diff options
author | fmalita <fmalita@chromium.org> | 2016-01-11 13:58:29 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-01-11 13:58:30 -0800 |
commit | bad23dc9ed2e00f2a066db01ab88e4c4adcecfc6 (patch) | |
tree | 70e23d68615f8fc1070c7f0a4256c56d803c54c3 /samplecode | |
parent | ce894007eb51c4dc34b2b6eb19ff6c772a1fb590 (diff) |
SkPaintFilterCanvas skip-draw support
At the time SkPaintFilterCanvas was introduced as a SkDrawFilter replacement,
no clients were relying on the draw veto logic. Now Chromium does.
To facilitate migrating off SkDrawFilter, let's augment SkPaintFilterCanvas
with skip-draw semantics.
A side effect of the CL is that now we call the filter virtual even for null
paints.
BUG=skia:4782
R=reed@google.com,robertphillips@google.com
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1577933002
Review URL: https://codereview.chromium.org/1577933002
Diffstat (limited to 'samplecode')
-rw-r--r-- | samplecode/SampleApp.cpp | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/samplecode/SampleApp.cpp b/samplecode/SampleApp.cpp index 9f0bd4524c..ce2cfb2590 100644 --- a/samplecode/SampleApp.cpp +++ b/samplecode/SampleApp.cpp @@ -465,34 +465,39 @@ class FlagsFilterCanvas : public SkPaintFilterCanvas { public: FlagsFilterCanvas(SkCanvas* canvas, SkOSMenu::TriState lcd, SkOSMenu::TriState aa, SkOSMenu::TriState subpixel, int hinting, int filterQuality) - : INHERITED(canvas->imageInfo().width(), canvas->imageInfo().height()) + : INHERITED(canvas) , fLCDState(lcd) , fAAState(aa) , fSubpixelState(subpixel) , fHintingState(hinting) , fFilterQualityIndex(filterQuality) { SkASSERT((unsigned)filterQuality < SK_ARRAY_COUNT(gFilterQualityStates)); - - this->addCanvas(canvas); } protected: - void onFilterPaint(SkPaint* paint, Type t) const override { + bool onFilter(const SkPaint* paint, Type t, SkTLazy<SkPaint>* filteredPaint) const override { + if (!paint) { + return true; + } + + filteredPaint->set(*paint); if (kText_Type == t && SkOSMenu::kMixedState != fLCDState) { - paint->setLCDRenderText(SkOSMenu::kOnState == fLCDState); + filteredPaint->get()->setLCDRenderText(SkOSMenu::kOnState == fLCDState); } if (SkOSMenu::kMixedState != fAAState) { - paint->setAntiAlias(SkOSMenu::kOnState == fAAState); + filteredPaint->get()->setAntiAlias(SkOSMenu::kOnState == fAAState); } if (0 != fFilterQualityIndex) { - paint->setFilterQuality(gFilterQualityStates[fFilterQualityIndex].fQuality); + filteredPaint->get()->setFilterQuality( + gFilterQualityStates[fFilterQualityIndex].fQuality); } if (SkOSMenu::kMixedState != fSubpixelState) { - paint->setSubpixelText(SkOSMenu::kOnState == fSubpixelState); + filteredPaint->get()->setSubpixelText(SkOSMenu::kOnState == fSubpixelState); } if (0 != fHintingState && fHintingState < (int)SK_ARRAY_COUNT(gHintingStates)) { - paint->setHinting(gHintingStates[fHintingState].hinting); + filteredPaint->get()->setHinting(gHintingStates[fHintingState].hinting); } + return true; } private: |