OLD | NEW |
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 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 kTextBlob_Type, | 42 kTextBlob_Type, |
43 kVertices_Type, | 43 kVertices_Type, |
44 kPatch_Type, | 44 kPatch_Type, |
45 | 45 |
46 kTypeCount | 46 kTypeCount |
47 }; | 47 }; |
48 | 48 |
49 protected: | 49 protected: |
50 /** | 50 /** |
51 * 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. |
52 * | 52 * The implementation may modify the paint as they wish (using SkTCopyOnFir
stWrite::writable). |
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 * | 53 * |
57 * The result bool is used to determine whether the draw op is to be | 54 * 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 | 55 * executed (true) or skipped (false). |
59 * ignored. | |
60 * | 56 * |
61 * Note: The base implementation calls onFilter() for top-level/explicit pa
ints only. | 57 * Note: The base implementation calls onFilter() for top-level/explicit pa
ints only. |
62 * To also filter encapsulated paints (e.g. SkPicture, SkTextBlob), c
lients may need to | 58 * To also filter encapsulated paints (e.g. SkPicture, SkTextBlob), c
lients may need to |
63 * override the relevant methods (i.e. drawPicture, drawTextBlob). | 59 * override the relevant methods (i.e. drawPicture, drawTextBlob). |
64 */ | 60 */ |
65 virtual bool onFilter(const SkPaint* paint, Type type, SkTLazy<SkPaint>* fil
teredPaint) const { | 61 virtual bool onFilter(SkTCopyOnFirstWrite<SkPaint>* paint, Type type) const
{ |
66 if (paint) { | 62 if (*paint) { |
67 this->onFilterPaint(filteredPaint->set(*paint), type); | 63 this->onFilterPaint(paint->writable(), type); |
68 } | 64 } |
69 return true; | 65 return true; |
70 } | 66 } |
71 | 67 |
72 // DEPRECATED - do not use | 68 // DEPRECATED - do not use |
73 virtual void onFilterPaint(SkPaint*, Type) const { } | 69 virtual void onFilterPaint(SkPaint*, Type) const { } |
74 | 70 |
75 void onDrawPaint(const SkPaint&) override; | 71 void onDrawPaint(const SkPaint&) override; |
76 void onDrawPoints(PointMode, size_t count, const SkPoint pts[], const SkPain
t&) override; | 72 void onDrawPoints(PointMode, size_t count, const SkPoint pts[], const SkPain
t&) override; |
77 void onDrawRect(const SkRect&, const SkPaint&) override; | 73 void onDrawRect(const SkRect&, const SkPaint&) override; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 void onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y, | 106 void onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y, |
111 const SkPaint& paint) override; | 107 const SkPaint& paint) override; |
112 | 108 |
113 private: | 109 private: |
114 class AutoPaintFilter; | 110 class AutoPaintFilter; |
115 | 111 |
116 typedef SkNWayCanvas INHERITED; | 112 typedef SkNWayCanvas INHERITED; |
117 }; | 113 }; |
118 | 114 |
119 #endif | 115 #endif |
OLD | NEW |