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

Unified Diff: src/core/SkPicturePlayback.cpp

Issue 1535993003: hide old SaveFlags (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: aaaaaargh 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 | « src/core/SkCanvas.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkPicturePlayback.cpp
diff --git a/src/core/SkPicturePlayback.cpp b/src/core/SkPicturePlayback.cpp
index 187eeb96e14bb08498372cc3475fbde13f6ede80..82b8f0e5782ef6ac494e124952f46719448c98cd 100644
--- a/src/core/SkPicturePlayback.cpp
+++ b/src/core/SkPicturePlayback.cpp
@@ -16,6 +16,28 @@
#include "SkTDArray.h"
#include "SkTypes.h"
+// matches old SkCanvas::SaveFlags
+enum LegacySaveFlags {
+ kHasAlphaLayer_LegacySaveFlags = 0x04,
+ kClipToLayer_LegacySaveFlags = 0x10,
+};
+#ifdef SK_SUPPORT_LEGACY_SAVEFLAGS
+static_assert(kHasAlphaLayer_LegacySaveFlags == (int)SkCanvas::kHasAlphaLayer_SaveFlag, "");
+static_assert(kClipToLayer_LegacySaveFlags == (int)SkCanvas::kClipToLayer_SaveFlag, "");
+#endif
+
+SkCanvas::SaveLayerFlags SkCanvas::LegacySaveFlagsToSaveLayerFlags(uint32_t flags) {
+ uint32_t layerFlags = 0;
+
+ if (0 == (flags & kClipToLayer_LegacySaveFlags)) {
+ layerFlags |= SkCanvas::kDontClipToLayer_PrivateSaveLayerFlag;
+ }
+ if (0 == (flags & kHasAlphaLayer_LegacySaveFlags)) {
+ layerFlags |= kIsOpaque_SaveLayerFlag;
+ }
+ return layerFlags;
+}
+
/*
* Read the next op code and chunk size from 'reader'. The returned size
* is the entire size of the chunk (including the opcode). Thus, the
@@ -458,9 +480,8 @@ void SkPicturePlayback::handleOp(SkReader32* reader,
case SAVE_LAYER_SAVEFLAGS_DEPRECATED: {
const SkRect* boundsPtr = get_rect_ptr(reader);
const SkPaint* paint = fPictureData->getPaint(reader);
- const SkCanvas::SaveFlags flags = (SkCanvas::SaveFlags)reader->readInt();
- canvas->saveLayer(SkCanvas::SaveLayerRec(boundsPtr, paint,
- SkCanvas::SaveFlagsToSaveLayerFlags(flags)));
+ auto flags = SkCanvas::LegacySaveFlagsToSaveLayerFlags(reader->readInt());
+ canvas->saveLayer(SkCanvas::SaveLayerRec(boundsPtr, paint, flags));
} break;
case SAVE_LAYER_SAVELAYERFLAGS: {
const SkRect* boundsPtr = get_rect_ptr(reader);
« no previous file with comments | « src/core/SkCanvas.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698