remove dead code from old drawimage virtuals
Bug: skia:7650 Change-Id: Ie6bce2130519655645b7c5602d364cd0e1d6fdf3 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/356358 Reviewed-by: Mike Reed <reed@google.com> Commit-Queue: Mike Reed <reed@google.com>
This commit is contained in:
parent
08f5311ae1
commit
821a84558b
@ -35,7 +35,7 @@
|
||||
|
||||
// Working on allow this to be undefined
|
||||
#define SK_SUPPORT_LEGACY_GETTOTALMATRIX
|
||||
//#define SK_SUPPORT_LEGACY_ONDRAWIMAGERECT
|
||||
|
||||
#define SK_SUPPORT_LEGACY_DRAWBITMAP
|
||||
|
||||
#define SK_SUPPORT_LEGACY_DRAWIMAGE_NOSAMPLING
|
||||
@ -2552,21 +2552,6 @@ protected:
|
||||
virtual void onDrawPoints(PointMode mode, size_t count, const SkPoint pts[],
|
||||
const SkPaint& paint);
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_ONDRAWIMAGERECT
|
||||
virtual void onDrawImage(const SkImage* image, SkScalar dx, SkScalar dy, const SkPaint* paint);
|
||||
virtual void onDrawImageRect(const SkImage* image, const SkRect* src, const SkRect& dst,
|
||||
const SkPaint* paint, SrcRectConstraint constraint);
|
||||
virtual void onDrawImageLattice(const SkImage* image, const Lattice& lattice, const SkRect& dst,
|
||||
const SkPaint* paint);
|
||||
virtual void onDrawAtlas(const SkImage* atlas, const SkRSXform xform[], const SkRect rect[],
|
||||
const SkColor colors[], int count, SkBlendMode mode,
|
||||
const SkRect* cull, const SkPaint* paint);
|
||||
// never called -- remove from clients' subclasses
|
||||
virtual void onDrawImageNine(const SkImage*, const SkIRect&, const SkRect&, const SkPaint*) {}
|
||||
virtual void onDrawEdgeAAImageSet(const ImageSetEntry imageSet[], int count,
|
||||
const SkPoint dstClips[], const SkMatrix preViewMatrices[],
|
||||
const SkPaint* paint, SrcRectConstraint constraint);
|
||||
#endif
|
||||
virtual void onDrawImage2(const SkImage*, SkScalar dx, SkScalar dy, const SkSamplingOptions&,
|
||||
const SkPaint*);
|
||||
virtual void onDrawImageRect2(const SkImage*, const SkRect& src, const SkRect& dst,
|
||||
|
@ -35,17 +35,7 @@ public:
|
||||
void onDrawPoints(PointMode, size_t, const SkPoint[], const SkPaint&) override;
|
||||
void onDrawVerticesObject(const SkVertices*, SkBlendMode, const SkPaint&) override;
|
||||
void onDrawPath(const SkPath&, const SkPaint&) override;
|
||||
#ifdef SK_SUPPORT_LEGACY_ONDRAWIMAGERECT
|
||||
void onDrawImage(const SkImage*, SkScalar left, SkScalar top, const SkPaint*) override;
|
||||
void onDrawImageRect(const SkImage*, const SkRect* src, const SkRect& dst,
|
||||
const SkPaint*, SrcRectConstraint) override;
|
||||
void onDrawImageLattice(const SkImage*, const Lattice& lattice, const SkRect& dst,
|
||||
const SkPaint*) override;
|
||||
void onDrawAtlas(const SkImage*, const SkRSXform[], const SkRect[], const SkColor[],
|
||||
int, SkBlendMode, const SkRect*, const SkPaint*) override;
|
||||
void onDrawEdgeAAImageSet(const ImageSetEntry[], int count, const SkPoint[], const SkMatrix[],
|
||||
const SkPaint*, SrcRectConstraint) override;
|
||||
#endif
|
||||
|
||||
void onDrawImage2(const SkImage*, SkScalar, SkScalar, const SkSamplingOptions&,
|
||||
const SkPaint*) override;
|
||||
void onDrawImageRect2(const SkImage*, const SkRect&, const SkRect&, const SkSamplingOptions&,
|
||||
|
@ -51,17 +51,7 @@ protected:
|
||||
void onDrawArc(const SkRect&, SkScalar, SkScalar, bool, const SkPaint&) override;
|
||||
void onDrawRRect(const SkRRect&, const SkPaint&) override;
|
||||
void onDrawPath(const SkPath&, const SkPaint&) override;
|
||||
#ifdef SK_SUPPORT_LEGACY_ONDRAWIMAGERECT
|
||||
void onDrawImage(const SkImage*, SkScalar left, SkScalar top, const SkPaint*) override;
|
||||
void onDrawImageRect(const SkImage*, const SkRect* src, const SkRect& dst,
|
||||
const SkPaint*, SrcRectConstraint) override;
|
||||
void onDrawImageLattice(const SkImage*, const Lattice& lattice, const SkRect& dst,
|
||||
const SkPaint*) override;
|
||||
void onDrawAtlas(const SkImage*, const SkRSXform[], const SkRect[], const SkColor[],
|
||||
int, SkBlendMode, const SkRect*, const SkPaint*) override;
|
||||
void onDrawEdgeAAImageSet(const ImageSetEntry[], int count, const SkPoint[], const SkMatrix[],
|
||||
const SkPaint*, SrcRectConstraint) override;
|
||||
#endif
|
||||
|
||||
void onDrawImage2(const SkImage*, SkScalar, SkScalar, const SkSamplingOptions&,
|
||||
const SkPaint*) override;
|
||||
void onDrawImageRect2(const SkImage*, const SkRect&, const SkRect&, const SkSamplingOptions&,
|
||||
|
@ -53,17 +53,7 @@ protected:
|
||||
void onDrawArc(const SkRect&, SkScalar, SkScalar, bool, const SkPaint&) override {}
|
||||
void onDrawRRect(const SkRRect&, const SkPaint&) override {}
|
||||
void onDrawPath(const SkPath&, const SkPaint&) override {}
|
||||
#ifdef SK_SUPPORT_LEGACY_ONDRAWIMAGERECT
|
||||
void onDrawImage(const SkImage*, SkScalar, SkScalar, const SkPaint*) override {}
|
||||
void onDrawImageRect(const SkImage*, const SkRect*, const SkRect&, const SkPaint*,
|
||||
SrcRectConstraint) override {}
|
||||
void onDrawImageLattice(const SkImage*, const Lattice&, const SkRect&,
|
||||
const SkPaint*) override {}
|
||||
void onDrawAtlas(const SkImage*, const SkRSXform[], const SkRect[], const SkColor[],
|
||||
int, SkBlendMode, const SkRect*, const SkPaint*) override {}
|
||||
void onDrawEdgeAAImageSet(const ImageSetEntry[], int, const SkPoint[],
|
||||
const SkMatrix[], const SkPaint*, SrcRectConstraint) override {}
|
||||
#endif
|
||||
|
||||
void onDrawImage2(const SkImage*, SkScalar, SkScalar, const SkSamplingOptions&,
|
||||
const SkPaint*) override {}
|
||||
void onDrawImageRect2(const SkImage*, const SkRect&, const SkRect&, const SkSamplingOptions&,
|
||||
|
@ -57,17 +57,7 @@ protected:
|
||||
void onDrawOval(const SkRect&, const SkPaint&) override;
|
||||
void onDrawArc(const SkRect&, SkScalar, SkScalar, bool, const SkPaint&) override;
|
||||
void onDrawPath(const SkPath&, const SkPaint&) override;
|
||||
#ifdef SK_SUPPORT_LEGACY_ONDRAWIMAGERECT
|
||||
void onDrawImage(const SkImage*, SkScalar left, SkScalar top, const SkPaint*) override;
|
||||
void onDrawImageRect(const SkImage*, const SkRect* src, const SkRect& dst,
|
||||
const SkPaint*, SrcRectConstraint) override;
|
||||
void onDrawImageLattice(const SkImage*, const Lattice& lattice, const SkRect& dst,
|
||||
const SkPaint*) override;
|
||||
void onDrawAtlas(const SkImage*, const SkRSXform[], const SkRect[], const SkColor[],
|
||||
int, SkBlendMode, const SkRect*, const SkPaint*) override;
|
||||
void onDrawEdgeAAImageSet(const ImageSetEntry[], int count, const SkPoint[], const SkMatrix[],
|
||||
const SkPaint*, SrcRectConstraint) override;
|
||||
#endif
|
||||
|
||||
void onDrawImage2(const SkImage*, SkScalar, SkScalar, const SkSamplingOptions&,
|
||||
const SkPaint*) override;
|
||||
void onDrawImageRect2(const SkImage*, const SkRect&, const SkRect&, const SkSamplingOptions&,
|
||||
|
@ -1853,13 +1853,7 @@ void SkCanvas::drawPath(const SkPath& path, const SkPaint& paint) {
|
||||
}
|
||||
|
||||
void SkCanvas::drawImage(const SkImage* image, SkScalar x, SkScalar y, const SkPaint* paint) {
|
||||
#ifdef SK_SUPPORT_LEGACY_ONDRAWIMAGERECT
|
||||
TRACE_EVENT0("skia", TRACE_FUNC);
|
||||
RETURN_ON_NULL(image);
|
||||
this->onDrawImage(image, x, y, paint);
|
||||
#else
|
||||
this->drawImage(image, x, y, paint_to_sampling(paint, this->recordingContext()), paint);
|
||||
#endif
|
||||
}
|
||||
|
||||
// Returns true if the rect can be "filled" : non-empty and finite
|
||||
@ -1871,17 +1865,8 @@ static bool fillable(const SkRect& r) {
|
||||
|
||||
void SkCanvas::drawImageRect(const SkImage* image, const SkRect& src, const SkRect& dst,
|
||||
const SkPaint* paint, SrcRectConstraint constraint) {
|
||||
#ifdef SK_SUPPORT_LEGACY_ONDRAWIMAGERECT
|
||||
TRACE_EVENT0("skia", TRACE_FUNC);
|
||||
RETURN_ON_NULL(image);
|
||||
if (!fillable(dst) || !fillable(src)) {
|
||||
return;
|
||||
}
|
||||
this->onDrawImageRect(image, &src, dst, paint, constraint);
|
||||
#else
|
||||
this->drawImageRect(image, src, dst, paint_to_sampling(paint, this->recordingContext()),
|
||||
paint, constraint);
|
||||
#endif
|
||||
}
|
||||
|
||||
void SkCanvas::drawImageRect(const SkImage* image, const SkIRect& isrc, const SkRect& dst,
|
||||
@ -1928,23 +1913,7 @@ void SkCanvas::drawImageNine(const SkImage* image, const SkIRect& center, const
|
||||
|
||||
void SkCanvas::drawImageNine(const SkImage* image, const SkIRect& center, const SkRect& dst,
|
||||
const SkPaint* paint) {
|
||||
#ifdef SK_SUPPORT_LEGACY_ONDRAWIMAGERECT
|
||||
RETURN_ON_NULL(image);
|
||||
|
||||
const int xdivs[] = {center.fLeft, center.fRight};
|
||||
const int ydivs[] = {center.fTop, center.fBottom};
|
||||
|
||||
Lattice lat;
|
||||
lat.fXDivs = xdivs;
|
||||
lat.fYDivs = ydivs;
|
||||
lat.fRectTypes = nullptr;
|
||||
lat.fXCount = lat.fYCount = 2;
|
||||
lat.fBounds = nullptr;
|
||||
lat.fColors = nullptr;
|
||||
this->drawImageLattice(image, lat, dst, paint);
|
||||
#else
|
||||
this->drawImageNine(image, center, dst, paint_to_filter(paint), paint);
|
||||
#endif
|
||||
}
|
||||
|
||||
void SkCanvas::drawImageLattice(const SkImage* image, const Lattice& lattice, const SkRect& dst,
|
||||
@ -1973,29 +1942,7 @@ void SkCanvas::drawImageLattice(const SkImage* image, const Lattice& lattice, co
|
||||
|
||||
void SkCanvas::drawImageLattice(const SkImage* image, const Lattice& lattice, const SkRect& dst,
|
||||
const SkPaint* paint) {
|
||||
#ifdef SK_SUPPORT_LEGACY_ONDRAWIMAGERECT
|
||||
TRACE_EVENT0("skia", TRACE_FUNC);
|
||||
RETURN_ON_NULL(image);
|
||||
if (dst.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
SkIRect bounds;
|
||||
Lattice latticePlusBounds = lattice;
|
||||
if (!latticePlusBounds.fBounds) {
|
||||
bounds = SkIRect::MakeWH(image->width(), image->height());
|
||||
latticePlusBounds.fBounds = &bounds;
|
||||
}
|
||||
|
||||
if (SkLatticeIter::Valid(image->width(), image->height(), latticePlusBounds)) {
|
||||
SkPaint latticePaint = clean_paint_for_lattice(paint);
|
||||
this->onDrawImageLattice(image, latticePlusBounds, dst, &latticePaint);
|
||||
} else {
|
||||
this->drawImageRect(image, dst, paint);
|
||||
}
|
||||
#else
|
||||
this->drawImageLattice(image, lattice, dst, paint_to_filter(paint), paint);
|
||||
#endif
|
||||
}
|
||||
|
||||
static sk_sp<SkImage> bitmap_as_image(const SkBitmap& bitmap) {
|
||||
@ -2042,19 +1989,8 @@ void SkCanvas::drawAtlas(const SkImage* atlas, const SkRSXform xform[], const Sk
|
||||
void SkCanvas::drawAtlas(const SkImage* atlas, const SkRSXform xform[], const SkRect tex[],
|
||||
const SkColor colors[], int count, SkBlendMode mode,
|
||||
const SkRect* cull, const SkPaint* paint) {
|
||||
#ifdef SK_SUPPORT_LEGACY_ONDRAWIMAGERECT
|
||||
TRACE_EVENT0("skia", TRACE_FUNC);
|
||||
RETURN_ON_NULL(atlas);
|
||||
if (count <= 0) {
|
||||
return;
|
||||
}
|
||||
SkASSERT(atlas);
|
||||
SkASSERT(tex);
|
||||
this->onDrawAtlas(atlas, xform, tex, colors, count, mode, cull, paint);
|
||||
#else
|
||||
this->drawAtlas(atlas, xform, tex, colors, count, mode,
|
||||
paint_to_sampling(paint, this->recordingContext()), cull, paint);
|
||||
#endif
|
||||
}
|
||||
|
||||
void SkCanvas::drawAnnotation(const SkRect& rect, const char key[], SkData* value) {
|
||||
@ -2100,14 +2036,9 @@ void SkCanvas::experimental_DrawEdgeAAImageSet(const ImageSetEntry imageSet[], i
|
||||
const SkMatrix preViewMatrices[],
|
||||
const SkPaint* paint,
|
||||
SrcRectConstraint constraint) {
|
||||
#ifdef SK_SUPPORT_LEGACY_ONDRAWIMAGERECT
|
||||
TRACE_EVENT0("skia", TRACE_FUNC);
|
||||
this->onDrawEdgeAAImageSet(imageSet, cnt, dstClips, preViewMatrices, paint, constraint);
|
||||
#else
|
||||
this->experimental_DrawEdgeAAImageSet(imageSet, cnt, dstClips, preViewMatrices,
|
||||
paint_to_sampling(paint, this->recordingContext()),
|
||||
paint, constraint);
|
||||
#endif
|
||||
}
|
||||
|
||||
void SkCanvas::experimental_DrawEdgeAAImageSet(const ImageSetEntry imageSet[], int cnt,
|
||||
@ -2356,135 +2287,6 @@ static SkPaint clean_paint_for_drawVertices(SkPaint paint) {
|
||||
return paint;
|
||||
}
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_ONDRAWIMAGERECT
|
||||
void SkCanvas::onDrawImage(const SkImage* image, SkScalar x, SkScalar y, const SkPaint* paint) {
|
||||
SkPaint realPaint = clean_paint_for_drawImage(paint);
|
||||
SkSamplingOptions sampling = paint_to_sampling(&realPaint, this->recordingContext());
|
||||
|
||||
SkRect bounds = SkRect::MakeXYWH(x, y, image->width(), image->height());
|
||||
if (this->internalQuickReject(bounds, realPaint)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (realPaint.getImageFilter() &&
|
||||
this->canDrawBitmapAsSprite(x, y, image->width(), image->height(), sampling, realPaint) &&
|
||||
!image_to_color_filter(&realPaint)) {
|
||||
// Evaluate the image filter directly on the input image and then draw the result, instead
|
||||
// of first drawing the image to a temporary layer and filtering.
|
||||
SkBaseDevice* device = this->topDevice();
|
||||
sk_sp<SkSpecialImage> special;
|
||||
if ((special = device->makeSpecial(image))) {
|
||||
sk_sp<SkImageFilter> filter = realPaint.refImageFilter();
|
||||
realPaint.setImageFilter(nullptr);
|
||||
|
||||
// TODO(michaelludwig) - Many filters could probably be evaluated like this even if the
|
||||
// CTM is not translate-only; the post-transformation of the filtered image by the CTM
|
||||
// will probably look just as good and not require an extra layer.
|
||||
// TODO(michaelludwig) - Once image filter implementations can support source images
|
||||
// with non-(0,0) origins, we can just mark the origin as (x,y) instead of doing a
|
||||
// pre-concat here.
|
||||
SkMatrix layerToDevice = device->localToDevice();
|
||||
layerToDevice.preTranslate(x, y);
|
||||
skif::Mapping mapping(layerToDevice, SkMatrix::Translate(-x, -y));
|
||||
|
||||
this->predrawNotify();
|
||||
device->drawFilteredImage(mapping, special.get(), filter.get(), sampling, realPaint);
|
||||
return;
|
||||
} // else fall through to regular drawing path
|
||||
}
|
||||
|
||||
AutoLayerForImageFilter layer(this, realPaint, &bounds);
|
||||
this->topDevice()->drawImageRect(image, nullptr, bounds, sampling,
|
||||
layer.paint(), kStrict_SrcRectConstraint);
|
||||
}
|
||||
|
||||
void SkCanvas::onDrawImageRect(const SkImage* image, const SkRect* src, const SkRect& dst,
|
||||
const SkPaint* paint, SrcRectConstraint constraint) {
|
||||
SkPaint realPaint = clean_paint_for_drawImage(paint);
|
||||
SkSamplingOptions sampling = paint_to_sampling(&realPaint, this->recordingContext());
|
||||
|
||||
if (this->internalQuickReject(dst, realPaint)) {
|
||||
return;
|
||||
}
|
||||
|
||||
AutoLayerForImageFilter layer(this, realPaint, &dst, CheckForOverwrite::kYes,
|
||||
image->isOpaque() ? kOpaque_ShaderOverrideOpacity
|
||||
: kNotOpaque_ShaderOverrideOpacity);
|
||||
this->topDevice()->drawImageRect(image, src, dst, sampling, layer.paint(), constraint);
|
||||
}
|
||||
|
||||
void SkCanvas::onDrawImageLattice(const SkImage* image, const Lattice& lattice, const SkRect& dst,
|
||||
const SkPaint* paint) {
|
||||
SkPaint realPaint = clean_paint_for_drawImage(paint);
|
||||
|
||||
if (this->internalQuickReject(dst, realPaint)) {
|
||||
return;
|
||||
}
|
||||
|
||||
AutoLayerForImageFilter layer(this, realPaint, &dst);
|
||||
this->topDevice()->drawImageLattice(image, lattice, dst, paint_to_filter(&realPaint),
|
||||
layer.paint());
|
||||
}
|
||||
|
||||
void SkCanvas::onDrawAtlas(const SkImage* atlas, const SkRSXform xform[], const SkRect tex[],
|
||||
const SkColor colors[], int count, SkBlendMode bmode,
|
||||
const SkRect* cull, const SkPaint* paint) {
|
||||
// drawAtlas is a combination of drawVertices and drawImage...
|
||||
SkPaint realPaint = clean_paint_for_drawVertices(clean_paint_for_drawImage(paint));
|
||||
SkSamplingOptions sampling = paint_to_sampling(&realPaint, this->recordingContext());
|
||||
|
||||
if (cull && this->internalQuickReject(*cull, realPaint)) {
|
||||
return;
|
||||
}
|
||||
|
||||
AutoLayerForImageFilter layer(this, realPaint);
|
||||
this->topDevice()->drawAtlas(atlas, xform, tex, colors, count, bmode, sampling, layer.paint());
|
||||
}
|
||||
|
||||
void SkCanvas::onDrawEdgeAAImageSet(const ImageSetEntry imageSet[], int count,
|
||||
const SkPoint dstClips[], const SkMatrix preViewMatrices[],
|
||||
const SkPaint* paint, SrcRectConstraint constraint) {
|
||||
if (count <= 0) {
|
||||
// Nothing to draw
|
||||
return;
|
||||
}
|
||||
|
||||
SkPaint realPaint = clean_paint_for_drawImage(paint);
|
||||
|
||||
// We could calculate the set's dstRect union to always check quickReject(), but we can't reject
|
||||
// individual entries and Chromium's occlusion culling already makes it likely that at least one
|
||||
// entry will be visible. So, we only calculate the draw bounds when it's trivial (count == 1),
|
||||
// or we need it for the autolooper (since it greatly improves image filter perf).
|
||||
bool needsAutoLayer = SkToBool(realPaint.getImageFilter());
|
||||
bool setBoundsValid = count == 1 || needsAutoLayer;
|
||||
SkRect setBounds = imageSet[0].fDstRect;
|
||||
if (imageSet[0].fMatrixIndex >= 0) {
|
||||
// Account for the per-entry transform that is applied prior to the CTM when drawing
|
||||
preViewMatrices[imageSet[0].fMatrixIndex].mapRect(&setBounds);
|
||||
}
|
||||
if (needsAutoLayer) {
|
||||
for (int i = 1; i < count; ++i) {
|
||||
SkRect entryBounds = imageSet[i].fDstRect;
|
||||
if (imageSet[i].fMatrixIndex >= 0) {
|
||||
preViewMatrices[imageSet[i].fMatrixIndex].mapRect(&entryBounds);
|
||||
}
|
||||
setBounds.joinPossiblyEmptyRect(entryBounds);
|
||||
}
|
||||
}
|
||||
|
||||
// If we happen to have the draw bounds, though, might as well check quickReject().
|
||||
if (setBoundsValid && this->internalQuickReject(setBounds, realPaint)) {
|
||||
return;
|
||||
}
|
||||
|
||||
AutoLayerForImageFilter layer(this, realPaint, setBoundsValid ? &setBounds : nullptr);
|
||||
this->topDevice()->drawEdgeAAImageSet(imageSet, count, dstClips, preViewMatrices,
|
||||
SkSamplingOptions(SkPaintPriv::GetFQ(layer.paint())),
|
||||
layer.paint(), constraint);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void SkCanvas::onDrawImage2(const SkImage* image, SkScalar x, SkScalar y,
|
||||
const SkSamplingOptions& sampling, const SkPaint* paint) {
|
||||
SkPaint realPaint = clean_paint_for_drawImage(paint);
|
||||
|
@ -154,73 +154,6 @@ void SkOverdrawCanvas::onDrawPath(const SkPath& path, const SkPaint& paint) {
|
||||
fList[0]->onDrawPath(path, fPaint);
|
||||
}
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_ONDRAWIMAGERECT
|
||||
void SkOverdrawCanvas::onDrawImage(const SkImage* image, SkScalar x, SkScalar y, const SkPaint*) {
|
||||
fList[0]->onDrawRect(SkRect::MakeXYWH(x, y, image->width(), image->height()), fPaint);
|
||||
}
|
||||
|
||||
void SkOverdrawCanvas::onDrawImageRect(const SkImage* image, const SkRect* src, const SkRect& dst,
|
||||
const SkPaint*, SrcRectConstraint) {
|
||||
fList[0]->onDrawRect(dst, fPaint);
|
||||
}
|
||||
|
||||
void SkOverdrawCanvas::onDrawImageLattice(const SkImage* image, const Lattice& lattice,
|
||||
const SkRect& dst, const SkPaint*) {
|
||||
SkIRect bounds;
|
||||
Lattice latticePlusBounds = lattice;
|
||||
if (!latticePlusBounds.fBounds) {
|
||||
bounds = SkIRect::MakeWH(image->width(), image->height());
|
||||
latticePlusBounds.fBounds = &bounds;
|
||||
}
|
||||
|
||||
if (SkLatticeIter::Valid(image->width(), image->height(), latticePlusBounds)) {
|
||||
SkLatticeIter iter(latticePlusBounds, dst);
|
||||
|
||||
SkRect unusedSrc, iterDst;
|
||||
while (iter.next(&unusedSrc, &iterDst)) {
|
||||
fList[0]->onDrawRect(iterDst, fPaint);
|
||||
}
|
||||
} else {
|
||||
fList[0]->onDrawRect(dst, fPaint);
|
||||
}
|
||||
}
|
||||
|
||||
void SkOverdrawCanvas::onDrawAtlas(const SkImage* image, const SkRSXform xform[],
|
||||
const SkRect texs[], const SkColor colors[], int count,
|
||||
SkBlendMode mode, const SkRect* cull, const SkPaint* paint) {
|
||||
SkPaint* paintPtr = &fPaint;
|
||||
SkPaint storage;
|
||||
if (paint) {
|
||||
storage = this->overdrawPaint(*paint);
|
||||
paintPtr = &storage;
|
||||
}
|
||||
|
||||
fList[0]->onDrawAtlas(image, xform, texs, colors, count, mode, cull, paintPtr);
|
||||
}
|
||||
|
||||
void SkOverdrawCanvas::onDrawEdgeAAImageSet(const ImageSetEntry set[], int count,
|
||||
const SkPoint dstClips[],
|
||||
const SkMatrix preViewMatrices[], const SkPaint* paint,
|
||||
SrcRectConstraint constraint) {
|
||||
int clipIndex = 0;
|
||||
for (int i = 0; i < count; ++i) {
|
||||
if (set[i].fMatrixIndex >= 0) {
|
||||
fList[0]->save();
|
||||
fList[0]->concat(preViewMatrices[set[i].fMatrixIndex]);
|
||||
}
|
||||
if (set[i].fHasClip) {
|
||||
fList[0]->onDrawPath(SkPath::Polygon(dstClips + clipIndex, 4, true), fPaint);
|
||||
clipIndex += 4;
|
||||
} else {
|
||||
fList[0]->onDrawRect(set[i].fDstRect, fPaint);
|
||||
}
|
||||
if (set[i].fMatrixIndex >= 0) {
|
||||
fList[0]->restore();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void SkOverdrawCanvas::onDrawImage2(const SkImage* image, SkScalar x, SkScalar y,
|
||||
const SkSamplingOptions&, const SkPaint*) {
|
||||
fList[0]->onDrawRect(SkRect::MakeXYWH(x, y, image->width(), image->height()), fPaint);
|
||||
|
@ -535,122 +535,6 @@ void SkPictureRecord::onDrawPath(const SkPath& path, const SkPaint& paint) {
|
||||
this->validate(initialOffset, size);
|
||||
}
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_ONDRAWIMAGERECT
|
||||
void SkPictureRecord::onDrawImage(const SkImage* image, SkScalar x, SkScalar y,
|
||||
const SkPaint* paint) {
|
||||
// op + paint_index + image_index + x + y
|
||||
size_t size = 3 * kUInt32Size + 2 * sizeof(SkScalar);
|
||||
size_t initialOffset = this->addDraw(DRAW_IMAGE, &size);
|
||||
this->addPaintPtr(paint);
|
||||
this->addImage(image);
|
||||
this->addScalar(x);
|
||||
this->addScalar(y);
|
||||
this->validate(initialOffset, size);
|
||||
}
|
||||
|
||||
void SkPictureRecord::onDrawImageRect(const SkImage* image, const SkRect* src, const SkRect& dst,
|
||||
const SkPaint* paint, SrcRectConstraint constraint) {
|
||||
// id + paint_index + image_index + bool_for_src + constraint
|
||||
size_t size = 5 * kUInt32Size;
|
||||
if (src) {
|
||||
size += sizeof(*src); // + rect
|
||||
}
|
||||
size += sizeof(dst); // + rect
|
||||
|
||||
size_t initialOffset = this->addDraw(DRAW_IMAGE_RECT, &size);
|
||||
this->addPaintPtr(paint);
|
||||
this->addImage(image);
|
||||
this->addRectPtr(src); // may be null
|
||||
this->addRect(dst);
|
||||
this->addInt(constraint);
|
||||
this->validate(initialOffset, size);
|
||||
}
|
||||
|
||||
void SkPictureRecord::onDrawImageLattice(const SkImage* image, const Lattice& lattice,
|
||||
const SkRect& dst, const SkPaint* paint) {
|
||||
size_t latticeSize = SkCanvasPriv::WriteLattice(nullptr, lattice);
|
||||
// op + paint index + image index + lattice + dst rect
|
||||
size_t size = 3 * kUInt32Size + latticeSize + sizeof(dst);
|
||||
size_t initialOffset = this->addDraw(DRAW_IMAGE_LATTICE, &size);
|
||||
this->addPaintPtr(paint);
|
||||
this->addImage(image);
|
||||
(void)SkCanvasPriv::WriteLattice(fWriter.reservePad(latticeSize), lattice);
|
||||
this->addRect(dst);
|
||||
this->validate(initialOffset, size);
|
||||
}
|
||||
|
||||
void SkPictureRecord::onDrawAtlas(const SkImage* atlas, const SkRSXform xform[], const SkRect tex[],
|
||||
const SkColor colors[], int count, SkBlendMode mode,
|
||||
const SkRect* cull, const SkPaint* paint) {
|
||||
// [op + paint-index + atlas-index + flags + count] + [xform] + [tex] + [*colors + mode] + cull
|
||||
size_t size = 5 * kUInt32Size + count * sizeof(SkRSXform) + count * sizeof(SkRect);
|
||||
uint32_t flags = 0;
|
||||
if (colors) {
|
||||
flags |= DRAW_ATLAS_HAS_COLORS;
|
||||
size += count * sizeof(SkColor);
|
||||
size += sizeof(uint32_t); // xfermode::mode
|
||||
}
|
||||
if (cull) {
|
||||
flags |= DRAW_ATLAS_HAS_CULL;
|
||||
size += sizeof(SkRect);
|
||||
}
|
||||
|
||||
size_t initialOffset = this->addDraw(DRAW_ATLAS, &size);
|
||||
this->addPaintPtr(paint);
|
||||
this->addImage(atlas);
|
||||
this->addInt(flags);
|
||||
this->addInt(count);
|
||||
fWriter.write(xform, count * sizeof(SkRSXform));
|
||||
fWriter.write(tex, count * sizeof(SkRect));
|
||||
|
||||
// write optional parameters
|
||||
if (colors) {
|
||||
fWriter.write(colors, count * sizeof(SkColor));
|
||||
this->addInt((int)mode);
|
||||
}
|
||||
if (cull) {
|
||||
fWriter.write(cull, sizeof(SkRect));
|
||||
}
|
||||
this->validate(initialOffset, size);
|
||||
}
|
||||
|
||||
void SkPictureRecord::onDrawEdgeAAImageSet(const SkCanvas::ImageSetEntry set[], int count,
|
||||
const SkPoint dstClips[],
|
||||
const SkMatrix preViewMatrices[],
|
||||
const SkPaint* paint,
|
||||
SkCanvas::SrcRectConstraint constraint) {
|
||||
static constexpr size_t kMatrixSize = 9 * sizeof(SkScalar); // *not* sizeof(SkMatrix)
|
||||
// op + count + paint + constraint + (image index, src rect, dst rect, alpha, aa flags,
|
||||
// hasClip(int), matrixIndex) * cnt + totalClipCount + dstClips + totalMatrixCount + matrices
|
||||
int totalDstClipCount, totalMatrixCount;
|
||||
SkCanvasPriv::GetDstClipAndMatrixCounts(set, count, &totalDstClipCount, &totalMatrixCount);
|
||||
|
||||
size_t size = 6 * kUInt32Size + sizeof(SkPoint) * totalDstClipCount +
|
||||
kMatrixSize * totalMatrixCount +
|
||||
(4 * kUInt32Size + 2 * sizeof(SkRect) + sizeof(SkScalar)) * count;
|
||||
size_t initialOffset = this->addDraw(DRAW_EDGEAA_IMAGE_SET, &size);
|
||||
this->addInt(count);
|
||||
this->addPaintPtr(paint);
|
||||
this->addInt((int) constraint);
|
||||
for (int i = 0; i < count; ++i) {
|
||||
this->addImage(set[i].fImage.get());
|
||||
this->addRect(set[i].fSrcRect);
|
||||
this->addRect(set[i].fDstRect);
|
||||
this->addInt(set[i].fMatrixIndex);
|
||||
this->addScalar(set[i].fAlpha);
|
||||
this->addInt((int)set[i].fAAFlags);
|
||||
this->addInt(set[i].fHasClip);
|
||||
}
|
||||
this->addInt(totalDstClipCount);
|
||||
this->addPoints(dstClips, totalDstClipCount);
|
||||
this->addInt(totalMatrixCount);
|
||||
for (int i = 0; i < totalMatrixCount; ++i) {
|
||||
this->addMatrix(preViewMatrices[i]);
|
||||
}
|
||||
this->validate(initialOffset, size);
|
||||
}
|
||||
#endif
|
||||
|
||||
void SkPictureRecord::onDrawImage2(const SkImage* image, SkScalar x, SkScalar y,
|
||||
const SkSamplingOptions& sampling, const SkPaint* paint) {
|
||||
// op + paint_index + image_index + x + y
|
||||
|
@ -186,17 +186,7 @@ protected:
|
||||
void onDrawArc(const SkRect&, SkScalar, SkScalar, bool, const SkPaint&) override;
|
||||
void onDrawRRect(const SkRRect&, const SkPaint&) override;
|
||||
void onDrawPath(const SkPath&, const SkPaint&) override;
|
||||
#ifdef SK_SUPPORT_LEGACY_ONDRAWIMAGERECT
|
||||
void onDrawImage(const SkImage*, SkScalar left, SkScalar top, const SkPaint*) override;
|
||||
void onDrawImageRect(const SkImage*, const SkRect* src, const SkRect& dst,
|
||||
const SkPaint*, SrcRectConstraint) override;
|
||||
void onDrawImageLattice(const SkImage*, const Lattice& lattice, const SkRect& dst,
|
||||
const SkPaint*) override;
|
||||
void onDrawAtlas(const SkImage*, const SkRSXform[], const SkRect[], const SkColor[], int,
|
||||
SkBlendMode, const SkRect*, const SkPaint*) override;
|
||||
void onDrawEdgeAAImageSet(const ImageSetEntry[], int count, const SkPoint[], const SkMatrix[],
|
||||
const SkPaint*, SrcRectConstraint) override;
|
||||
#endif
|
||||
|
||||
void onDrawImage2(const SkImage*, SkScalar, SkScalar, const SkSamplingOptions&,
|
||||
const SkPaint*) override;
|
||||
void onDrawImageRect2(const SkImage*, const SkRect&, const SkRect&, const SkSamplingOptions&,
|
||||
|
@ -204,56 +204,6 @@ void SkRecorder::onDrawPath(const SkPath& path, const SkPaint& paint) {
|
||||
this->append<SkRecords::DrawPath>(paint, path);
|
||||
}
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_ONDRAWIMAGERECT
|
||||
void SkRecorder::onDrawImage(const SkImage* image, SkScalar left, SkScalar top,
|
||||
const SkPaint* paint) {
|
||||
this->append<SkRecords::DrawImage>(this->copy(paint), sk_ref_sp(image), left, top);
|
||||
}
|
||||
|
||||
void SkRecorder::onDrawImageRect(const SkImage* image, const SkRect* src, const SkRect& dst,
|
||||
const SkPaint* paint, SrcRectConstraint constraint) {
|
||||
this->append<SkRecords::DrawImageRect>(this->copy(paint), sk_ref_sp(image), this->copy(src), dst, constraint);
|
||||
}
|
||||
|
||||
void SkRecorder::onDrawImageLattice(const SkImage* image, const Lattice& lattice, const SkRect& dst,
|
||||
const SkPaint* paint) {
|
||||
int flagCount = lattice.fRectTypes ? (lattice.fXCount + 1) * (lattice.fYCount + 1) : 0;
|
||||
SkASSERT(lattice.fBounds);
|
||||
this->append<SkRecords::DrawImageLattice>(this->copy(paint), sk_ref_sp(image),
|
||||
lattice.fXCount, this->copy(lattice.fXDivs, lattice.fXCount),
|
||||
lattice.fYCount, this->copy(lattice.fYDivs, lattice.fYCount),
|
||||
flagCount, this->copy(lattice.fRectTypes, flagCount),
|
||||
this->copy(lattice.fColors, flagCount), *lattice.fBounds, dst);
|
||||
}
|
||||
void SkRecorder::onDrawAtlas(const SkImage* atlas, const SkRSXform xform[], const SkRect tex[],
|
||||
const SkColor colors[], int count, SkBlendMode mode,
|
||||
const SkRect* cull, const SkPaint* paint) {
|
||||
this->append<SkRecords::DrawAtlas>(this->copy(paint),
|
||||
sk_ref_sp(atlas),
|
||||
this->copy(xform, count),
|
||||
this->copy(tex, count),
|
||||
this->copy(colors, count),
|
||||
count,
|
||||
mode,
|
||||
this->copy(cull));
|
||||
}
|
||||
void SkRecorder::onDrawEdgeAAImageSet(const ImageSetEntry set[], int count,
|
||||
const SkPoint dstClips[], const SkMatrix preViewMatrices[],
|
||||
const SkPaint* paint, SrcRectConstraint constraint) {
|
||||
int totalDstClipCount, totalMatrixCount;
|
||||
SkCanvasPriv::GetDstClipAndMatrixCounts(set, count, &totalDstClipCount, &totalMatrixCount);
|
||||
|
||||
SkAutoTArray<ImageSetEntry> setCopy(count);
|
||||
for (int i = 0; i < count; ++i) {
|
||||
setCopy[i] = set[i];
|
||||
}
|
||||
|
||||
this->append<SkRecords::DrawEdgeAAImageSet>(this->copy(paint), std::move(setCopy), count,
|
||||
this->copy(dstClips, totalDstClipCount),
|
||||
this->copy(preViewMatrices, totalMatrixCount), constraint);
|
||||
}
|
||||
#endif
|
||||
|
||||
void SkRecorder::onDrawImage2(const SkImage* image, SkScalar x, SkScalar y,
|
||||
const SkSamplingOptions& sampling, const SkPaint* paint) {
|
||||
this->append<SkRecords::DrawImage2>(this->copy(paint), sk_ref_sp(image), x, y, sampling);
|
||||
|
@ -86,17 +86,7 @@ public:
|
||||
void onDrawArc(const SkRect&, SkScalar, SkScalar, bool, const SkPaint&) override;
|
||||
void onDrawRRect(const SkRRect&, const SkPaint&) override;
|
||||
void onDrawPath(const SkPath&, const SkPaint&) override;
|
||||
#ifdef SK_SUPPORT_LEGACY_ONDRAWIMAGERECT
|
||||
void onDrawImage(const SkImage*, SkScalar left, SkScalar top, const SkPaint*) override;
|
||||
void onDrawImageRect(const SkImage*, const SkRect* src, const SkRect& dst,
|
||||
const SkPaint*, SrcRectConstraint) override;
|
||||
void onDrawImageLattice(const SkImage*, const Lattice& lattice, const SkRect& dst,
|
||||
const SkPaint*) override;
|
||||
void onDrawAtlas(const SkImage*, const SkRSXform[], const SkRect[], const SkColor[],
|
||||
int, SkBlendMode, const SkRect*, const SkPaint*) override;
|
||||
void onDrawEdgeAAImageSet(const ImageSetEntry[], int count, const SkPoint[], const SkMatrix[],
|
||||
const SkPaint*, SrcRectConstraint) override;
|
||||
#endif
|
||||
|
||||
void onDrawImage2(const SkImage*, SkScalar, SkScalar, const SkSamplingOptions&,
|
||||
const SkPaint*) override;
|
||||
void onDrawImageRect2(const SkImage*, const SkRect&, const SkRect&, const SkSamplingOptions&,
|
||||
|
@ -241,49 +241,6 @@ void SkNWayCanvas::onDrawPath(const SkPath& path, const SkPaint& paint) {
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_ONDRAWIMAGERECT
|
||||
void SkNWayCanvas::onDrawImage(const SkImage* image, SkScalar left, SkScalar top,
|
||||
const SkPaint* paint) {
|
||||
Iter iter(fList);
|
||||
while (iter.next()) {
|
||||
iter->drawImage(image, left, top, paint);
|
||||
}
|
||||
}
|
||||
|
||||
void SkNWayCanvas::onDrawImageRect(const SkImage* image, const SkRect* src, const SkRect& dst,
|
||||
const SkPaint* paint, SrcRectConstraint constraint) {
|
||||
Iter iter(fList);
|
||||
while (iter.next()) {
|
||||
iter->legacy_drawImageRect(image, src, dst, paint, constraint);
|
||||
}
|
||||
}
|
||||
|
||||
void SkNWayCanvas::onDrawImageLattice(const SkImage* image, const Lattice& lattice,
|
||||
const SkRect& dst, const SkPaint* paint) {
|
||||
Iter iter(fList);
|
||||
while (iter.next()) {
|
||||
iter->drawImageLattice(image, lattice, dst, paint);
|
||||
}
|
||||
}
|
||||
void SkNWayCanvas::onDrawAtlas(const SkImage* image, const SkRSXform xform[], const SkRect tex[],
|
||||
const SkColor colors[], int count, SkBlendMode bmode,
|
||||
const SkRect* cull, const SkPaint* paint) {
|
||||
Iter iter(fList);
|
||||
while (iter.next()) {
|
||||
iter->drawAtlas(image, xform, tex, colors, count, bmode, cull, paint);
|
||||
}
|
||||
}
|
||||
void SkNWayCanvas::onDrawEdgeAAImageSet(const ImageSetEntry set[], int count,
|
||||
const SkPoint dstClips[], const SkMatrix preViewMatrices[],
|
||||
const SkPaint* paint, SrcRectConstraint constraint) {
|
||||
Iter iter(fList);
|
||||
while (iter.next()) {
|
||||
iter->experimental_DrawEdgeAAImageSet(
|
||||
set, count, dstClips, preViewMatrices, paint, constraint);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void SkNWayCanvas::onDrawImage2(const SkImage* image, SkScalar left, SkScalar top,
|
||||
const SkSamplingOptions& sampling, const SkPaint* paint) {
|
||||
Iter iter(fList);
|
||||
|
@ -116,51 +116,6 @@ void SkPaintFilterCanvas::onDrawPath(const SkPath& path, const SkPaint& paint) {
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_ONDRAWIMAGERECT
|
||||
void SkPaintFilterCanvas::onDrawImage(const SkImage* image, SkScalar left, SkScalar top,
|
||||
const SkPaint* paint) {
|
||||
AutoPaintFilter apf(this, paint);
|
||||
if (apf.shouldDraw()) {
|
||||
this->SkNWayCanvas::onDrawImage(image, left, top, &apf.paint());
|
||||
}
|
||||
}
|
||||
|
||||
void SkPaintFilterCanvas::onDrawImageRect(const SkImage* image, const SkRect* src,
|
||||
const SkRect& dst, const SkPaint* paint,
|
||||
SrcRectConstraint constraint) {
|
||||
AutoPaintFilter apf(this, paint);
|
||||
if (apf.shouldDraw()) {
|
||||
this->SkNWayCanvas::onDrawImageRect(image, src, dst, &apf.paint(), constraint);
|
||||
}
|
||||
}
|
||||
|
||||
void SkPaintFilterCanvas::onDrawImageLattice(const SkImage* image, const Lattice& lattice,
|
||||
const SkRect& dst, const SkPaint* paint) {
|
||||
AutoPaintFilter apf(this, paint);
|
||||
if (apf.shouldDraw()) {
|
||||
this->SkNWayCanvas::onDrawImageLattice(image, lattice, dst, &apf.paint());
|
||||
}
|
||||
}
|
||||
void SkPaintFilterCanvas::onDrawAtlas(const SkImage* image, const SkRSXform xform[],
|
||||
const SkRect tex[], const SkColor colors[], int count,
|
||||
SkBlendMode bmode, const SkRect* cull, const SkPaint* paint) {
|
||||
AutoPaintFilter apf(this, paint);
|
||||
if (apf.shouldDraw()) {
|
||||
this->SkNWayCanvas::onDrawAtlas(image, xform, tex, colors, count, bmode, cull, &apf.paint());
|
||||
}
|
||||
}
|
||||
void SkPaintFilterCanvas::onDrawEdgeAAImageSet(const ImageSetEntry set[], int count,
|
||||
const SkPoint dstClips[],
|
||||
const SkMatrix preViewMatrices[],
|
||||
const SkPaint* paint, SrcRectConstraint constraint) {
|
||||
AutoPaintFilter apf(this, paint);
|
||||
if (apf.shouldDraw()) {
|
||||
this->SkNWayCanvas::onDrawEdgeAAImageSet(
|
||||
set, count, dstClips, preViewMatrices, &apf.paint(), constraint);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void SkPaintFilterCanvas::onDrawImage2(const SkImage* image, SkScalar left, SkScalar top,
|
||||
const SkSamplingOptions& sampling, const SkPaint* paint) {
|
||||
AutoPaintFilter apf(this, paint);
|
||||
|
@ -269,18 +269,6 @@ DEF_TEST(RecordDraw_drawImage, r){
|
||||
this->resetTestValues();
|
||||
}
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_ONDRAWIMAGERECT
|
||||
void onDrawImage(const SkImage* image, SkScalar left, SkScalar top,
|
||||
const SkPaint* paint) override {
|
||||
fDrawImageCalled = true;
|
||||
}
|
||||
|
||||
void onDrawImageRect(const SkImage* image, const SkRect* src, const SkRect& dst,
|
||||
const SkPaint* paint, SrcRectConstraint) override {
|
||||
fDrawImageRectCalled = true;
|
||||
}
|
||||
#endif
|
||||
|
||||
void resetTestValues() {
|
||||
fDrawImageCalled = fDrawImageRectCalled = false;
|
||||
}
|
||||
@ -294,23 +282,4 @@ DEF_TEST(RecordDraw_drawImage, r){
|
||||
sk_sp<SkImage> image(surface->makeImageSnapshot());
|
||||
|
||||
SkCanvasMock canvas(10, 10);
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_ONDRAWIMAGERECT
|
||||
{
|
||||
SkRecord record;
|
||||
SkRecorder recorder(&record, 10, 10);
|
||||
recorder.drawImage(image, 0, 0);
|
||||
SkRecordDraw(record, &canvas, nullptr, nullptr, 0, nullptr, nullptr);
|
||||
}
|
||||
REPORTER_ASSERT(r, canvas.fDrawImageCalled);
|
||||
canvas.resetTestValues();
|
||||
|
||||
{
|
||||
SkRecord record;
|
||||
SkRecorder recorder(&record, 10, 10);
|
||||
recorder.drawImageRect(image, SkRect::MakeWH(10, 10), nullptr);
|
||||
SkRecordDraw(record, &canvas, nullptr, nullptr, 0, nullptr, nullptr);
|
||||
}
|
||||
REPORTER_ASSERT(r, canvas.fDrawImageRectCalled);
|
||||
#endif
|
||||
}
|
||||
|
@ -78,37 +78,6 @@ DEF_TEST(Recorder_drawImage_takeReference, reporter) {
|
||||
surface->getCanvas()->clear(SK_ColorGREEN);
|
||||
image = surface->makeImageSnapshot();
|
||||
}
|
||||
#ifdef SK_SUPPORT_LEGACY_ONDRAWIMAGERECT
|
||||
{
|
||||
SkRecord record;
|
||||
SkRecorder recorder(&record, 100, 100);
|
||||
|
||||
// DrawImage is supposed to take a reference
|
||||
recorder.drawImage(image, 0, 0);
|
||||
REPORTER_ASSERT(reporter, !image->unique());
|
||||
|
||||
Tally tally;
|
||||
tally.apply(record);
|
||||
|
||||
REPORTER_ASSERT(reporter, 1 == tally.count<SkRecords::DrawImage>());
|
||||
}
|
||||
REPORTER_ASSERT(reporter, image->unique());
|
||||
|
||||
{
|
||||
SkRecord record;
|
||||
SkRecorder recorder(&record, 100, 100);
|
||||
|
||||
// DrawImageRect is supposed to take a reference
|
||||
recorder.drawImageRect(image, SkRect::MakeWH(100, 100), nullptr);
|
||||
REPORTER_ASSERT(reporter, !image->unique());
|
||||
|
||||
Tally tally;
|
||||
tally.apply(record);
|
||||
|
||||
REPORTER_ASSERT(reporter, 1 == tally.count<SkRecords::DrawImageRect>());
|
||||
}
|
||||
REPORTER_ASSERT(reporter, image->unique());
|
||||
#endif
|
||||
|
||||
{
|
||||
SkRecord record;
|
||||
|
@ -402,70 +402,6 @@ void DebugCanvas::onDrawAnnotation(const SkRect& rect, const char key[], SkData*
|
||||
this->addDrawCommand(new DrawAnnotationCommand(rect, key, sk_ref_sp(value)));
|
||||
}
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_ONDRAWIMAGERECT
|
||||
void DebugCanvas::onDrawImage(const SkImage* image,
|
||||
SkScalar left,
|
||||
SkScalar top,
|
||||
const SkPaint* paint) {
|
||||
this->addDrawCommand(new DrawImageCommand(image, left, top, SkSamplingOptions(), paint));
|
||||
}
|
||||
|
||||
void DebugCanvas::onDrawImageLattice(const SkImage* image,
|
||||
const Lattice& lattice,
|
||||
const SkRect& dst,
|
||||
const SkPaint* paint) {
|
||||
this->addDrawCommand(new DrawImageLatticeCommand(image, lattice, dst, paint));
|
||||
}
|
||||
|
||||
void DebugCanvas::onDrawImageRect(const SkImage* image,
|
||||
const SkRect* src,
|
||||
const SkRect& dst,
|
||||
const SkPaint* paint,
|
||||
SrcRectConstraint constraint) {
|
||||
if (fnextDrawImageRectLayerId != -1 && fLayerManager) {
|
||||
// This drawImageRect command would have drawn the offscreen buffer for a layer.
|
||||
// On Android, we recorded an SkPicture of the commands that drew to the layer.
|
||||
// To render the layer as it would have looked on the frame this DebugCanvas draws, we need
|
||||
// to call fLayerManager->getLayerAsImage(id). This must be done just before
|
||||
// drawTo(command), since it depends on the index into the layer's commands
|
||||
// (managed by fLayerManager)
|
||||
// Instead of adding a DrawImageRectCommand, we need a deferred command, that when
|
||||
// executed, will call drawImageRect(fLayerManager->getLayerAsImage())
|
||||
this->addDrawCommand(new DrawImageRectLayerCommand(
|
||||
fLayerManager, fnextDrawImageRectLayerId, fFrame, src, dst, paint, constraint));
|
||||
} else {
|
||||
if (!src) {
|
||||
src = &dst; // wrong, but just needed until we can switch to new virtuals
|
||||
}
|
||||
this->addDrawCommand(new DrawImageRectCommand(image, *src, dst, SkSamplingOptions(),
|
||||
paint, constraint));
|
||||
}
|
||||
// Reset expectation so next drawImageRect is not special.
|
||||
fnextDrawImageRectLayerId = -1;
|
||||
}
|
||||
void DebugCanvas::onDrawAtlas(const SkImage* image,
|
||||
const SkRSXform xform[],
|
||||
const SkRect tex[],
|
||||
const SkColor colors[],
|
||||
int count,
|
||||
SkBlendMode bmode,
|
||||
const SkRect* cull,
|
||||
const SkPaint* paint) {
|
||||
this->addDrawCommand(
|
||||
new DrawAtlasCommand(image, xform, tex, colors, count, bmode, cull, paint));
|
||||
}
|
||||
void DebugCanvas::onDrawEdgeAAImageSet(const ImageSetEntry set[],
|
||||
int count,
|
||||
const SkPoint dstClips[],
|
||||
const SkMatrix preViewMatrices[],
|
||||
const SkPaint* paint,
|
||||
SrcRectConstraint constraint) {
|
||||
SkSamplingOptions sampling(paint ? paint->getFilterQuality() : kNone_SkFilterQuality);
|
||||
this->addDrawCommand(new DrawEdgeAAImageSetCommand(
|
||||
set, count, dstClips, preViewMatrices, sampling, paint, constraint));
|
||||
}
|
||||
#endif
|
||||
|
||||
void DebugCanvas::onDrawImage2(const SkImage* image,
|
||||
SkScalar left,
|
||||
SkScalar top,
|
||||
|
@ -169,21 +169,7 @@ protected:
|
||||
void onDrawVerticesObject(const SkVertices*, SkBlendMode, const SkPaint&) override;
|
||||
void onDrawPath(const SkPath&, const SkPaint&) override;
|
||||
void onDrawRegion(const SkRegion&, const SkPaint&) override;
|
||||
#ifdef SK_SUPPORT_LEGACY_ONDRAWIMAGERECT
|
||||
void onDrawImage(const SkImage*, SkScalar left, SkScalar top, const SkPaint*) override;
|
||||
void onDrawImageRect(const SkImage*, const SkRect* src, const SkRect& dst,
|
||||
const SkPaint*, SrcRectConstraint) override;
|
||||
void onDrawImageLattice(const SkImage*, const Lattice& lattice, const SkRect& dst,
|
||||
const SkPaint*) override;
|
||||
void onDrawAtlas(const SkImage*, const SkRSXform[], const SkRect[], const SkColor[],
|
||||
int, SkBlendMode, const SkRect*, const SkPaint*) override;
|
||||
void onDrawEdgeAAImageSet(const ImageSetEntry[],
|
||||
int count,
|
||||
const SkPoint[],
|
||||
const SkMatrix[],
|
||||
const SkPaint*,
|
||||
SrcRectConstraint) override;
|
||||
#endif
|
||||
|
||||
void onDrawImage2(const SkImage*, SkScalar, SkScalar, const SkSamplingOptions&,
|
||||
const SkPaint*) override;
|
||||
void onDrawImageRect2(const SkImage*, const SkRect&, const SkRect&, const SkSamplingOptions&,
|
||||
|
Loading…
Reference in New Issue
Block a user