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

Unified Diff: src/pipe/SkGPipeWrite.cpp

Issue 194713008: De-virtualize SkCanvas save/restore. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Rebased 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/SkPictureRecord.cpp ('k') | src/utils/SkDeferredCanvas.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/pipe/SkGPipeWrite.cpp
diff --git a/src/pipe/SkGPipeWrite.cpp b/src/pipe/SkGPipeWrite.cpp
index 43209f644b9e64743d02f02e1e24800fe3959e55..7f2f1a1936f9e9073acaa99282c37d7c949d9cc7 100644
--- a/src/pipe/SkGPipeWrite.cpp
+++ b/src/pipe/SkGPipeWrite.cpp
@@ -229,10 +229,6 @@ public:
}
// overrides from SkCanvas
- virtual int save(SaveFlags) SK_OVERRIDE;
- virtual int saveLayer(const SkRect* bounds, const SkPaint*,
- SaveFlags) SK_OVERRIDE;
- virtual void restore() SK_OVERRIDE;
virtual bool isDrawingToLayer() const SK_OVERRIDE;
virtual bool translate(SkScalar dx, SkScalar dy) SK_OVERRIDE;
virtual bool scale(SkScalar sx, SkScalar sy) SK_OVERRIDE;
@@ -287,6 +283,10 @@ public:
bool shuttleBitmap(const SkBitmap&, int32_t slot);
protected:
+ virtual void willSave(SaveFlags) SK_OVERRIDE;
+ virtual SaveLayerStrategy willSaveLayer(const SkRect*, const SkPaint*, SaveFlags) SK_OVERRIDE;
+ virtual void willRestore() SK_OVERRIDE;
+
virtual void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) SK_OVERRIDE;
virtual void onClipRect(const SkRect&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE;
@@ -514,16 +514,17 @@ uint32_t SkGPipeCanvas::getTypefaceID(SkTypeface* face) {
#define NOTIFY_SETUP(canvas) \
AutoPipeNotify apn(canvas)
-int SkGPipeCanvas::save(SaveFlags flags) {
+void SkGPipeCanvas::willSave(SaveFlags flags) {
NOTIFY_SETUP(this);
if (this->needOpBytes()) {
this->writeOp(kSave_DrawOp, 0, flags);
}
- return this->INHERITED::save(flags);
+
+ this->INHERITED::willSave(flags);
}
-int SkGPipeCanvas::saveLayer(const SkRect* bounds, const SkPaint* paint,
- SaveFlags saveFlags) {
+SkCanvas::SaveLayerStrategy SkGPipeCanvas::willSaveLayer(const SkRect* bounds, const SkPaint* paint,
+ SaveFlags saveFlags) {
NOTIFY_SETUP(this);
size_t size = 0;
unsigned opFlags = 0;
@@ -547,21 +548,23 @@ int SkGPipeCanvas::saveLayer(const SkRect* bounds, const SkPaint* paint,
if (kNoSaveLayer == fFirstSaveLayerStackLevel){
fFirstSaveLayerStackLevel = this->getSaveCount();
}
- // we just pass on the save, so we don't create a layer
- return this->INHERITED::save(saveFlags);
+
+ this->INHERITED::willSaveLayer(bounds, paint, saveFlags);
+ // we don't create a layer
+ return kNoLayer_SaveLayerStrategy;
}
-void SkGPipeCanvas::restore() {
+void SkGPipeCanvas::willRestore() {
NOTIFY_SETUP(this);
if (this->needOpBytes()) {
this->writeOp(kRestore_DrawOp);
}
- this->INHERITED::restore();
-
- if (this->getSaveCount() == fFirstSaveLayerStackLevel){
+ if (this->getSaveCount() - 1 == fFirstSaveLayerStackLevel){
fFirstSaveLayerStackLevel = kNoSaveLayer;
}
+
+ this->INHERITED::willRestore();
}
bool SkGPipeCanvas::isDrawingToLayer() const {
« no previous file with comments | « src/core/SkPictureRecord.cpp ('k') | src/utils/SkDeferredCanvas.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698