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

Side by Side Diff: include/utils/SkPaintFilterCanvas.h

Issue 1576183002: SkTCopyOnFirstWrite-based SkPaintFilterCanvas API (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: minor cleanup 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 | « include/core/SkTLazy.h ('k') | 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
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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
OLDNEW
« no previous file with comments | « include/core/SkTLazy.h ('k') | samplecode/SampleApp.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698