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

Unified Diff: src/core/SkCanvas.cpp

Issue 196323003: Revert of Revert "De-virtualize SkCanvas save/restore." (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 9 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 | « src/core/SkBBoxHierarchyRecord.cpp ('k') | src/core/SkPictureRecord.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkCanvas.cpp
diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp
index 0888a01fa459615322717b5896d68bed5e0dc229..bd75f7dbdea0f37fc3351bbe180ebd48d40e2277 100644
--- a/src/core/SkCanvas.cpp
+++ b/src/core/SkCanvas.cpp
@@ -348,7 +348,7 @@
SkPaint tmp;
tmp.setImageFilter(fOrigPaint.getImageFilter());
(void)canvas->internalSaveLayer(bounds, &tmp,
- SkCanvas::kARGB_ClipLayer_SaveFlag, true);
+ SkCanvas::kARGB_ClipLayer_SaveFlag, true, false);
// we'll clear the imageFilter for the actual draws in next(), so
// it will only be applied during the restore().
fDoClearImageFilter = true;
@@ -806,7 +806,12 @@
return saveCount;
}
+void SkCanvas::onSave(SaveFlags) {
+ // Do nothing. Subclasses may do something.
+}
+
int SkCanvas::save(SaveFlags flags) {
+ this->onSave(flags);
// call shared impl
return this->internalSave(flags);
}
@@ -863,9 +868,16 @@
return true;
}
+bool SkCanvas::onSaveLayer(const SkRect*, const SkPaint*, SaveFlags) {
+ // Do nothing. Subclasses may do something.
+ return true;
+}
+
int SkCanvas::saveLayer(const SkRect* bounds, const SkPaint* paint,
SaveFlags flags) {
- return this->internalSaveLayer(bounds, paint, flags, false);
+ // Overriding classes may return false to signal that we don't need to create a layer.
+ bool skipLayer = !this->onSaveLayer(bounds, paint, flags);
+ return this->internalSaveLayer(bounds, paint, flags, false, skipLayer);
}
static SkBaseDevice* createCompatibleDevice(SkCanvas* canvas,
@@ -875,7 +887,7 @@
}
int SkCanvas::internalSaveLayer(const SkRect* bounds, const SkPaint* paint,
- SaveFlags flags, bool justForImageFilter) {
+ SaveFlags flags, bool justForImageFilter, bool skipLayer) {
#ifndef SK_SUPPORT_LEGACY_CLIPTOLAYERFLAG
flags = (SaveFlags)(flags | kClipToLayer_SaveFlag);
#endif
@@ -890,6 +902,11 @@
if (!this->clipRectBounds(bounds, flags, &ir, paint ? paint->getImageFilter() : NULL)) {
return count;
}
+
+ // FIXME: do onSaveLayer() overriders returning false really care about the clipRectBounds()
+ // call above?
+ if (skipLayer)
+ return count;
// Kill the imagefilter if our device doesn't allow it
SkLazyPaint lazyP;
@@ -943,9 +960,14 @@
}
}
+void SkCanvas::onRestore() {
+ // Do nothing. Subclasses may do something.
+}
+
void SkCanvas::restore() {
// check for underflow
if (fMCStack.count() > 1) {
+ this->onRestore();
this->internalRestore();
}
}
« no previous file with comments | « src/core/SkBBoxHierarchyRecord.cpp ('k') | src/core/SkPictureRecord.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698