Chromium Code Reviews| Index: include/core/SkCanvas.h |
| diff --git a/include/core/SkCanvas.h b/include/core/SkCanvas.h |
| index 003a96c0566e8ffd4d5056c0fc8cce42d84bb568..4c7beb080f295ef9e31c915b372c492a84104460 100644 |
| --- a/include/core/SkCanvas.h |
| +++ b/include/core/SkCanvas.h |
| @@ -391,6 +391,27 @@ public: |
| SK_ATTR_EXTERNALLY_DEPRECATED("SaveFlags use is deprecated") |
| int saveLayerAlpha(const SkRect* bounds, U8CPU alpha, SaveFlags flags); |
| + enum { |
| + kIsOpaque_SaveLayerFlag = 1 << 0, |
| + kPreserveLCDText_SaveLayerFlag = 1 << 1, |
| + }; |
| + typedef uint32_t SaveLayerFlags; |
| + |
| + struct SaveLayerRec { |
| + SaveLayerRec() : fBounds(nullptr), fPaint(nullptr), fSaveLayerFlags(0) {} |
| + SaveLayerRec(const SkRect* bounds, const SkPaint* paint, SaveLayerFlags saveLayerFlags = 0) |
| + : fBounds(bounds) |
| + , fPaint(paint) |
| + , fSaveLayerFlags(saveLayerFlags) |
| + {} |
| + |
| + const SkRect* fBounds; // optional |
| + const SkPaint* fPaint; // optional |
| + SaveLayerFlags 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 +1241,20 @@ protected: |
| // willSaveLayer()'s return value may suppress full layer allocation. |
| enum SaveLayerStrategy { |
| kFullLayer_SaveLayerStrategy, |
| - kNoLayer_SaveLayerStrategy |
| + kNoLayer_SaveLayerStrategy, |
| }; |
| virtual void willSave() {} |
| +#ifdef SK_SUPPORT_LEGACY_SAVELAYERPARAMS |
| virtual SaveLayerStrategy willSaveLayer(const SkRect*, const SkPaint*, SaveFlags) { |
| return kFullLayer_SaveLayerStrategy; |
| } |
| + virtual SaveLayerStrategy getSaveLayerStrategy(const SaveLayerRec&); |
| +#else |
| + virtual SaveLayerStrategy getSaveLayerStrategy(const SaveLayerRec&) { |
|
f(malita)
2015/12/17 22:23:28
While reviewing the Chromium side of this CL, it o
reed1
2015/12/17 22:29:39
That is documented on the strategy enum, but I wil
|
| + return kFullLayer_SaveLayerStrategy; |
| + } |
| +#endif |
| virtual void willRestore() {} |
| virtual void didRestore() {} |
| virtual void didConcat(const SkMatrix&) {} |
| @@ -1304,16 +1332,17 @@ 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, |
| - SkIRect* intersection, |
| + bool clipRectBounds(const SkRect* bounds, SaveLayerFlags, SkIRect* intersection, |
| const SkImageFilter* imageFilter = NULL); |
| private: |
| - enum PrivateSaveFlags { |
| - // These must not overlap the public flags. |
| - kPreserveLCDText_PrivateSaveFlag = 1 << 5, |
| + enum PrivateSaveLayerFlags { |
| + kDontClipToLayer_PrivateSaveLayerFlag = 1 << 31, |
| }; |
| + static bool BoundsAffectsClip(SaveLayerFlags); |
| + static uint32_t SaveFlagsToSaveLayerFlags(SaveFlags); |
| + |
| enum ShaderOverrideOpacity { |
| kNone_ShaderOverrideOpacity, //!< there is no overriding shader (bitmap or image) |
| kOpaque_ShaderOverrideOpacity, //!< the overriding shader is opaque |
| @@ -1373,6 +1402,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 +1434,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() |