diff options
author | fmalita <fmalita@chromium.org> | 2016-01-12 07:21:11 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-01-12 07:21:11 -0800 |
commit | 32cdc32522bf39a8236880f57ff4ee5b26bdd363 (patch) | |
tree | 4dc6f63fe1c65ae124985be47c79b57d116d2e88 /include/utils/SkPaintFilterCanvas.h | |
parent | a51e7782b2e028a38712a159c412e6151eca1666 (diff) |
SkTCopyOnFirstWrite-based SkPaintFilterCanvas API
I find this version preferable because
1) it consolidates the in/out paint args without compromising
efficiency or flexibility
2) relieves overriders from having to set the SkTLazy explicitly
BUG=skia:4782
R=mtklein@google.com,reed@google.com
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1576183002
Review URL: https://codereview.chromium.org/1576183002
Diffstat (limited to 'include/utils/SkPaintFilterCanvas.h')
-rw-r--r-- | include/utils/SkPaintFilterCanvas.h | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/include/utils/SkPaintFilterCanvas.h b/include/utils/SkPaintFilterCanvas.h index 505f965565..35e3221752 100644 --- a/include/utils/SkPaintFilterCanvas.h +++ b/include/utils/SkPaintFilterCanvas.h @@ -49,22 +49,18 @@ public: protected: /** * Called with the paint that will be used to draw the specified type. - * - * 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 implementation may modify the paint as they wish (using SkTCopyOnFirstWrite::writable). * * 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. + * executed (true) or skipped (false). * * 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 bool onFilter(const SkPaint* paint, Type type, SkTLazy<SkPaint>* filteredPaint) const { - if (paint) { - this->onFilterPaint(filteredPaint->set(*paint), type); + virtual bool onFilter(SkTCopyOnFirstWrite<SkPaint>* paint, Type type) const { + if (*paint) { + this->onFilterPaint(paint->writable(), type); } return true; } |