Revert "Add new virts, hide old ones"

This reverts commit c56e2e5aa6.

Reason for revert: suspected of breaking chrome roll

Original change's description:
> Add new virts, hide old ones
>
> Add virtuals for the draw methods that now take sampling/filtermode.
>
> drawImage
> drawImageRect
> drawImageLattice
> drawAtlas
>
> Add a flag that can remove the older virtuals, once each client has
> stopped overriding them. In that situation, the older public methods
> will simplify extract the sampling from the paint, and call the new
> public methods.
>
> Bug: skia:11105, skia:7650
> Change-Id: I8b0029727295caa983e8148fc743a55cfbecd043
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/347022
> Commit-Queue: Mike Reed <reed@google.com>
> Reviewed-by: Florin Malita <fmalita@chromium.org>
> Reviewed-by: Brian Salomon <bsalomon@google.com>

TBR=bsalomon@google.com,fmalita@chromium.org,reed@google.com

Change-Id: I0a90952c11a180d918126ea06a630f4a0bf9b49b
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:11105
Bug: skia:7650
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/348194
Reviewed-by: Derek Sollenberger <djsollen@google.com>
Commit-Queue: Derek Sollenberger <djsollen@google.com>
This commit is contained in:
Derek Sollenberger 2020-12-30 13:41:39 +00:00 committed by Skia Commit-Bot
parent d3a91db48d
commit 8f924ac0ce
35 changed files with 180 additions and 887 deletions

View File

@ -196,8 +196,7 @@ DEF_SIMPLE_GM(drawimage_sampling, canvas, 500, 500) {
canvas->translate(dst.width() + 4, 0);
canvas->drawImageRect(img.get(), src, dst, sampling, nullptr,
SkCanvas::kFast_SrcRectConstraint);
canvas->drawImageRect(img.get(), src, dst, sampling);
canvas->restore();
canvas->translate(0, dst.height() + 8);

View File

@ -35,7 +35,6 @@
// Working on allow this to be undefined
#define SK_SUPPORT_LEGACY_GETTOTALMATRIX
//#define SK_SUPPORT_LEGACY_ONDRAWIMAGERECT
class GrBackendRenderTarget;
class GrRecordingContext;
@ -1646,7 +1645,7 @@ public:
void drawImage(const SkImage*, SkScalar x, SkScalar y, const SkSamplingOptions&,
const SkPaint* = nullptr);
void drawImageRect(const SkImage*, const SkRect& src, const SkRect& dst,
const SkSamplingOptions&, const SkPaint*, SrcRectConstraint);
const SkSamplingOptions&, const SkPaint* = nullptr);
/** Draws SkImage image stretched proportionally to fit into SkRect dst.
SkIRect center divides the image into nine sections: four sides, four corners, and
@ -2258,15 +2257,9 @@ public:
@param colors one per sprite, blended with sprite using SkBlendMode; may be nullptr
@param count number of sprites to draw
@param mode SkBlendMode combining colors and sprites
@param sampling SkSamplingOptions used when sampling from the atlas image
@param cullRect bounds of transformed sprites for efficient clipping; may be nullptr
@param paint SkColorFilter, SkImageFilter, SkBlendMode, and so on; may be nullptr
*/
void drawAtlas(const SkImage* atlas, const SkRSXform xform[], const SkRect tex[],
const SkColor colors[], int count, SkBlendMode mode,
const SkSamplingOptions& sampling, const SkRect* cullRect, const SkPaint* paint);
// DEPRECATED -- pass sampling
void drawAtlas(const SkImage* atlas, const SkRSXform xform[], const SkRect tex[],
const SkColor colors[], int count, SkBlendMode mode, const SkRect* cullRect,
const SkPaint* paint);
@ -2525,30 +2518,20 @@ protected:
virtual void onDrawPoints(PointMode mode, size_t count, const SkPoint pts[],
const SkPaint& paint);
#ifdef SK_SUPPORT_LEGACY_ONDRAWIMAGERECT
virtual void onDrawVerticesObject(const SkVertices* vertices, SkBlendMode mode,
const SkPaint& paint);
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);
// never called -- remove from clients' subclasses
virtual void onDrawImageNine(const SkImage*, const SkIRect&, const SkRect&, const SkPaint*) {}
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*) {}
#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,
const SkSamplingOptions&, const SkPaint*, SrcRectConstraint);
virtual void onDrawImageLattice2(const SkImage*, const Lattice&, const SkRect& dst,
SkFilterMode, const SkPaint*);
virtual void onDrawAtlas2(const SkImage*, const SkRSXform[], const SkRect src[],
const SkColor[], int count, SkBlendMode, const SkSamplingOptions&,
const SkRect* cull, const SkPaint*);
virtual void onDrawVerticesObject(const SkVertices* vertices, SkBlendMode mode,
const SkPaint& paint);
virtual void onDrawAnnotation(const SkRect& rect, const char key[], SkData* value);
virtual void onDrawShadowRec(const SkPath&, const SkDrawShadowRec&);

View File

@ -40,6 +40,16 @@ protected:
void onDrawPoints(SkCanvas::PointMode mode, size_t count, const SkPoint pts[],
const SkPaint& paint) override = 0;
// restore me later when clients are updated
// void onDrawVerticesObject(const SkVertices*, SkBlendMode, const SkPaint&) override = 0;
void onDrawImage(const SkImage* image, SkScalar dx, SkScalar dy,
const SkPaint* paint) override = 0;
void onDrawImageRect(const SkImage* image, const SkRect* src, const SkRect& dst,
const SkPaint* paint, SkCanvas::SrcRectConstraint constraint) override = 0;
void onDrawImageLattice(const SkImage* image, const SkCanvas::Lattice& lattice,
const SkRect& dst, const SkPaint* paint) override = 0;
#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
// This is under active development for Chrome and not used in Android. Hold off on adding
// implementations in Android's SkCanvas subclasses until this stabilizes.
@ -56,6 +66,10 @@ protected:
SkCanvas::SrcRectConstraint constraint) override = 0;
#endif
void onDrawAtlas(const SkImage* atlas, const SkRSXform xform[], const SkRect rect[],
const SkColor colors[], int count, SkBlendMode mode, const SkRect* cull,
const SkPaint* paint) override = 0;
void onDrawAnnotation(const SkRect& rect, const char key[], SkData* value) override = 0;
void onDrawShadowRec(const SkPath&, const SkDrawShadowRec&) override = 0;

View File

@ -34,25 +34,13 @@ public:
void onDrawRRect(const SkRRect&, const SkPaint&) override;
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;
#endif
void onDrawImage2(const SkImage*, SkScalar, SkScalar, const SkSamplingOptions&,
const SkPaint*) override;
void onDrawImageRect2(const SkImage*, const SkRect&, const SkRect&, const SkSamplingOptions&,
const SkPaint*, SrcRectConstraint) override;
void onDrawImageLattice2(const SkImage*, const Lattice&, const SkRect&, SkFilterMode,
const SkPaint*) override;
void onDrawAtlas2(const SkImage*, const SkRSXform[], const SkRect[], const SkColor[], int,
SkBlendMode, const SkSamplingOptions&, const SkRect*, const SkPaint*) override;
void onDrawPath(const SkPath&, const SkPaint&) override;
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 onDrawDrawable(SkDrawable*, const SkMatrix*) override;
void onDrawPicture(const SkPicture*, const SkMatrix*, const SkPaint*) override;

View File

@ -51,25 +51,13 @@ 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 onDrawImageLattice(const SkImage*, const Lattice&, const SkRect&, const SkPaint*) override;
void onDrawVerticesObject(const SkVertices*, SkBlendMode, const SkPaint&) override;
void onDrawAtlas(const SkImage*, const SkRSXform[], const SkRect[], const SkColor[],
int, SkBlendMode, const SkRect*, const SkPaint*) override;
#endif
void onDrawImage2(const SkImage*, SkScalar, SkScalar, const SkSamplingOptions&,
const SkPaint*) override;
void onDrawImageRect2(const SkImage*, const SkRect&, const SkRect&, const SkSamplingOptions&,
const SkPaint*, SrcRectConstraint) override;
void onDrawImageLattice2(const SkImage*, const Lattice&, const SkRect&, SkFilterMode,
const SkPaint*) override;
void onDrawAtlas2(const SkImage*, const SkRSXform[], const SkRect[], const SkColor[], int,
SkBlendMode, const SkSamplingOptions&, const SkRect*, const SkPaint*) override;
void onDrawVerticesObject(const SkVertices*, SkBlendMode, const SkPaint&) override;
void onDrawShadowRec(const SkPath&, const SkDrawShadowRec&) override;
void onClipRect(const SkRect&, SkClipOp, ClipEdgeStyle) override;

