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

Unified Diff: include/core/SkCanvas.h

Issue 1533953002: change signature for virtual related to saveLayer, passing SaveLayerRec (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years 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 | « no previous file | include/private/SkRecords.h » ('j') | include/utils/SkNoSaveLayerCanvas.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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()
« no previous file with comments | « no previous file | include/private/SkRecords.h » ('j') | include/utils/SkNoSaveLayerCanvas.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698