Revert "Add new virts, hide old ones"
This reverts commit c56e2e5aa65dd129e5927224d2f6c1f82edff74e.
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>
diff --git a/gm/image_shader.cpp b/gm/image_shader.cpp
index e16c234..831995c 100644
--- a/gm/image_shader.cpp
+++ b/gm/image_shader.cpp
@@ -196,8 +196,7 @@
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);
diff --git a/include/core/SkCanvas.h b/include/core/SkCanvas.h
index 56efcd7..6ade36d 100644
--- a/include/core/SkCanvas.h
+++ b/include/core/SkCanvas.h
@@ -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 @@
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,16 +2257,10 @@
@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 @@
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&);
diff --git a/include/core/SkCanvasVirtualEnforcer.h b/include/core/SkCanvasVirtualEnforcer.h
index 143a256..014029b 100644
--- a/include/core/SkCanvasVirtualEnforcer.h
+++ b/include/core/SkCanvasVirtualEnforcer.h
@@ -40,6 +40,16 @@
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 @@
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;
diff --git a/include/core/SkOverdrawCanvas.h b/include/core/SkOverdrawCanvas.h
index 94533cf..7d15459 100644
--- a/include/core/SkOverdrawCanvas.h
+++ b/include/core/SkOverdrawCanvas.h
@@ -34,25 +34,13 @@
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;
diff --git a/include/utils/SkNWayCanvas.h b/include/utils/SkNWayCanvas.h
index 6d66c15..5157ffe 100644
--- a/include/utils/SkNWayCanvas.h
+++ b/include/utils/SkNWayCanvas.h
@@ -51,25 +51,13 @@
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;
diff --git a/include/utils/SkNoDrawCanvas.h b/include/utils/SkNoDrawCanvas.h
index e07203f..6063f57 100644
--- a/include/utils/SkNoDrawCanvas.h
+++ b/include/utils/SkNoDrawCanvas.h
@@ -53,25 +53,14 @@
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 {}
diff --git a/include/utils/SkPaintFilterCanvas.h b/include/utils/SkPaintFilterCanvas.h
index 8ff003c..2a45a7d 100644
--- a/include/utils/SkPaintFilterCanvas.h
+++ b/include/utils/SkPaintFilterCanvas.h
@@ -57,24 +57,11 @@
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 @@
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;
diff --git a/modules/canvaskit/canvaskit_bindings.cpp b/modules/canvaskit/canvaskit_bindings.cpp
index de93d8d..8aa4d39 100644
--- a/modules/canvaskit/canvaskit_bindings.cpp
+++ b/modules/canvaskit/canvaskit_bindings.cpp
@@ -932,8 +932,7 @@
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 @@
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,
diff --git a/samplecode/SampleAnimatedText.cpp b/samplecode/SampleAnimatedText.cpp
index 80aafdc..f9bd925 100644
--- a/samplecode/SampleAnimatedText.cpp
+++ b/samplecode/SampleAnimatedText.cpp
@@ -73,8 +73,7 @@
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);
diff --git a/samplecode/SampleFilterBounds.cpp b/samplecode/SampleFilterBounds.cpp
index d9d699d..bebdcc2 100644
--- a/samplecode/SampleFilterBounds.cpp
+++ b/samplecode/SampleFilterBounds.cpp
@@ -184,7 +184,7 @@
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
diff --git a/samplecode/SampleThinAA.cpp b/samplecode/SampleThinAA.cpp
index 97be844..08b2b44 100644
--- a/samplecode/SampleThinAA.cpp
+++ b/samplecode/SampleThinAA.cpp
@@ -226,8 +226,7 @@
SkRect::MakeWH(kTileWidth, kTileHeight),
SkSamplingOptions(scale > 1.f ? kNone_SkFilterQuality
: kMedium_SkFilterQuality),
- &blit,
- SkCanvas::kFast_SrcRectConstraint);
+ &blit);
}
private:
diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp
index 31bda26..1049f0d 100644
--- a/src/core/SkCanvas.cpp
+++ b/src/core/SkCanvas.cpp
@@ -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::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 @@
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::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 @@
} 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) {
@@ -2005,22 +1968,7 @@
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 @@
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 @@
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 @@
}
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 @@
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 @@
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 @@
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;
diff --git a/src/core/SkOverdrawCanvas.cpp b/src/core/SkOverdrawCanvas.cpp
index ec8e415..9986524 100644
--- a/src/core/SkOverdrawCanvas.cpp
+++ b/src/core/SkOverdrawCanvas.cpp
@@ -136,55 +136,6 @@
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 @@
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) {
diff --git a/src/core/SkPictureFlat.h b/src/core/SkPictureFlat.h
index e03dcb9..0bdf32e 100644
--- a/src/core/SkPictureFlat.h
+++ b/src/core/SkPictureFlat.h
@@ -109,11 +109,7 @@
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 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 {
diff --git a/src/core/SkPicturePlayback.cpp b/src/core/SkPicturePlayback.cpp
index 499ba97..fdf28ee 100644
--- a/src/core/SkPicturePlayback.cpp
+++ b/src/core/SkPicturePlayback.cpp
@@ -83,11 +83,7 @@
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 @@
}
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 @@
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 @@
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 @@
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;
diff --git a/src/core/SkPicturePriv.h b/src/core/SkPicturePriv.h
index 9a40143..7c954ff 100644
--- a/src/core/SkPicturePriv.h
+++ b/src/core/SkPicturePriv.h
@@ -80,8 +80,6 @@
// 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 @@
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,
diff --git a/src/core/SkPictureRecord.cpp b/src/core/SkPictureRecord.cpp
index 012af13..7c3bff7 100644
--- a/src/core/SkPictureRecord.cpp
+++ b/src/core/SkPictureRecord.cpp
@@ -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 @@
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 @@
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 @@
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 @@
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 @@
if (cull) {
fWriter.write(cull, sizeof(SkRect));
}
- this->addSampling(sampling);
this->validate(initialOffset, size);
}
@@ -1002,17 +915,6 @@
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);
diff --git a/src/core/SkPictureRecord.h b/src/core/SkPictureRecord.h
index 1703b3a..4fb11b0 100644
--- a/src/core/SkPictureRecord.h
+++ b/src/core/SkPictureRecord.h
@@ -141,7 +141,6 @@
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 @@
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 @@
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;
diff --git a/src/core/SkReadBuffer.cpp b/src/core/SkReadBuffer.cpp
index d0b8b6d..38cde75 100644
--- a/src/core/SkReadBuffer.cpp
+++ b/src/core/SkReadBuffer.cpp
@@ -201,26 +201,6 @@
}
}
-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) {
diff --git a/src/core/SkReadBuffer.h b/src/core/SkReadBuffer.h
index 9e2774a..936404b 100644
--- a/src/core/SkReadBuffer.h
+++ b/src/core/SkReadBuffer.h
@@ -96,7 +96,6 @@
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 @@
SkFilterQuality checkFilterQuality();
- SkSamplingOptions readSampling();
-
private:
const char* readString(size_t* length);
diff --git a/src/core/SkRecordDraw.cpp b/src/core/SkRecordDraw.cpp
index 3ffe978..0d14e27 100644
--- a/src/core/SkRecordDraw.cpp
+++ b/src/core/SkRecordDraw.cpp
@@ -108,7 +108,6 @@
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 @@
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(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 @@
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 @@
}
}
- 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);
diff --git a/src/core/SkRecorder.cpp b/src/core/SkRecorder.cpp
index 575e959..606b8bb 100644
--- a/src/core/SkRecorder.cpp
+++ b/src/core/SkRecorder.cpp
@@ -204,7 +204,6 @@
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 @@
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 @@
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));
}
diff --git a/src/core/SkRecorder.h b/src/core/SkRecorder.h
index e6dcd57..962958c 100644
--- a/src/core/SkRecorder.h
+++ b/src/core/SkRecorder.h
@@ -86,25 +86,14 @@
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;
diff --git a/src/core/SkRecords.h b/src/core/SkRecords.h
index 8b7f5b3..f3c1658 100644
--- a/src/core/SkRecords.h
+++ b/src/core/SkRecords.h
@@ -62,9 +62,6 @@
M(DrawImage) \
M(DrawImageLattice) \
M(DrawImageRect) \
- M(DrawImage2) \
- M(DrawImageLattice2) \
- M(DrawImageRect2) \
M(DrawDRRect) \
M(DrawOval) \
M(DrawBehind) \
@@ -78,7 +75,6 @@
M(DrawRegion) \
M(DrawTextBlob) \
M(DrawAtlas) \
- M(DrawAtlas2) \
M(DrawVertices) \
M(DrawShadowRec) \
M(DrawAnnotation) \
@@ -243,12 +239,6 @@
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 @@
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 @@
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;
diff --git a/src/core/SkSamplingPriv.h b/src/core/SkSamplingPriv.h
index facc481..e5701c9 100644
--- a/src/core/SkSamplingPriv.h
+++ b/src/core/SkSamplingPriv.h
@@ -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
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index 406a692..e28d3f2 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -805,7 +805,7 @@
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::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);
diff --git a/src/gpu/SkGpuDevice.h b/src/gpu/SkGpuDevice.h
index 3c8e516..2f67cae 100644
--- a/src/gpu/SkGpuDevice.h
+++ b/src/gpu/SkGpuDevice.h
@@ -205,8 +205,7 @@
// 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.
diff --git a/src/gpu/SkGpuDevice_drawTexture.cpp b/src/gpu/SkGpuDevice_drawTexture.cpp
index 6b8290e..a96b95f 100644
--- a/src/gpu/SkGpuDevice_drawTexture.cpp
+++ b/src/gpu/SkGpuDevice_drawTexture.cpp
@@ -321,9 +321,9 @@
* 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 @@
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::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::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 @@
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 @@
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;
}
diff --git a/src/utils/SkNWayCanvas.cpp b/src/utils/SkNWayCanvas.cpp
index 8cc037b..6c6c801 100644
--- a/src/utils/SkNWayCanvas.cpp
+++ b/src/utils/SkNWayCanvas.cpp
@@ -241,7 +241,6 @@
}
}
-#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 @@
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::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()) {
diff --git a/src/utils/SkPaintFilterCanvas.cpp b/src/utils/SkPaintFilterCanvas.cpp
index 7c7e99d..0dd86d0 100644
--- a/src/utils/SkPaintFilterCanvas.cpp
+++ b/src/utils/SkPaintFilterCanvas.cpp
@@ -116,7 +116,6 @@
}
}
-#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 @@
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::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());
}
}
diff --git a/tests/ImageTest.cpp b/tests/ImageTest.cpp
index 8b4d1c5..7bdf8dd6 100644
--- a/tests/ImageTest.cpp
+++ b/tests/ImageTest.cpp
@@ -230,7 +230,7 @@
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);
diff --git a/tests/RecordDrawTest.cpp b/tests/RecordDrawTest.cpp
index 9430678..ff5d0c8 100644
--- a/tests/RecordDrawTest.cpp
+++ b/tests/RecordDrawTest.cpp
@@ -269,7 +269,6 @@
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 @@
const SkPaint* paint, SrcRectConstraint) override {
fDrawImageRectCalled = true;
}
-#endif
void resetTestValues() {
fDrawImageCalled = fDrawImageRectCalled = false;
@@ -295,7 +293,6 @@
SkCanvasMock canvas(10, 10);
-#ifdef SK_SUPPORT_LEGACY_ONDRAWIMAGERECT
{
SkRecord record;
SkRecorder recorder(&record, 10, 10);
@@ -312,5 +309,5 @@
SkRecordDraw(record, &canvas, nullptr, nullptr, 0, nullptr, nullptr);
}
REPORTER_ASSERT(r, canvas.fDrawImageRectCalled);
-#endif
+
}
diff --git a/tests/RecorderTest.cpp b/tests/RecorderTest.cpp
index 82afa32..116c60b 100644
--- a/tests/RecorderTest.cpp
+++ b/tests/RecorderTest.cpp
@@ -78,7 +78,6 @@
surface->getCanvas()->clear(SK_ColorGREEN);
image = surface->makeImageSnapshot();
}
-#ifdef SK_SUPPORT_LEGACY_ONDRAWIMAGERECT
{
SkRecord record;
SkRecorder recorder(&record, 100, 100);
@@ -108,38 +107,6 @@
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
diff --git a/tools/debugger/DebugCanvas.cpp b/tools/debugger/DebugCanvas.cpp
index 0ec29f8..b8756e5 100644
--- a/tools/debugger/DebugCanvas.cpp
+++ b/tools/debugger/DebugCanvas.cpp
@@ -402,7 +402,6 @@
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 @@
// 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 @@
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));
}
diff --git a/tools/debugger/DebugCanvas.h b/tools/debugger/DebugCanvas.h
index 9183af0..2c956ce 100644
--- a/tools/debugger/DebugCanvas.h
+++ b/tools/debugger/DebugCanvas.h
@@ -169,24 +169,24 @@
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;