Chromium Code Reviews| Index: include/core/SkCanvas.h |
| diff --git a/include/core/SkCanvas.h b/include/core/SkCanvas.h |
| index 003a96c0566e8ffd4d5056c0fc8cce42d84bb568..e9735ce40702d5a8eacd78f245e63e14a6a29a6c 100644 |
| --- a/include/core/SkCanvas.h |
| +++ b/include/core/SkCanvas.h |
| @@ -391,6 +391,26 @@ public: |
| SK_ATTR_EXTERNALLY_DEPRECATED("SaveFlags use is deprecated") |
| int saveLayerAlpha(const SkRect* bounds, U8CPU alpha, SaveFlags flags); |
| + enum SaveLayerFlags { |
| + kIsOpaque_SaveLayerFlag = 1 << 0, |
| + kPreserveLCDText_SaveLayerFlag = 1 << 1, |
| + }; |
|
f(malita)
2015/12/17 19:40:49
Since we don't really refer to the SaveLayerFlags
reed1
2015/12/17 19:53:27
Done.
|
| + |
| + struct SaveLayerRec { |
| + SaveLayerRec() : fBounds(nullptr), fPaint(nullptr), fSaveLayerFlags(0) {} |
| + SaveLayerRec(const SkRect* bounds, const SkPaint* paint, uint32_t saveLayerFlags = 0) |
| + : fBounds(bounds) |
| + , fPaint(paint) |
| + , fSaveLayerFlags(saveLayerFlags) |
| + {} |
| + |
| + const SkRect* fBounds; // optional |
| + const SkPaint* fPaint; // optional |
| + uint32_t fSaveLayerFlags; |
| + }; |
| + |
| + int saveLayer(const SaveLayerRec&); |
| + |
| /** This call balances a previous call to save(), and is used to remove all |
| modifications to the matrix/clip/drawFilter state since the last save |
| call. |
| @@ -1220,13 +1240,20 @@ protected: |
| // willSaveLayer()'s return value may suppress full layer allocation. |
| enum SaveLayerStrategy { |
| kFullLayer_SaveLayerStrategy, |
| - kNoLayer_SaveLayerStrategy |
| + kNoLayer_SaveLayerStrategy, |
| + kCallLegacyMethod_SaveLayerStrategy, // TEMPORARY until we can remove legacy willSaveLayer |
| }; |
| virtual void willSave() {} |
| +#ifdef SK_SUPPORT_LEGACY_SAVELAYERPARAMS |
| virtual SaveLayerStrategy willSaveLayer(const SkRect*, const SkPaint*, SaveFlags) { |
| return kFullLayer_SaveLayerStrategy; |
| } |
| +#endif |
| + virtual SaveLayerStrategy getSaveLayerStrategy(const SaveLayerRec&) { |
| + // returning this tells us to call the older version of this method |
| + return kCallLegacyMethod_SaveLayerStrategy; |
| + } |
| virtual void willRestore() {} |
| virtual void didRestore() {} |
| virtual void didConcat(const SkMatrix&) {} |
| @@ -1304,14 +1331,23 @@ protected: |
| // returns false if the entire rectangle is entirely clipped out |
| // If non-NULL, The imageFilter parameter will be used to expand the clip |
| // and offscreen bounds for any margin required by the filter DAG. |
| - bool clipRectBounds(const SkRect* bounds, SaveFlags flags, |
| + bool clipRectBounds(const SkRect* bounds, uint32_t saveLayerFlags, |
| SkIRect* intersection, |
| const SkImageFilter* imageFilter = NULL); |
| private: |
| + enum PrivateSaveLayerFlags { |
| + kDontSaveMatrix_PrivateSaveLayerFlag = 1 << 29, |
| + kDontSaveClip_PrivateSaveLayerFlag = 1 << 30, |
|
f(malita)
2015/12/17 19:40:49
I don't think these are needed: we don't ever get
reed1
2015/12/17 19:49:19
Meaning I don't need any of these, or I don't need
|
| + kDontClipToLayer_PrivateSaveLayerFlag = 1 << 31, |
| + }; |
| + |
| + static bool BoundsAffectsClip(uint32_t saveLayerFlags); |
| + static uint32_t SaveFlagsToSaveLayerFlags(SaveFlags); |
| + |
| enum PrivateSaveFlags { |
| // These must not overlap the public flags. |
|
robertphillips
2015/12/17 19:53:57
??
|
| - kPreserveLCDText_PrivateSaveFlag = 1 << 5, |
| +// kPreserveLCDText_PrivateSaveFlag = 1 << 5, |
| }; |
| enum ShaderOverrideOpacity { |
| @@ -1373,6 +1409,7 @@ private: |
| friend class SkNoSaveLayerCanvas; // InitFlags |
| friend class SkPictureImageFilter; // SkCanvas(SkBaseDevice*, SkSurfaceProps*, InitFlags) |
| friend class SkPictureRecord; // predrawNotify (why does it need it? <reed>) |
| + friend class SkPicturePlayback; // SaveFlagsToSaveLayerFlags |
| enum InitFlags { |
| kDefault_InitFlags = 0, |
| @@ -1404,7 +1441,7 @@ private: |
| const SkRect& dst, const SkPaint* paint, |
| SrcRectConstraint); |
| void internalDrawPaint(const SkPaint& paint); |
| - void internalSaveLayer(const SkRect* bounds, const SkPaint*, SaveFlags, SaveLayerStrategy); |
| + void internalSaveLayer(const SaveLayerRec&, SaveLayerStrategy); |
| void internalDrawDevice(SkBaseDevice*, int x, int y, const SkPaint*, bool isBitmapDevice); |
| // shared by save() and saveLayer() |