View File

@ -53,25 +53,14 @@ 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 onDrawVerticesObject(const SkVertices*, SkBlendMode, const SkPaint&) override {}
void onDrawAtlas(const SkImage*, const SkRSXform[], const SkRect[], const SkColor[],
int, SkBlendMode, const SkRect*, const SkPaint*) override {}
#endif
void onDrawImage2(const SkImage*, SkScalar, SkScalar, const SkSamplingOptions&,
const SkPaint*) override {}
void onDrawImageRect2(const SkImage*, const SkRect&, const SkRect&, const SkSamplingOptions&,
const SkPaint*, SrcRectConstraint) override {}
void onDrawImageLattice2(const SkImage*, const Lattice&, const SkRect&, SkFilterMode,
const SkPaint*) override {}
void onDrawAtlas2(const SkImage*, const SkRSXform[], const SkRect[], const SkColor[], int,
SkBlendMode, const SkSamplingOptions&, const SkRect*, const SkPaint*) override {}
void onDrawVerticesObject(const SkVertices*, SkBlendMode, const SkPaint&) override {}
void onDrawShadowRec(const SkPath&, const SkDrawShadowRec&) override {}
void onDrawPicture(const SkPicture*, const SkMatrix*, const SkPaint*) override {}

View File

@ -57,24 +57,11 @@ 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,
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;
#endif
void onDrawImage2(const SkImage*, SkScalar, SkScalar, const SkSamplingOptions&,
const SkPaint*) override;
void onDrawImageRect2(const SkImage*, const SkRect&, const SkRect&, const SkSamplingOptions&,
const SkPaint*, SrcRectConstraint) override;
void onDrawImageLattice2(const SkImage*, const Lattice&, const SkRect&, SkFilterMode,
const SkPaint*) override;
void onDrawAtlas2(const SkImage*, const SkRSXform[], const SkRect[], const SkColor[], int,
SkBlendMode, const SkSamplingOptions&, const SkRect*, const SkPaint*) override;
void onDrawVerticesObject(const SkVertices*, SkBlendMode, const SkPaint&) override;
void onDrawPatch(const SkPoint cubics[12], const SkColor colors[4],
const SkPoint texCoords[4], SkBlendMode,
@ -84,6 +71,8 @@ protected:
void onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y,
const SkPaint& paint) override;
void onDrawAtlas(const SkImage*, const SkRSXform[], const SkRect[], const SkColor[],
int, SkBlendMode, const SkRect*, const SkPaint*) override;
void onDrawAnnotation(const SkRect& rect, const char key[], SkData* value) override;
void onDrawShadowRec(const SkPath& path, const SkDrawShadowRec& rec) override;

View File

@ -932,8 +932,7 @@ EMSCRIPTEN_BINDINGS(Skia) {
const SkPaint* paint)->void {
const SkRect* src = reinterpret_cast<const SkRect*>(srcPtr);
const SkRect* dst = reinterpret_cast<const SkRect*>(dstPtr);
auto constraint = SkCanvas::kStrict_SrcRectConstraint; // TODO: get from caller
self.drawImageRect(image.get(), *src, *dst, SkSamplingOptions({B, C}), paint, constraint);
self.drawImageRect(image.get(), *src, *dst, SkSamplingOptions({B, C}), paint);
}), allow_raw_pointers())
.function("_drawImageRectOptions", optional_override([](SkCanvas& self, const sk_sp<SkImage>& image,
uintptr_t /* float* */ srcPtr, uintptr_t /* float* */ dstPtr,
@ -941,8 +940,7 @@ EMSCRIPTEN_BINDINGS(Skia) {
const SkPaint* paint)->void {
const SkRect* src = reinterpret_cast<const SkRect*>(srcPtr);
const SkRect* dst = reinterpret_cast<const SkRect*>(dstPtr);
auto constraint = SkCanvas::kStrict_SrcRectConstraint; // TODO: get from caller
self.drawImageRect(image.get(), *src, *dst, {filter, mipmap}, paint, constraint);
self.drawImageRect(image.get(), *src, *dst, {filter, mipmap}, paint);
}), allow_raw_pointers())
.function("drawLine", select_overload<void (SkScalar, SkScalar, SkScalar, SkScalar, const SkPaint&)>(&SkCanvas::drawLine))
.function("_drawOval", optional_override([](SkCanvas& self, uintptr_t /* float* */ fPtr,

View File

@ -73,8 +73,7 @@ class AnimatedTextView : public Sample {
sk_sp<SkImage> image = direct->priv().testingOnly_getFontAtlasImage(
GrMaskFormat::kA8_GrMaskFormat);
const SkRect rect = SkRect::MakeXYWH(512.0f, 10.0f, 512.0f, 512.0f);
canvas->drawImageRect(image.get(), rect, rect, sampling, &paint,
SkCanvas::kFast_SrcRectConstraint);
canvas->drawImageRect(image.get(), rect, rect, sampling, &paint);
}
#endif
canvas->translate(180, 180);

View File

@ -184,7 +184,7 @@ public:
canvas->saveLayer(&localContentRect, &blurPaint);
canvas->drawImageRect(fImage.get(), localContentRect, localContentRect,
SkSamplingOptions(SkFilterMode::kLinear, SkMipmapMode::kNone),
nullptr, SkCanvas::kFast_SrcRectConstraint);
nullptr);
canvas->restore();
// Now visualize the underlying bounds calculations used to determine the layer for the blur

View File

@ -226,8 +226,7 @@ public:
SkRect::MakeWH(kTileWidth, kTileHeight),
SkSamplingOptions(scale > 1.f ? kNone_SkFilterQuality
: kMedium_SkFilterQuality),
&blit,
SkCanvas::kFast_SrcRectConstraint);
&blit);
}
private:

View File

