Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(327)

Unified Diff: include/utils/SkPaintFilterCanvas.h

Issue 1577933002: SkPaintFilterCanvas skip-draw support (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: lazy paint copy + missing onDrawImageNine override Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | samplecode/SampleApp.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/utils/SkPaintFilterCanvas.h
diff --git a/include/utils/SkPaintFilterCanvas.h b/include/utils/SkPaintFilterCanvas.h
index 0ad7e251b6e54759a850a9c6c04fbbba4d7362db..505f965565882f5784c7383e4f5b8f884a134e53 100644
--- a/include/utils/SkPaintFilterCanvas.h
+++ b/include/utils/SkPaintFilterCanvas.h
@@ -9,10 +9,11 @@
#define SkPaintFilterCanvas_DEFINED
#include "SkNWayCanvas.h"
+#include "SkTLazy.h"
/** \class SkPaintFilterCanvas
- A utility proxy base class for implementing paint filters.
+ A utility proxy base class for implementing draw/paint filters.
*/
class SK_API SkPaintFilterCanvas : public SkNWayCanvas {
public:
@@ -48,13 +49,28 @@ public:
protected:
/**
* Called with the paint that will be used to draw the specified type.
- * The implementation may modify the paint as they wish.
*
- * Note: The base implementation calls onFilterPaint() for top-level/explicit paints only.
+ * Upon return, if filteredPaint is initialized it will replace the original paint
+ * for the current draw. Note that that implementation is responsible for
+ * initializing *filteredPaint (e.g. via set(*paint)).
+ *
+ * The result bool is used to determine whether the draw op is to be
+ * executed (true) or skipped (false). When the draw is skipped, filteredPaint is
+ * ignored.
+ *
+ * Note: The base implementation calls onFilter() for top-level/explicit paints only.
* To also filter encapsulated paints (e.g. SkPicture, SkTextBlob), clients may need to
* override the relevant methods (i.e. drawPicture, drawTextBlob).
*/
- virtual void onFilterPaint(SkPaint* paint, Type type) const = 0;
+ virtual bool onFilter(const SkPaint* paint, Type type, SkTLazy<SkPaint>* filteredPaint) const {
+ if (paint) {
+ this->onFilterPaint(filteredPaint->set(*paint), type);
+ }
+ return true;
+ }
+
+ // DEPRECATED - do not use
+ virtual void onFilterPaint(SkPaint*, Type) const { }
void onDrawPaint(const SkPaint&) override;
void onDrawPoints(PointMode, size_t count, const SkPoint pts[], const SkPaint&) override;
@@ -66,11 +82,13 @@ protected:
void onDrawBitmap(const SkBitmap&, SkScalar left, SkScalar top, const SkPaint*) override;
void onDrawBitmapRect(const SkBitmap&, const SkRect* src, const SkRect& dst, const SkPaint*,
SrcRectConstraint) override;
+ void onDrawBitmapNine(const SkBitmap&, const SkIRect& center, const SkRect& dst,
+ const SkPaint*) override;
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 onDrawBitmapNine(const SkBitmap&, const SkIRect& center, const SkRect& dst,
- const SkPaint*) override;
+ void onDrawImageNine(const SkImage*, const SkIRect& center, const SkRect& dst,
+ const SkPaint*) override;
void onDrawVertices(VertexMode vmode, int vertexCount,
const SkPoint vertices[], const SkPoint texs[],
const SkColor colors[], SkXfermode* xmode,
« no previous file with comments | « no previous file | samplecode/SampleApp.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698