aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/core/SkCanvas.h
diff options
context:
space:
mode:
authorGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-03-12 20:21:48 +0000
committerGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-03-12 20:21:48 +0000
commite54a23fcfa42b2fc9d320650de72bcb2d9566b2d (patch)
treebf63292c10f857384abd6a35a6fd0ff6c5a1fb96 /include/core/SkCanvas.h
parentf11943f21d985cba5af38b1609dbe8a4cfa58179 (diff)
De-virtualize SkCanvas save/restore.
This moves the state management logic into non-virtual SkCanvas methods, and turns the virtuals into protected notifiers. R=reed@google.com, robertphillips@google.com Author: fmalita@chromium.org Review URL: https://codereview.chromium.org/194713008 git-svn-id: http://skia.googlecode.com/svn/trunk@13776 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'include/core/SkCanvas.h')
-rw-r--r--include/core/SkCanvas.h21
1 files changed, 16 insertions, 5 deletions
diff --git a/include/core/SkCanvas.h b/include/core/SkCanvas.h
index 5ac137d4f0..bcfba16cd9 100644
--- a/include/core/SkCanvas.h
+++ b/include/core/SkCanvas.h
@@ -378,7 +378,7 @@ public:
by calls to save/restore.
@return The value to pass to restoreToCount() to balance this save()
*/
- virtual int save(SaveFlags flags = kMatrixClip_SaveFlag);
+ int save(SaveFlags flags = kMatrixClip_SaveFlag);
/** This behaves the same as save(), but in addition it allocates an
offscreen bitmap. All drawing calls are directed there, and only when
@@ -393,8 +393,8 @@ public:
@param flags LayerFlags
@return The value to pass to restoreToCount() to balance this save()
*/
- virtual int saveLayer(const SkRect* bounds, const SkPaint* paint,
- SaveFlags flags = kARGB_ClipLayer_SaveFlag);
+ int saveLayer(const SkRect* bounds, const SkPaint* paint,
+ SaveFlags flags = kARGB_ClipLayer_SaveFlag);
/** This behaves the same as save(), but in addition it allocates an
offscreen bitmap. All drawing calls are directed there, and only when
@@ -416,7 +416,7 @@ public:
call.
It is an error to call restore() more times than save() was called.
*/
- virtual void restore();
+ void restore();
/** Returns the number of matrix/clip states on the SkCanvas' private stack.
This will equal # save() calls - # restore() calls + 1. The save count on
@@ -1201,6 +1201,17 @@ protected:
virtual const void* onPeekPixels(SkImageInfo*, size_t* rowBytes);
virtual void* onAccessTopLayerPixels(SkImageInfo*, size_t* rowBytes);
+ // Subclass save/restore notifiers.
+ // Overriders should call the corresponding INHERITED method up the inheritance chain.
+ // willSaveLayer()'s return value may suppress full layer allocation.
+ enum SaveLayerStrategy {
+ kFullLayer_SaveLayerStrategy,
+ kNoLayer_SaveLayerStrategy
+ };
+ virtual void willSave(SaveFlags);
+ virtual SaveLayerStrategy willSaveLayer(const SkRect*, const SkPaint*, SaveFlags);
+ virtual void willRestore();
+
virtual void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&);
enum ClipEdgeStyle {
@@ -1301,7 +1312,7 @@ private:
const SkRect& dst, const SkPaint* paint);
void internalDrawPaint(const SkPaint& paint);
int internalSaveLayer(const SkRect* bounds, const SkPaint* paint,
- SaveFlags, bool justForImageFilter);
+ SaveFlags, bool justForImageFilter, SaveLayerStrategy strategy);
void internalDrawDevice(SkBaseDevice*, int x, int y, const SkPaint*);
// shared by save() and saveLayer()