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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | samplecode/SampleApp.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2015 Google Inc. 2 * Copyright 2015 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #ifndef SkPaintFilterCanvas_DEFINED 8 #ifndef SkPaintFilterCanvas_DEFINED
9 #define SkPaintFilterCanvas_DEFINED 9 #define SkPaintFilterCanvas_DEFINED
10 10
11 #include "SkNWayCanvas.h" 11 #include "SkNWayCanvas.h"
12 #include "SkTLazy.h"
12 13
13 /** \class SkPaintFilterCanvas 14 /** \class SkPaintFilterCanvas
14 15
15 A utility proxy base class for implementing paint filters. 16 A utility proxy base class for implementing draw/paint filters.
16 */ 17 */
17 class SK_API SkPaintFilterCanvas : public SkNWayCanvas { 18 class SK_API SkPaintFilterCanvas : public SkNWayCanvas {
18 public: 19 public:
19 /** 20 /**
20 * DEPRECATED: use the variant below. 21 * DEPRECATED: use the variant below.
21 */ 22 */
22 SkPaintFilterCanvas(int width, int height); 23 SkPaintFilterCanvas(int width, int height);
23 24
24 /** 25 /**
25 * The new SkPaintFilterCanvas is configured for forwarding to the 26 * The new SkPaintFilterCanvas is configured for forwarding to the
(...skipping 15 matching lines...) Expand all
41 kTextBlob_Type, 42 kTextBlob_Type,
42 kVertices_Type, 43 kVertices_Type,
43 kPatch_Type, 44 kPatch_Type,
44 45
45 kTypeCount 46 kTypeCount
46 }; 47 };
47 48
48 protected: 49 protected:
49 /** 50 /**
50 * Called with the paint that will be used to draw the specified type. 51 * Called with the paint that will be used to draw the specified type.
51 * The implementation may modify the paint as they wish.
52 * 52 *
53 * Note: The base implementation calls onFilterPaint() for top-level/explic it paints only. 53 * Upon return, if filteredPaint is initialized it will replace the origina l paint
54 * for the current draw. Note that that implementation is responsible for
55 * initializing *filteredPaint (e.g. via set(*paint)).
56 *
57 * The result bool is used to determine whether the draw op is to be
58 * executed (true) or skipped (false). When the draw is skipped, filteredP aint is
59 * ignored.
60 *
61 * Note: The base implementation calls onFilter() for top-level/explicit pa ints only.
54 * To also filter encapsulated paints (e.g. SkPicture, SkTextBlob), c lients may need to 62 * To also filter encapsulated paints (e.g. SkPicture, SkTextBlob), c lients may need to
55 * override the relevant methods (i.e. drawPicture, drawTextBlob). 63 * override the relevant methods (i.e. drawPicture, drawTextBlob).
56 */ 64 */
57 virtual void onFilterPaint(SkPaint* paint, Type type) const = 0; 65 virtual bool onFilter(const SkPaint* paint, Type type, SkTLazy<SkPaint>* fil teredPaint) const {
66 if (paint) {
67 this->onFilterPaint(filteredPaint->set(*paint), type);
68 }
69 return true;
70 }
71
72 // DEPRECATED - do not use
73 virtual void onFilterPaint(SkPaint*, Type) const { }
58 74
59 void onDrawPaint(const SkPaint&) override; 75 void onDrawPaint(const SkPaint&) override;
60 void onDrawPoints(PointMode, size_t count, const SkPoint pts[], const SkPain t&) override; 76 void onDrawPoints(PointMode, size_t count, const SkPoint pts[], const SkPain t&) override;
61 void onDrawRect(const SkRect&, const SkPaint&) override; 77 void onDrawRect(const SkRect&, const SkPaint&) override;
62 void onDrawRRect(const SkRRect&, const SkPaint&) override; 78 void onDrawRRect(const SkRRect&, const SkPaint&) override;
63 void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) override; 79 void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) override;
64 void onDrawOval(const SkRect&, const SkPaint&) override; 80 void onDrawOval(const SkRect&, const SkPaint&) override;
65 void onDrawPath(const SkPath&, const SkPaint&) override; 81 void onDrawPath(const SkPath&, const SkPaint&) override;
66 void onDrawBitmap(const SkBitmap&, SkScalar left, SkScalar top, const SkPain t*) override; 82 void onDrawBitmap(const SkBitmap&, SkScalar left, SkScalar top, const SkPain t*) override;
67 void onDrawBitmapRect(const SkBitmap&, const SkRect* src, const SkRect& dst, const SkPaint*, 83 void onDrawBitmapRect(const SkBitmap&, const SkRect* src, const SkRect& dst, const SkPaint*,
68 SrcRectConstraint) override; 84 SrcRectConstraint) override;
85 void onDrawBitmapNine(const SkBitmap&, const SkIRect& center, const SkRect& dst,
86 const SkPaint*) override;
69 void onDrawImage(const SkImage*, SkScalar left, SkScalar top, const SkPaint* ) override; 87 void onDrawImage(const SkImage*, SkScalar left, SkScalar top, const SkPaint* ) override;
70 void onDrawImageRect(const SkImage*, const SkRect* src, const SkRect& dst, 88 void onDrawImageRect(const SkImage*, const SkRect* src, const SkRect& dst,
71 const SkPaint*, SrcRectConstraint) override; 89 const SkPaint*, SrcRectConstraint) override;
72 void onDrawBitmapNine(const SkBitmap&, const SkIRect& center, const SkRect& dst, 90 void onDrawImageNine(const SkImage*, const SkIRect& center, const SkRect& ds t,
73 const SkPaint*) override; 91 const SkPaint*) override;
74 void onDrawVertices(VertexMode vmode, int vertexCount, 92 void onDrawVertices(VertexMode vmode, int vertexCount,
75 const SkPoint vertices[], const SkPoint texs[], 93 const SkPoint vertices[], const SkPoint texs[],
76 const SkColor colors[], SkXfermode* xmode, 94 const SkColor colors[], SkXfermode* xmode,
77 const uint16_t indices[], int indexCount, 95 const uint16_t indices[], int indexCount,
78 const SkPaint&) override; 96 const SkPaint&) override;
79 void onDrawPatch(const SkPoint cubics[12], const SkColor colors[4], 97 void onDrawPatch(const SkPoint cubics[12], const SkColor colors[4],
80 const SkPoint texCoords[4], SkXfermode* xmode, 98 const SkPoint texCoords[4], SkXfermode* xmode,
81 const SkPaint& paint) override; 99 const SkPaint& paint) override;
82 void onDrawPicture(const SkPicture*, const SkMatrix*, const SkPaint*) overri de; 100 void onDrawPicture(const SkPicture*, const SkMatrix*, const SkPaint*) overri de;
83 101
84 void onDrawText(const void* text, size_t byteLength, SkScalar x, SkScalar y, 102 void onDrawText(const void* text, size_t byteLength, SkScalar x, SkScalar y,
85 const SkPaint&) override; 103 const SkPaint&) override;
86 void onDrawPosText(const void* text, size_t byteLength, const SkPoint pos[], 104 void onDrawPosText(const void* text, size_t byteLength, const SkPoint pos[],
87 const SkPaint&) override; 105 const SkPaint&) override;
88 void onDrawPosTextH(const void* text, size_t byteLength, const SkScalar xpos [], 106 void onDrawPosTextH(const void* text, size_t byteLength, const SkScalar xpos [],
89 SkScalar constY, const SkPaint&) override; 107 SkScalar constY, const SkPaint&) override;
90 void onDrawTextOnPath(const void* text, size_t byteLength, const SkPath& pat h, 108 void onDrawTextOnPath(const void* text, size_t byteLength, const SkPath& pat h,
91 const SkMatrix* matrix, const SkPaint&) override; 109 const SkMatrix* matrix, const SkPaint&) override;
92 void onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y, 110 void onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y,
93 const SkPaint& paint) override; 111 const SkPaint& paint) override;
94 112
95 private: 113 private:
96 class AutoPaintFilter; 114 class AutoPaintFilter;
97 115
98 typedef SkNWayCanvas INHERITED; 116 typedef SkNWayCanvas INHERITED;
99 }; 117 };
100 118
101 #endif 119 #endif
OLDNEW
« 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