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

Unified Diff: samplecode/SampleApp.cpp

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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/utils/SkPaintFilterCanvas.h ('k') | src/utils/SkPaintFilterCanvas.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: samplecode/SampleApp.cpp
diff --git a/samplecode/SampleApp.cpp b/samplecode/SampleApp.cpp
index 9f0bd4524ced5cb46c5e4d124be7deec3a177dbc..ce2cfb259009bf54ec22779aaa43853c2f15cf6a 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:
« no previous file with comments | « include/utils/SkPaintFilterCanvas.h ('k') | src/utils/SkPaintFilterCanvas.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698