@ -67,12 +67,6 @@
// and std::max() is constexpr only since the c++14 stdlib.
static_assert(std::max(3,4) == 4);
static SkSamplingOptions paint_to_sampling(const SkPaint* paint, const GrRecordingContext* ctx) {
SkSamplingOptions::MediumBehavior mb = ctx ? SkSamplingOptions::kMedium_asMipmapLinear
: SkSamplingOptions::kMedium_asMipmapNearest;
return SkSamplingOptions(paint ? paint->getFilterQuality() : kNone_SkFilterQuality, mb);
}
///////////////////////////////////////////////////////////////////////////////////////////////////
/*
@ -1840,13 +1834,9 @@ 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
@ -1858,17 +1848,12 @@ 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,
@ -1924,32 +1909,15 @@ void SkCanvas::drawImageNine(const SkImage* image, const SkIRect& center, const
void SkCanvas::drawImageLattice(const SkImage* image, const Lattice& lattice, const SkRect& dst,
SkFilterMode filter, const SkPaint* paint) {
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->onDrawImageLattice2(image, latticePlusBounds, dst, filter, &latticePaint);
} else {
this->drawImageRect(image, SkRect::MakeIWH(image->width(), image->height()), dst,
SkSamplingOptions(filter, SkMipmapMode::kNone), paint,
kStrict_SrcRectConstraint);
}
SkPaint latticePaint = clean_paint_for_lattice(paint);
// use filterquality until we can update our virtuals to take SkFilterMode
latticePaint.setFilterQuality(filter == SkFilterMode::kNearest ? kNone_SkFilterQuality
: kLow_SkFilterQuality);
this->drawImageLattice(image, lattice, dst, &latticePaint);
}
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()) {
@ -1969,11 +1937,6 @@ void SkCanvas::drawImageLattice(const SkImage* image, const Lattice& lattice, co
} else {
this->drawImageRect(image, dst, paint);
}
#else
this->drawImageLattice(image, lattice, dst,
paint_to_sampling(paint, this->recordingContext()).filter,
paint);
#endif
}
static sk_sp<SkImage> bitmap_as_image(const SkBitmap& bitmap) {
@ -2003,24 +1966,9 @@ void SkCanvas::drawBitmapRect(const SkBitmap& bitmap, const SkRect& dst, const S
constraint);
}
void SkCanvas::drawAtlas(const SkImage* atlas, const SkRSXform xform[], const SkRect tex[],
const SkColor colors[], int count, SkBlendMode mode,
const SkSamplingOptions& sampling, const SkRect* cull,
const SkPaint* paint) {
TRACE_EVENT0("skia", TRACE_FUNC);
RETURN_ON_NULL(atlas);
if (count <= 0) {
return;
}
SkASSERT(atlas);
SkASSERT(tex);
this->onDrawAtlas2(atlas, xform, tex, colors, count, mode, sampling, cull, paint);
}
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) {
@ -2029,10 +1977,6 @@ void SkCanvas::drawAtlas(const SkImage* atlas, const SkRSXform xform[], const Sk
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) {
@ -2307,25 +2251,22 @@ static SkPaint clean_paint_for_drawImage(const SkPaint* paint) {
return cleaned;
}
// drawVertices fills triangles and ignores mask filter and path effect,
// so canonicalize the paint before checking quick reject.
static SkPaint clean_paint_for_drawVertices(SkPaint paint) {
paint.setStyle(SkPaint::kFill_Style);
paint.setMaskFilter(nullptr);
paint.setPathEffect(nullptr);
return paint;
static SkSamplingOptions paint_to_sampling(const SkPaint* paint, GrRecordingContext* ctx) {
SkSamplingOptions::MediumBehavior mb = ctx ? SkSamplingOptions::kMedium_asMipmapLinear
: SkSamplingOptions::kMedium_asMipmapNearest;
return SkSamplingOptions(paint ? paint->getFilterQuality() : kNone_SkFilterQuality, mb);
}
#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;
}
const SkSamplingOptions sampling = paint_to_sampling(&realPaint, this->recordingContext());
if (realPaint.getImageFilter() &&
this->canDrawBitmapAsSprite(x, y, image->width(), image->height(), sampling, realPaint) &&
!image_to_color_filter(&realPaint)) {
@ -2354,14 +2295,14 @@ void SkCanvas::onDrawImage(const SkImage* image, SkScalar x, SkScalar y, const S
}
AutoLayerForImageFilter layer(this, realPaint, &bounds);
this->topDevice()->drawImageRect(image, nullptr, bounds, sampling,
this->topDevice()->drawImageRect(image, nullptr, bounds,
paint_to_sampling(&layer.paint(), this->recordingContext()),
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;
@ -2370,121 +2311,51 @@ void SkCanvas::onDrawImageRect(const SkImage* image, const SkRect* src, const Sk
AutoLayerForImageFilter layer(this, realPaint, &dst, CheckForOverwrite::kYes,
image->isOpaque() ? kOpaque_ShaderOverrideOpacity
: kNotOpaque_ShaderOverrideOpacity);
this->topDevice()->drawImageRect(image, src, dst, sampling, layer.paint(), constraint);
this->topDevice()->drawImageRect(image, src, dst, paint_to_sampling(&layer.paint(),
this->recordingContext()),
layer.paint(), constraint);
}
void SkCanvas::drawImage(const SkImage* image, SkScalar x, SkScalar y,
const SkSamplingOptions& sampling, const SkPaint* paint) {
RETURN_ON_NULL(image);
// If we need more per-device control, add new virtual
auto mx = SkMatrix::Translate(x, y);
SkPaint p = paint ? *paint : SkPaint();
p.setShader(image->makeShader(SkTileMode::kClamp, SkTileMode::kClamp, sampling, &mx));
this->drawRect(SkRect::MakeXYWH(x, y, image->width(), image->height()), p);
}
void SkCanvas::drawImageRect(const SkImage* image, const SkRect& src, const SkRect& dst,
const SkSamplingOptions& sampling, const SkPaint* paint) {
RETURN_ON_NULL(image);
if (dst.isEmpty()) {
return;
}
// If we need more per-device control, add new virtual
SkMatrix mx = SkMatrix::MakeRectToRect(src, dst, SkMatrix::kFill_ScaleToFit);
if (mx.isFinite()) {
SkPaint p = paint ? *paint : SkPaint();
p.setShader(image->makeShader(SkTileMode::kDecal, SkTileMode::kDecal, sampling, &mx));
this->drawRect(dst, p);
}
}
void SkCanvas::onDrawImageLattice(const SkImage* image, const Lattice& lattice, const SkRect& dst,
const SkPaint* paint) {
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);
this->topDevice()->drawImageLattice(image, lattice, dst, sampling.filter, 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());
}
#endif
void SkCanvas::onDrawImage2(const SkImage* image, SkScalar x, SkScalar y,
const SkSamplingOptions& sampling, const SkPaint* paint) {
SkPaint realPaint = clean_paint_for_drawImage(paint);
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(), 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::onDrawImageRect2(const SkImage* image, const SkRect& src, const SkRect& dst,
const SkSamplingOptions& sampling, const SkPaint* paint,
SrcRectConstraint constraint) {
SkPaint realPaint = clean_paint_for_drawImage(paint);
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::onDrawImageLattice2(const SkImage* image, const Lattice& lattice, const SkRect& dst,
SkFilterMode filter, 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, filter, layer.paint());
}
void SkCanvas::drawImage(const SkImage* image, SkScalar x, SkScalar y,
const SkSamplingOptions& sampling, const SkPaint* paint) {
TRACE_EVENT0("skia", TRACE_FUNC);
RETURN_ON_NULL(image);
this->onDrawImage2(image, x, y, sampling, paint);
}
void SkCanvas::drawImageRect(const SkImage* image, const SkRect& src, const SkRect& dst,
const SkSamplingOptions& sampling, const SkPaint* paint,
SrcRectConstraint constraint) {
RETURN_ON_NULL(image);
if (!fillable(dst) || !fillable(src)) {
return;
}
this->onDrawImageRect2(image, src, dst, sampling, paint, constraint);
this->topDevice()->drawImageLattice(image, lattice, dst,
paint_to_sampling(&layer.paint(),
this->recordingContext()).filter,
layer.paint());
}
void SkCanvas::onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y,
@ -2529,6 +2400,15 @@ void SkCanvas::drawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y,
this->onDrawTextBlob(blob, x, y, paint);
}
// drawVertices fills triangles and ignores mask filter and path effect,
// so canonicalize the paint before checking quick reject.
static SkPaint clean_paint_for_drawVertices(SkPaint paint) {
paint.setStyle(SkPaint::kFill_Style);
paint.setMaskFilter(nullptr);
paint.setPathEffect(nullptr);
return paint;
}
void SkCanvas::onDrawVerticesObject(const SkVertices* vertices, SkBlendMode bmode,
const SkPaint& paint) {
SkPaint simplePaint = clean_paint_for_drawVertices(paint);
@ -2602,12 +2482,12 @@ void SkCanvas::onDrawDrawable(SkDrawable* dr, const SkMatrix* matrix) {
this->baseDevice()->drawDrawable(dr, matrix, this);
}
void SkCanvas::onDrawAtlas2(const SkImage* atlas, const SkRSXform xform[], const SkRect tex[],
const SkColor colors[], int count, SkBlendMode bmode,
const SkSamplingOptions& sampling, const SkRect* cull,
const SkPaint* 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(paint, this->recordingContext()));
if (cull && this->internalQuickReject(*cull, realPaint)) {
return;

View File

@ -136,55 +136,6 @@ void SkOverdrawCanvas::onDrawVerticesObject(const SkVertices* vertices,
fList[0]->onDrawVerticesObject(vertices, blendMode, this->overdrawPaint(paint));
}
void SkOverdrawCanvas::onDrawAtlas2(const SkImage* image, const SkRSXform xform[],
const SkRect texs[], const SkColor colors[], int count,
SkBlendMode mode, const SkSamplingOptions& sampling,
const SkRect* cull, const SkPaint* paint) {
SkPaint* paintPtr = &fPaint;
SkPaint storage;
if (paint) {
storage = this->overdrawPaint(*paint);
paintPtr = &storage;
}
fList[0]->onDrawAtlas2(image, xform, texs, colors, count, mode, sampling, cull, paintPtr);
}
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) {
@ -197,20 +148,22 @@ void SkOverdrawCanvas::onDrawAtlas(const SkImage* image, const SkRSXform xform[]
fList[0]->onDrawAtlas(image, xform, texs, colors, count, mode, cull, paintPtr);
}
#endif
void SkOverdrawCanvas::onDrawImage2(const SkImage* image, SkScalar x, SkScalar y,
const SkSamplingOptions&, const SkPaint*) {
void SkOverdrawCanvas::onDrawPath(const SkPath& path, const SkPaint& paint) {
fList[0]->onDrawPath(path, fPaint);
}
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::onDrawImageRect2(const SkImage* image, const SkRect& src, const SkRect& dst,
const SkSamplingOptions&, const SkPaint*, SrcRectConstraint) {
void SkOverdrawCanvas::onDrawImageRect(const SkImage* image, const SkRect* src, const SkRect& dst,
const SkPaint*, SrcRectConstraint) {
fList[0]->onDrawRect(dst, fPaint);
}
void SkOverdrawCanvas::onDrawImageLattice2(const SkImage* image, const Lattice& lattice,
const SkRect& dst, SkFilterMode, const SkPaint*) {
void SkOverdrawCanvas::onDrawImageLattice(const SkImage* image, const Lattice& lattice,
const SkRect& dst, const SkPaint*) {
SkIRect bounds;
Lattice latticePlusBounds = lattice;
if (!latticePlusBounds.fBounds) {

View File

@ -109,11 +109,7 @@ enum DrawType {
MARK_CTM,
SET_M44,
DRAW_IMAGE2,
DRAW_IMAGE_RECT2,
DRAW_IMAGE_LATTICE2,
LAST_DRAWTYPE_ENUM = DRAW_IMAGE_LATTICE2,
LAST_DRAWTYPE_ENUM = SET_M44,
};
enum DrawVertexFlags {
@ -124,9 +120,8 @@ enum DrawVertexFlags {
};
enum DrawAtlasFlags {
DRAW_ATLAS_HAS_COLORS = 1 << 0,
DRAW_ATLAS_HAS_CULL = 1 << 1,
DRAW_ATLAS_HAS_SAMPLING = 1 << 2,
DRAW_ATLAS_HAS_COLORS = 1 << 0,
DRAW_ATLAS_HAS_CULL = 1 << 1,
};
enum DrawTextRSXformFlags {

View File

@ -83,11 +83,7 @@ void SkPicturePlayback::handleOp(SkReadBuffer* reader,
uint32_t size,
SkCanvas* canvas,
const SkM44& initialMatrix) {
#define BREAK_ON_READ_ERROR(r) \
do { if (!r->isValid()) { \
/* SkASSERT(false); */ \
break; \
}} while(0)
#define BREAK_ON_READ_ERROR(r) if (!r->isValid()) break
switch (op) {
case NOOP: {
@ -219,13 +215,7 @@ void SkPicturePlayback::handleOp(SkReadBuffer* reader,
}
BREAK_ON_READ_ERROR(reader);
if (flags & DRAW_ATLAS_HAS_SAMPLING) {
auto sampling = reader->readSampling();
BREAK_ON_READ_ERROR(reader);
canvas->drawAtlas(atlas, xform, tex, colors, count, mode, sampling, cull, paint);
} else {
canvas->drawAtlas(atlas, xform, tex, colors, count, mode, cull, paint);
}
canvas->drawAtlas(atlas, xform, tex, colors, count, mode, cull, paint);
} break;
case DRAW_CLEAR: {
auto c = reader->readInt();
@ -354,16 +344,6 @@ void SkPicturePlayback::handleOp(SkReadBuffer* reader,
canvas->drawImage(image, loc.fX, loc.fY, paint);
} break;
case DRAW_IMAGE2: {
const SkPaint* paint = fPictureData->optionalPaint(reader);
const SkImage* image = fPictureData->getImage(reader);
SkPoint loc;
reader->readPoint(&loc);
SkSamplingOptions sampling = reader->readSampling();
BREAK_ON_READ_ERROR(reader);
canvas->drawImage(image, loc.fX, loc.fY, sampling, paint);
} break;
case DRAW_IMAGE_LATTICE: {
const SkPaint* paint = fPictureData->optionalPaint(reader);
const SkImage* image = fPictureData->getImage(reader);
@ -374,17 +354,6 @@ void SkPicturePlayback::handleOp(SkReadBuffer* reader,
canvas->drawImageLattice(image, lattice, *dst, paint);
} break;
case DRAW_IMAGE_LATTICE2: {
const SkPaint* paint = fPictureData->optionalPaint(reader);
const SkImage* image = fPictureData->getImage(reader);
SkCanvas::Lattice lattice;
(void)SkCanvasPriv::ReadLattice(*reader, &lattice);
const SkRect* dst = reader->skipT<SkRect>();
SkFilterMode filter = reader->read32LE(SkFilterMode::kLinear);
BREAK_ON_READ_ERROR(reader);
canvas->drawImageLattice(image, lattice, *dst, filter, paint);
} break;
case DRAW_IMAGE_NINE: {
const SkPaint* paint = fPictureData->optionalPaint(reader);
const SkImage* image = fPictureData->getImage(reader);
@ -414,17 +383,6 @@ void SkPicturePlayback::handleOp(SkReadBuffer* reader,
canvas->legacy_drawImageRect(image, src, dst, paint, constraint);
} break;
case DRAW_IMAGE_RECT2: {
const SkPaint* paint = fPictureData->optionalPaint(reader);
const SkImage* image = fPictureData->getImage(reader);
SkRect src = reader->readRect();
SkRect dst = reader->readRect();
SkSamplingOptions sampling = reader->readSampling();
auto constraint = reader->read32LE(SkCanvas::kFast_SrcRectConstraint);
BREAK_ON_READ_ERROR(reader);
canvas->drawImageRect(image, src, dst, sampling, paint, constraint);
} break;
case DRAW_OVAL: {
const SkPaint& paint = fPictureData->requiredPaint(reader);
SkRect rect;

View File

@ -80,8 +80,6 @@ public:
// V77: Explicit filtering options on imageshaders
// V78: Serialize skmipmap data for images that have it
// V79: Cubic Resampler option on imageshader
// V80: Smapling options on imageshader
// V81: sampling parameters on drawImage/drawImageRect/etc.
enum Version {
kEdgeAAQuadColor4f_Version = 73,
@ -92,11 +90,10 @@ public:
kSerializeMipmaps_Version = 78,
kCubicResamplerImageShader_Version = 79,
kSamplingInImageShader_Version = 80,
kSamplingInDrawImage_Version = 81,
// Only SKPs within the min/current picture version range (inclusive) can be read.
kMin_Version = kEdgeAAQuadColor4f_Version,
kCurrent_Version = kSamplingInDrawImage_Version
kCurrent_Version = kSamplingInImageShader_Version
};
static_assert(SkPicturePriv::kMin_Version <= SkPicturePriv::kCubicResamplerImageShader_Version,

View File

@ -15,7 +15,6 @@
#include "src/core/SkClipOpPriv.h"
#include "src/core/SkDrawShadowInfo.h"
#include "src/core/SkMatrixPriv.h"
#include "src/core/SkSamplingPriv.h"
#include "src/core/SkTSearch.h"
#include "src/image/SkImage_Base.h"
#include "src/utils/SkPatchUtils.h"
@ -535,7 +534,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
@ -579,87 +577,6 @@ void SkPictureRecord::onDrawImageLattice(const SkImage* image, const Lattice& la
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);
}
#endif
void SkPictureRecord::onDrawImage2(const SkImage* image, SkScalar x, SkScalar y,
const SkSamplingOptions& sampling, const SkPaint* paint) {
// op + paint_index + image_index + x + y
size_t size = 3 * kUInt32Size + 2 * sizeof(SkScalar) + SkSamplingPriv::kFlatSize;
size_t initialOffset = this->addDraw(DRAW_IMAGE2, &size);
this->addPaintPtr(paint);
this->addImage(image);
this->addScalar(x);
this->addScalar(y);
this->addSampling(sampling);
this->validate(initialOffset, size);
}
void SkPictureRecord::onDrawImageRect2(const SkImage* image, const SkRect& src, const SkRect& dst,
const SkSamplingOptions& sampling, const SkPaint* paint,
SrcRectConstraint constraint) {
// id + paint_index + image_index + constraint
size_t size = 3 * kUInt32Size + 2 * sizeof(dst) + SkSamplingPriv::kFlatSize + kUInt32Size;
size_t initialOffset = this->addDraw(DRAW_IMAGE_RECT2, &size);
this->addPaintPtr(paint);
this->addImage(image);
this->addRect(src);
this->addRect(dst);
this->addSampling(sampling);
this->addInt(constraint);
this->validate(initialOffset, size);
}
void SkPictureRecord::onDrawImageLattice2(const SkImage* image, const Lattice& lattice,
const SkRect& dst, SkFilterMode filter,
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) + sizeof(uint32_t); // filter
size_t initialOffset = this->addDraw(DRAW_IMAGE_LATTICE2, &size);
this->addPaintPtr(paint);
this->addImage(image);
(void)SkCanvasPriv::WriteLattice(fWriter.reservePad(latticeSize), lattice);
this->addRect(dst);
this->addInt(static_cast<uint32_t>(filter));
this->validate(initialOffset, size);
}
void SkPictureRecord::onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y,
const SkPaint& paint) {
@ -763,13 +680,11 @@ void SkPictureRecord::onDrawPatch(const SkPoint cubics[12], const SkColor colors
this->validate(initialOffset, size);
}
void SkPictureRecord::onDrawAtlas2(const SkImage* atlas, const SkRSXform xform[], const SkRect tex[],
const SkColor colors[], int count, SkBlendMode mode,
const SkSamplingOptions& sampling, const SkRect* cull,
const SkPaint* paint) {
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);
size += SkSamplingPriv::kFlatSize;
uint32_t flags = 0;
if (colors) {
flags |= DRAW_ATLAS_HAS_COLORS;
@ -780,7 +695,6 @@ void SkPictureRecord::onDrawAtlas2(const SkImage* atlas, const SkRSXform xform[]
flags |= DRAW_ATLAS_HAS_CULL;
size += sizeof(SkRect);
}
flags |= DRAW_ATLAS_HAS_SAMPLING;
size_t initialOffset = this->addDraw(DRAW_ATLAS, &size);
this->addPaintPtr(paint);
@ -798,7 +712,6 @@ void SkPictureRecord::onDrawAtlas2(const SkImage* atlas, const SkRSXform xform[]
if (cull) {
fWriter.write(cull, sizeof(SkRect));
}
this->addSampling(sampling);
this->validate(initialOffset, size);
}
@ -1002,17 +915,6 @@ void SkPictureRecord::addRegion(const SkRegion& region) {
fWriter.writeRegion(region);
}
void SkPictureRecord::addSampling(const SkSamplingOptions& sampling) {
fWriter.writeBool(sampling.useCubic);
if (sampling.useCubic) {
fWriter.writeScalar(sampling.cubic.B);
fWriter.writeScalar(sampling.cubic.C);
} else {
fWriter.writeInt(static_cast<uint32_t>(sampling.filter));
fWriter.writeInt(static_cast<uint32_t>(sampling.mipmap));
}
}
void SkPictureRecord::addText(const void* text, size_t byteLength) {
addInt(SkToInt(byteLength));
fWriter.writePad(text, byteLength);

View File

@ -141,7 +141,6 @@ private:
void addIRectPtr(const SkIRect* rect);
void addRRect(const SkRRect&);
void addRegion(const SkRegion& region);
void addSampling(const SkSamplingOptions&);
void addText(const void* text, size_t byteLength);
void addTextBlob(const SkTextBlob* blob);
void addVertices(const SkVertices*);
@ -176,6 +175,8 @@ protected:
void onDrawPatch(const SkPoint cubics[12], const SkColor colors[4],
const SkPoint texCoords[4], SkBlendMode, const SkPaint& paint) override;
void onDrawAtlas(const SkImage*, const SkRSXform[], const SkRect[], const SkColor[], int,
SkBlendMode, const SkRect*, const SkPaint*) override;
void onDrawPaint(const SkPaint&) override;
void onDrawBehind(const SkPaint&) override;
@ -186,23 +187,11 @@ 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,
void onDrawImageLattice(const SkImage*, const SkCanvas::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;
#endif
void onDrawImage2(const SkImage*, SkScalar, SkScalar, const SkSamplingOptions&,
const SkPaint*) override;
void onDrawImageRect2(const SkImage*, const SkRect&, const SkRect&, const SkSamplingOptions&,
const SkPaint*, SrcRectConstraint) override;
void onDrawImageLattice2(const SkImage*, const Lattice&, const SkRect&, SkFilterMode,
const SkPaint*) override;
void onDrawAtlas2(const SkImage*, const SkRSXform[], const SkRect[], const SkColor[], int,
SkBlendMode, const SkSamplingOptions&, const SkRect*, const SkPaint*) override;
void onDrawShadowRec(const SkPath&, const SkDrawShadowRec&) override;
void onDrawVerticesObject(const SkVertices*, SkBlendMode, const SkPaint&) override;

View File

@ -201,26 +201,6 @@ void SkReadBuffer::readRect(SkRect* rect) {
}
}
SkRect SkReadBuffer::readRect() {
SkRect r;
if (!this->readPad32(&r, sizeof(SkRect))) {
r.setEmpty();
}
return r;
}
SkSamplingOptions SkReadBuffer::readSampling() {
if (this->readBool()) {
float B = this->readScalar();
float C = this->readScalar();
return SkSamplingOptions({B, C});
} else {
SkFilterMode filter = this->read32LE(SkFilterMode::kLinear);
SkMipmapMode mipmap = this->read32LE(SkMipmapMode::kLinear);
return SkSamplingOptions(filter, mipmap);
}
}
void SkReadBuffer::readRRect(SkRRect* rrect) {
size_t size = 0;
if (!fError) {

View File

@ -96,7 +96,6 @@ public:
void readMatrix(SkMatrix* matrix);
void readIRect(SkIRect* rect);
void readRect(SkRect* rect);
SkRect readRect();
void readRRect(SkRRect* rrect);
void readRegion(SkRegion* region);
@ -197,8 +196,6 @@ public:
SkFilterQuality checkFilterQuality();
SkSamplingOptions readSampling();
private:
const char* readString(size_t* length);

View File

@ -108,7 +108,6 @@ DRAW(ClipShader, clipShader(r.shader, r.op));
DRAW(DrawArc, drawArc(r.oval, r.startAngle, r.sweepAngle, r.useCenter, r.paint));
DRAW(DrawDRRect, drawDRRect(r.outer, r.inner, r.paint));
DRAW(DrawImage, drawImage(r.image.get(), r.left, r.top, r.paint));
DRAW(DrawImage2, drawImage(r.image.get(), r.left, r.top, r.sampling, r.paint));
template <> void Draw::draw(const DrawImageLattice& r) {
SkCanvas::Lattice lattice;
@ -122,20 +121,7 @@ template <> void Draw::draw(const DrawImageLattice& r) {
fCanvas->drawImageLattice(r.image.get(), lattice, r.dst, r.paint);
}
template <> void Draw::draw(const DrawImageLattice2& r) {
SkCanvas::Lattice lattice;
lattice.fXCount = r.xCount;
lattice.fXDivs = r.xDivs;
lattice.fYCount = r.yCount;
lattice.fYDivs = r.yDivs;
lattice.fRectTypes = (0 == r.flagCount) ? nullptr : r.flags;
lattice.fColors = (0 == r.flagCount) ? nullptr : r.colors;
lattice.fBounds = &r.src;
fCanvas->drawImageLattice(r.image.get(), lattice, r.dst, r.filter, r.paint);
}
DRAW(DrawImageRect, legacy_drawImageRect(r.image.get(), r.src, r.dst, r.paint, r.constraint));
DRAW(DrawImageRect2, drawImageRect(r.image.get(), r.src, r.dst, r.sampling, r.paint, r.constraint));
DRAW(DrawOval, drawOval(r.oval, r.paint));
DRAW(DrawPaint, drawPaint(r.paint));
DRAW(DrawPath, drawPath(r.path, r.paint));
@ -148,8 +134,6 @@ DRAW(DrawRegion, drawRegion(r.region, r.paint));
DRAW(DrawTextBlob, drawTextBlob(r.blob.get(), r.x, r.y, r.paint));
DRAW(DrawAtlas, drawAtlas(r.atlas.get(),
r.xforms, r.texs, r.colors, r.count, r.mode, r.cull, r.paint));
DRAW(DrawAtlas2, drawAtlas(r.atlas.get(), r.xforms, r.texs, r.colors, r.count, r.mode, r.sampling,
r.cull, r.paint));
DRAW(DrawVertices, drawVertices(r.vertices, r.bmode, r.paint));
DRAW(DrawShadowRec, private_draw_shadow_rec(r.path, r.rec));
DRAW(DrawAnnotation, drawAnnotation(r.rect, r.key.c_str(), r.value.get()));
@ -415,24 +399,12 @@ private:
return this->adjustAndMap(rect, op.paint);
}
Bounds bounds(const DrawImage2& op) const {
const SkImage* image = op.image.get();
SkRect rect = SkRect::MakeXYWH(op.left, op.top, image->width(), image->height());
return this->adjustAndMap(rect, op.paint);
}
Bounds bounds(const DrawImageLattice& op) const {
return this->adjustAndMap(op.dst, op.paint);
}
Bounds bounds(const DrawImageLattice2& op) const {
return this->adjustAndMap(op.dst, op.paint);
}
Bounds bounds(const DrawImageRect& op) const {
return this->adjustAndMap(op.dst, op.paint);
}
Bounds bounds(const DrawImageRect2& op) const {
return this->adjustAndMap(op.dst, op.paint);
}
Bounds bounds(const DrawPath& op) const {
return op.path.isInverseFillType() ? fCullRect
: this->adjustAndMap(op.path.getBounds(), &op.paint);
@ -466,16 +438,6 @@ private:
}
}
Bounds bounds(const DrawAtlas2& op) const {
if (op.cull) {
// TODO: <reed> can we pass nullptr for the paint? Isn't cull already "correct"
// for the paint (by the caller)?
return this->adjustAndMap(*op.cull, op.paint);
} else {
return fCullRect;
}
}
Bounds bounds(const DrawShadowRec& op) const {
SkRect bounds;
SkDrawShadowMetrics::GetLocalBounds(op.path, op.rec, fCTM, &bounds);

View File

@ -204,7 +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);
@ -225,42 +224,6 @@ void SkRecorder::onDrawImageLattice(const SkImage* image, const Lattice& lattice
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));
}
#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);
}
void SkRecorder::onDrawImageRect2(const SkImage* image, const SkRect& src, const SkRect& dst,
const SkSamplingOptions& sampling, const SkPaint* paint,
SrcRectConstraint constraint) {
this->append<SkRecords::DrawImageRect2>(this->copy(paint), sk_ref_sp(image), src, dst,
sampling, constraint);
}
void SkRecorder::onDrawImageLattice2(const SkImage* image, const Lattice& lattice, const SkRect& dst,
SkFilterMode filter, 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::onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y,
const SkPaint& paint) {
@ -290,18 +253,16 @@ void SkRecorder::onDrawPatch(const SkPoint cubics[12], const SkColor colors[4],
bmode);
}
void SkRecorder::onDrawAtlas2(const SkImage* atlas, const SkRSXform xform[], const SkRect tex[],
const SkColor colors[], int count, SkBlendMode mode,
const SkSamplingOptions& sampling, const SkRect* cull,
const SkPaint* paint) {
this->append<SkRecords::DrawAtlas2>(this->copy(paint),
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,
sampling,
this->copy(cull));
}

View File

@ -86,25 +86,14 @@ 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;
#endif
void onDrawImage2(const SkImage*, SkScalar, SkScalar, const SkSamplingOptions&,
const SkPaint*) override;
void onDrawImageRect2(const SkImage*, const SkRect&, const SkRect&, const SkSamplingOptions&,
const SkPaint*, SrcRectConstraint) override;
void onDrawImageLattice2(const SkImage*, const Lattice&, const SkRect&, SkFilterMode,
const SkPaint*) override;
void onDrawAtlas2(const SkImage*, const SkRSXform[], const SkRect[], const SkColor[], int,
SkBlendMode, const SkSamplingOptions&, const SkRect*, const SkPaint*) override;
void onDrawVerticesObject(const SkVertices*, SkBlendMode, const SkPaint&) override;
void onDrawAtlas(const SkImage*, const SkRSXform[], const SkRect[], const SkColor[],
int count, SkBlendMode, const SkRect* cull, const SkPaint*) override;
void onDrawShadowRec(const SkPath&, const SkDrawShadowRec&) override;
void onClipRect(const SkRect& rect, SkClipOp, ClipEdgeStyle) override;

View File

@ -62,9 +62,6 @@ namespace SkRecords {
M(DrawImage) \
M(DrawImageLattice) \
M(DrawImageRect) \
M(DrawImage2) \
M(DrawImageLattice2) \
M(DrawImageRect2) \
M(DrawDRRect) \
M(DrawOval) \
M(DrawBehind) \
@ -78,7 +75,6 @@ namespace SkRecords {
M(DrawRegion) \
M(DrawTextBlob) \
M(DrawAtlas) \
M(DrawAtlas2) \
M(DrawVertices) \
M(DrawShadowRec) \
M(DrawAnnotation) \
@ -243,12 +239,6 @@ RECORD(DrawImage, kDraw_Tag|kHasImage_Tag|kHasPaint_Tag,
sk_sp<const SkImage> image;
SkScalar left;
SkScalar top);
RECORD(DrawImage2, kDraw_Tag|kHasImage_Tag|kHasPaint_Tag,
Optional<SkPaint> paint;
sk_sp<const SkImage> image;
SkScalar left;
SkScalar top;
SkSamplingOptions sampling);
RECORD(DrawImageLattice, kDraw_Tag|kHasImage_Tag|kHasPaint_Tag,
Optional<SkPaint> paint;
sk_sp<const SkImage> image;
@ -261,32 +251,12 @@ RECORD(DrawImageLattice, kDraw_Tag|kHasImage_Tag|kHasPaint_Tag,
PODArray<SkColor> colors;
SkIRect src;
SkRect dst);
RECORD(DrawImageLattice2, kDraw_Tag|kHasImage_Tag|kHasPaint_Tag,
Optional<SkPaint> paint;
sk_sp<const SkImage> image;
int xCount;
PODArray<int> xDivs;
int yCount;
PODArray<int> yDivs;
int flagCount;
PODArray<SkCanvas::Lattice::RectType> flags;
PODArray<SkColor> colors;
SkIRect src;
SkRect dst;
SkFilterMode filter);
RECORD(DrawImageRect, kDraw_Tag|kHasImage_Tag|kHasPaint_Tag,
Optional<SkPaint> paint;
sk_sp<const SkImage> image;
Optional<SkRect> src;
SkRect dst;
SkCanvas::SrcRectConstraint constraint);
RECORD(DrawImageRect2, kDraw_Tag|kHasImage_Tag|kHasPaint_Tag,
Optional<SkPaint> paint;
sk_sp<const SkImage> image;
SkRect src;
SkRect dst;
SkSamplingOptions sampling;
SkCanvas::SrcRectConstraint constraint);
RECORD(DrawOval, kDraw_Tag|kHasPaint_Tag,
SkPaint paint;
SkRect oval);
@ -335,16 +305,6 @@ RECORD(DrawAtlas, kDraw_Tag|kHasImage_Tag|kHasPaint_Tag,
int count;
SkBlendMode mode;
Optional<SkRect> cull);
RECORD(DrawAtlas2, kDraw_Tag|kHasImage_Tag|kHasPaint_Tag,
Optional<SkPaint> paint;
sk_sp<const SkImage> atlas;
PODArray<SkRSXform> xforms;
PODArray<SkRect> texs;
PODArray<SkColor> colors;
int count;
SkBlendMode mode;
SkSamplingOptions sampling;
Optional<SkRect> cull);
RECORD(DrawVertices, kDraw_Tag|kHasPaint_Tag,
SkPaint paint;
sk_sp<SkVertices> vertices;

View File

@ -12,10 +12,6 @@
class SkSamplingPriv {
public:
enum {
kFlatSize = 3 * sizeof(uint32_t) // bool32 + [2 floats | 2 ints]
};
// Returns true if the sampling can be ignored when the CTM is identity.
static bool NoChangeWithIdentityMatrix(const SkSamplingOptions& sampling) {
#ifdef SK_SUPPORT_LEGACY_SPRITE_IGNORE_HQ

View File

@ -805,7 +805,7 @@ void SkGpuDevice::drawImageRect(const SkImage* image, const SkRect* src, const S
ASSERT_SINGLE_OWNER
GrQuadAAFlags aaFlags = paint.isAntiAlias() ? GrQuadAAFlags::kAll : GrQuadAAFlags::kNone;
this->drawImageQuad(image, src, &dst, nullptr, GrAA(paint.isAntiAlias()), aaFlags, nullptr,
sampling, paint, constraint);
/*sampling*/paint, constraint);
}
// When drawing nine-patches or n-patches, cap the filter quality at kLinear.
@ -848,12 +848,7 @@ void SkGpuDevice::drawProducerLattice(GrTextureProducer* producer,
void SkGpuDevice::drawImageLattice(const SkImage* image,
const SkCanvas::Lattice& lattice, const SkRect& dst,
SkFilterMode filter, const SkPaint& origPaint) {
// TODO: plumb filter down rather than rely on deprecated filter-quality
SkPaint paint(origPaint);
paint.setFilterQuality(filter == SkFilterMode::kLinear ? kLow_SkFilterQuality
: kNone_SkFilterQuality);
SkFilterMode filter, const SkPaint& paint) {
ASSERT_SINGLE_OWNER
uint32_t pinnedUniqueID;
auto iter = std::make_unique<SkLatticeIter>(lattice, dst);

View File

@ -205,8 +205,7 @@ private:
// If 'preViewMatrix' is not null, final CTM will be this->ctm() * preViewMatrix.
void drawImageQuad(const SkImage*, const SkRect* src, const SkRect* dst,
const SkPoint dstClip[4], GrAA aa, GrQuadAAFlags aaFlags,
const SkMatrix* preViewMatrix, const SkSamplingOptions&,
const SkPaint&, SkCanvas::SrcRectConstraint);
const SkMatrix* preViewMatrix, const SkPaint&, SkCanvas::SrcRectConstraint);
// FIXME(michaelludwig) - Should be removed in favor of using drawImageQuad with edge flags to
// for every element in the SkLatticeIter.

View File

@ -321,9 +321,9 @@ static ImageDrawMode optimize_sample_area(const SkISize& image, const SkRect* or
* Checks whether the paint is compatible with using GrSurfaceDrawContext::drawTexture. It is more
* efficient than the GrTextureProducer general case.
*/
static bool can_use_draw_texture(const SkPaint& paint, bool useCubicResampler, SkMipmapMode mm) {
static bool can_use_draw_texture(const SkPaint& paint) {
return (!paint.getColorFilter() && !paint.getShader() && !paint.getMaskFilter() &&
!paint.getImageFilter() && !useCubicResampler && mm == SkMipmapMode::kNone);
!paint.getImageFilter() && SkPaintPriv::GetFQ(paint) < kMedium_SkFilterQuality);
}
static SkPMColor4f texture_color(SkColor4f paintColor, float entryAlpha, GrColorType srcColorType,
@ -428,7 +428,7 @@ static void draw_texture_producer(GrRecordingContext* context,
const SkMatrix& ctm(matrixProvider.localToDevice());
if (sampler.wrapModeX() == GrSamplerState::WrapMode::kClamp &&
sampler.wrapModeY() == GrSamplerState::WrapMode::kClamp && !producer->isPlanar() &&
can_use_draw_texture(paint, GrValidCubicResampler(cubic), sampler.mipmapMode())) {
can_use_draw_texture(paint)) {
// We've done enough checks above to allow us to pass ClampNearest() and not check for
// scaling adjustments.
auto view = producer->view(GrMipmapped::kNo);
@ -683,8 +683,11 @@ void SkGpuDevice::drawSpecial(SkSpecialImage* special, const SkMatrix& localToDe
void SkGpuDevice::drawImageQuad(const SkImage* image, const SkRect* srcRect, const SkRect* dstRect,
const SkPoint dstClip[4], GrAA aa, GrQuadAAFlags aaFlags,
const SkMatrix* preViewMatrix, const SkSamplingOptions& sampling,
const SkPaint& paint, SkCanvas::SrcRectConstraint constraint) {
const SkMatrix* preViewMatrix, const SkPaint& paint,
SkCanvas::SrcRectConstraint constraint) {
// TODO: pass in sampling directly
SkSamplingOptions sampling(paint.getFilterQuality(), SkSamplingOptions::kMedium_asMipmapLinear);
SkRect src;
SkRect dst;
SkMatrix srcToDst;
@ -802,12 +805,8 @@ void SkGpuDevice::drawImageQuad(const SkImage* image, const SkRect* srcRect, con
void SkGpuDevice::drawEdgeAAImageSet(const SkCanvas::ImageSetEntry set[], int count,
const SkPoint dstClips[], const SkMatrix preViewMatrices[],
const SkPaint& paint, SkCanvas::SrcRectConstraint constraint) {
// TODO: pass in directly
// pass sampling, or just filter?
SkSamplingOptions sampling(SkPaintPriv::GetFQ(paint));
SkASSERT(count > 0);
if (!can_use_draw_texture(paint, sampling.useCubic, sampling.mipmap)) {
if (!can_use_draw_texture(paint)) {
// Send every entry through drawImageQuad() to handle the more complicated paint
int dstClipIndex = 0;
for (int i = 0; i < count; ++i) {
@ -826,13 +825,13 @@ void SkGpuDevice::drawEdgeAAImageSet(const SkCanvas::ImageSetEntry set[], int co
set[i].fHasClip ? dstClips + dstClipIndex : nullptr, GrAA::kYes,
SkToGrQuadAAFlags(set[i].fAAFlags),
set[i].fMatrixIndex < 0 ? nullptr : preViewMatrices + set[i].fMatrixIndex,
sampling, *entryPaint, constraint);
*entryPaint, constraint);
dstClipIndex += 4 * set[i].fHasClip;
}
return;
}
GrSamplerState::Filter filter = sampling.filter == SkFilterMode::kNearest
GrSamplerState::Filter filter = kNone_SkFilterQuality == paint.getFilterQuality()
? GrSamplerState::Filter::kNearest
: GrSamplerState::Filter::kLinear;
SkBlendMode mode = paint.getBlendMode();
@ -905,7 +904,7 @@ void SkGpuDevice::drawEdgeAAImageSet(const SkCanvas::ImageSetEntry set[], int co
image, &set[i].fSrcRect, &set[i].fDstRect, clip, GrAA::kYes,
SkToGrQuadAAFlags(set[i].fAAFlags),
set[i].fMatrixIndex < 0 ? nullptr : preViewMatrices + set[i].fMatrixIndex,
sampling, *entryPaint, constraint);
*entryPaint, constraint);
continue;
}

View File

@ -241,7 +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);
@ -265,51 +264,6 @@ void SkNWayCanvas::onDrawImageLattice(const SkImage* image, const Lattice& latti
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);
}
}
#endif
void SkNWayCanvas::onDrawImage2(const SkImage* image, SkScalar left, SkScalar top,
const SkSamplingOptions& sampling, const SkPaint* paint) {
Iter iter(fList);
while (iter.next()) {
iter->drawImage(image, left, top, sampling, paint);
}
}
void SkNWayCanvas::onDrawImageRect2(const SkImage* image, const SkRect& src, const SkRect& dst,
const SkSamplingOptions& sampling, const SkPaint* paint,
SrcRectConstraint constraint) {
Iter iter(fList);
while (iter.next()) {
iter->drawImageRect(image, src, dst, sampling, paint, constraint);
}
}
void SkNWayCanvas::onDrawImageLattice2(const SkImage* image, const Lattice& lattice,
const SkRect& dst, SkFilterMode filter,
const SkPaint* paint) {
Iter iter(fList);
while (iter.next()) {
iter->drawImageLattice(image, lattice, dst, filter, paint);
}
}
void SkNWayCanvas::onDrawAtlas2(const SkImage* image, const SkRSXform xform[], const SkRect tex[],
const SkColor colors[], int count, SkBlendMode bmode,
const SkSamplingOptions& sampling, const SkRect* cull,
const SkPaint* paint) {
Iter iter(fList);
while (iter.next()) {
iter->drawAtlas(image, xform, tex, colors, count, bmode, sampling, cull, paint);
}
}
void SkNWayCanvas::onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y,
const SkPaint &paint) {
@ -351,6 +305,15 @@ void SkNWayCanvas::onDrawPatch(const SkPoint cubics[12], const SkColor colors[4]
}
}
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::onDrawShadowRec(const SkPath& path, const SkDrawShadowRec& rec) {
Iter iter(fList);
while (iter.next()) {

View File

@ -116,7 +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);
@ -141,41 +140,6 @@ void SkPaintFilterCanvas::onDrawImageLattice(const SkImage* image, const Lattice
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());
}
}
#endif
void SkPaintFilterCanvas::onDrawImage2(const SkImage* image, SkScalar left, SkScalar top,
const SkSamplingOptions& sampling, const SkPaint* paint) {
AutoPaintFilter apf(this, paint);
if (apf.shouldDraw()) {
this->SkNWayCanvas::onDrawImage2(image, left, top, sampling, &apf.paint());
}
}
void SkPaintFilterCanvas::onDrawImageRect2(const SkImage* image, const SkRect& src,
const SkRect& dst, const SkSamplingOptions& sampling,
const SkPaint* paint, SrcRectConstraint constraint) {
AutoPaintFilter apf(this, paint);
if (apf.shouldDraw()) {
this->SkNWayCanvas::onDrawImageRect2(image, src, dst, sampling, &apf.paint(), constraint);
}
}
void SkPaintFilterCanvas::onDrawImageLattice2(const SkImage* image, const Lattice& lattice,
const SkRect& dst, SkFilterMode filter,
const SkPaint* paint) {
AutoPaintFilter apf(this, paint);
if (apf.shouldDraw()) {
this->SkNWayCanvas::onDrawImageLattice2(image, lattice, dst, filter, &apf.paint());
}
}
void SkPaintFilterCanvas::onDrawVerticesObject(const SkVertices* vertices,
SkBlendMode bmode, const SkPaint& paint) {
@ -234,14 +198,12 @@ void SkPaintFilterCanvas::onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkS
}
}
void SkPaintFilterCanvas::onDrawAtlas2(const SkImage* image, const SkRSXform xform[],
const SkRect tex[], const SkColor colors[], int count,
SkBlendMode bmode, const SkSamplingOptions& sampling,
const SkRect* cull, const SkPaint* 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::onDrawAtlas2(image, xform, tex, colors, count, bmode, sampling, cull,
&apf.paint());
this->SkNWayCanvas::onDrawAtlas(image, xform, tex, colors, count, bmode, cull, &apf.paint());
}
}

View File

@ -230,7 +230,7 @@ DEF_TEST(Image_Serialize_Encoding_Failure, reporter) {
SkPictureRecorder recorder;
SkCanvas* canvas = recorder.beginRecording(100, 100);
canvas->drawImage(image.get(), 0, 0, SkSamplingOptions());
canvas->drawImage(image, 0, 0);
sk_sp<SkPicture> picture(recorder.finishRecordingAsPicture());
REPORTER_ASSERT(reporter, picture);
REPORTER_ASSERT(reporter, picture->approximateOpCount() > 0);

View File

@ -269,7 +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;
@ -279,7 +278,6 @@ DEF_TEST(RecordDraw_drawImage, r){
const SkPaint* paint, SrcRectConstraint) override {
fDrawImageRectCalled = true;
}
#endif
void resetTestValues() {
fDrawImageCalled = fDrawImageRectCalled = false;
@ -295,7 +293,6 @@ DEF_TEST(RecordDraw_drawImage, r){
SkCanvasMock canvas(10, 10);
#ifdef SK_SUPPORT_LEGACY_ONDRAWIMAGERECT
{
SkRecord record;
SkRecorder recorder(&record, 10, 10);
@ -312,5 +309,5 @@ DEF_TEST(RecordDraw_drawImage, r){
SkRecordDraw(record, &canvas, nullptr, nullptr, 0, nullptr, nullptr);
}
REPORTER_ASSERT(r, canvas.fDrawImageRectCalled);
#endif
}

View File

@ -78,7 +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);
@ -108,38 +107,6 @@ DEF_TEST(Recorder_drawImage_takeReference, reporter) {
REPORTER_ASSERT(reporter, 1 == tally.count<SkRecords::DrawImageRect>());
}
REPORTER_ASSERT(reporter, image->unique());
#endif
{
SkRecord record;
SkRecorder recorder(&record, 100, 100);
// DrawImage is supposed to take a reference
recorder.drawImage(image.get(), 0, 0, SkSamplingOptions());
REPORTER_ASSERT(reporter, !image->unique());
Tally tally;
tally.apply(record);
REPORTER_ASSERT(reporter, 1 == tally.count<SkRecords::DrawImage2>());
}
REPORTER_ASSERT(reporter, image->unique());
{
SkRecord record;
SkRecorder recorder(&record, 100, 100);
// DrawImageRect is supposed to take a reference
recorder.drawImageRect(image.get(), SkRect::MakeWH(100, 100), SkRect::MakeWH(100, 100),
SkSamplingOptions(), nullptr, SkCanvas::kFast_SrcRectConstraint);
REPORTER_ASSERT(reporter, !image->unique());
Tally tally;
tally.apply(record);
REPORTER_ASSERT(reporter, 1 == tally.count<SkRecords::DrawImageRect2>());
}
REPORTER_ASSERT(reporter, image->unique());
}
// skbug.com/10997

View File

@ -402,7 +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,
@ -439,58 +438,6 @@ void DebugCanvas::onDrawImageRect(const SkImage* image,
// 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));
}
#endif
void DebugCanvas::onDrawImage2(const SkImage* image,
SkScalar left,
SkScalar top,
const SkSamplingOptions& sampling, // todo
const SkPaint* paint) {
this->addDrawCommand(new DrawImageCommand(image, left, top, paint));
}
void DebugCanvas::onDrawImageLattice2(const SkImage* image,
const Lattice& lattice,
const SkRect& dst,
SkFilterMode filter, // todo
const SkPaint* paint) {
this->addDrawCommand(new DrawImageLatticeCommand(image, lattice, dst, paint));
}
void DebugCanvas::onDrawImageRect2(const SkImage* image,
const SkRect& src,
const SkRect& dst,
const SkSamplingOptions& sampling, // todo
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 {
this->addDrawCommand(new DrawImageRectCommand(image, &src, dst, paint, constraint));
}
// Reset expectation so next drawImageRect is not special.
fnextDrawImageRectLayerId = -1;
}
void DebugCanvas::onDrawOval(const SkRect& oval, const SkPaint& paint) {
this->addDrawCommand(new DrawOvalCommand(oval, paint));
@ -578,15 +525,14 @@ void DebugCanvas::onDrawVerticesObject(const SkVertices* vertices,
new DrawVerticesCommand(sk_ref_sp(const_cast<SkVertices*>(vertices)), bmode, paint));
}
void DebugCanvas::onDrawAtlas2(const SkImage* image,
const SkRSXform xform[],
const SkRect tex[],
const SkColor colors[],
int count,
SkBlendMode bmode,
const SkSamplingOptions& sampling,
const SkRect* cull,
const SkPaint* paint) {
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));
}

View File

@ -169,24 +169,24 @@ 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;
#endif
void onDrawImage2(const SkImage*, SkScalar, SkScalar, const SkSamplingOptions&,
const SkPaint*) override;
void onDrawImageRect2(const SkImage*, const SkRect&, const SkRect&, const SkSamplingOptions&,
const SkPaint*, SrcRectConstraint) override;
void onDrawImageLattice2(const SkImage*, const Lattice&, const SkRect&, SkFilterMode,
const SkPaint*) override;
void onDrawAtlas2(const SkImage*, const SkRSXform[], const SkRect[], const SkColor[], int,
SkBlendMode, const SkSamplingOptions&, const SkRect*, const SkPaint*) override;
void onDrawImageLattice(const SkImage* image,
const Lattice& lattice,
const SkRect& dst,
const SkPaint* paint) override;
void onDrawImageRect(const SkImage*,
const SkRect* src,
const SkRect& dst,
const SkPaint*,
SrcRectConstraint) override;
void onDrawAtlas(const SkImage*,
const SkRSXform[],
const SkRect[],
const SkColor[],
int,
SkBlendMode,
const SkRect*,
const SkPaint*) override;
void onClipRect(const SkRect&, SkClipOp, ClipEdgeStyle) override;
void onClipRRect(const SkRRect&, SkClipOp, ClipEdgeStyle) override;
void onClipPath(const SkPath&, SkClipOp, ClipEdgeStyle) override;