Chromium Code Reviews| Index: src/core/SkPath.cpp |
| diff --git a/src/core/SkPath.cpp b/src/core/SkPath.cpp |
| index defedd2e5db4026a38f33e38e18310aabfd7da9d..545359f3dcfcbd6e2c08701a01aa151f64961762 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,30 @@ 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; |
|
egdaniel
2015/06/11 21:12:27
style wise do you want this sitting here or as an
|
| fIsVolatile = (packed >> kIsVolatile_SerializationShift) & 0x1; |
| SkPathRef* pathRef = SkPathRef::CreateFromBuffer(&buffer); |
| + if (version < kPathPrivFirstDirection_Version) { |
| + switch (fFirstDirection) { // 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); |
| + } |
| + } |
| + |
| size_t sizeRead = 0; |
| if (buffer.isValid()) { |
| fPathRef.reset(pathRef); |