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

Unified Diff: src/core/SkPath.cpp

Issue 1185453003: fix deserialization after FirstDirection change to paths (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 6 months 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 | « include/core/SkPath.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkPath.cpp
diff --git a/src/core/SkPath.cpp b/src/core/SkPath.cpp
index defedd2e5db4026a38f33e38e18310aabfd7da9d..daac0772dcde6b55c19e8be6faeddbfa0f1187d8 100644
--- a/src/core/SkPath.cpp
+++ b/src/core/SkPath.cpp
@@ -1861,7 +1861,8 @@ size_t SkPath::writeToMemory(void* storage) const {
int32_t packed = (fConvexity << kConvexity_SerializationShift) |
(fFillType << kFillType_SerializationShift) |
(fFirstDirection << kDirection_SerializationShift) |
- (fIsVolatile << kIsVolatile_SerializationShift);
+ (fIsVolatile << kIsVolatile_SerializationShift) |
+ kCurrent_Version;
buffer.write32(packed);
@@ -1879,12 +1880,33 @@ size_t SkPath::readFromMemory(const void* storage, size_t length) {
return 0;
}
+ unsigned version = packed & 0xFF;
+
fConvexity = (packed >> kConvexity_SerializationShift) & 0xFF;
fFillType = (packed >> kFillType_SerializationShift) & 0xFF;
- fFirstDirection = (packed >> kDirection_SerializationShift) & 0x3;
+ uint8_t dir = (packed >> kDirection_SerializationShift) & 0x3;
fIsVolatile = (packed >> kIsVolatile_SerializationShift) & 0x1;
SkPathRef* pathRef = SkPathRef::CreateFromBuffer(&buffer);
+ // compatibility check
+ if (version < kPathPrivFirstDirection_Version) {
+ switch (dir) { // old values
+ case 0:
+ fFirstDirection = SkPathPriv::kUnknown_FirstDirection;
+ break;
+ case 1:
+ fFirstDirection = SkPathPriv::kCW_FirstDirection;
+ break;
+ case 2:
+ fFirstDirection = SkPathPriv::kCCW_FirstDirection;
+ break;
+ default:
+ SkASSERT(false);
+ }
+ } else {
+ fFirstDirection = dir;
+ }
+
size_t sizeRead = 0;
if (buffer.isValid()) {
fPathRef.reset(pathRef);
« no previous file with comments | « include/core/SkPath.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698