Index: src/core/SkPath.cpp |
diff --git a/src/core/SkPath.cpp b/src/core/SkPath.cpp |
index 9df62850fd2eb5bc9cf442dc4675b7091cded8c1..c765823ac5ac3c3c725a0303861c626e2b710049 100644 |
--- a/src/core/SkPath.cpp |
+++ b/src/core/SkPath.cpp |
@@ -9,6 +9,7 @@ |
#include "SkBuffer.h" |
#include "SkErrorInternals.h" |
+#include "SkFlattenableBuffers.h" |
#include "SkMath.h" |
#include "SkPath.h" |
#include "SkPathRef.h" |
@@ -2086,12 +2087,28 @@ SkPath::Verb SkPath::RawIter::next(SkPoint pts[4]) { |
Format in compressed buffer: [ptCount, verbCount, pts[], verbs[]] |
*/ |
+uint32_t SkPath::sizeInMemory() const { |
+ const int byteCount = sizeof(int32_t) + fPathRef->writeSize(); |
+ return SkAlign4(byteCount); |
+} |
+ |
+uint32_t SkPath::SizeToRead(SkFlattenableReadBuffer& buffer) { |
+#ifndef DELETE_THIS_CODE_WHEN_SKPS_ARE_REBUILT_AT_V14_AND_ALL_OTHER_INSTANCES_TOO |
+ uint32_t packed = buffer.getArrayCount(); |
+ bool newFormat = (packed >> kNewFormat_SerializationShift) & 1; |
+#endif |
+ return sizeof(int32_t) + SkPathRef::SizeToRead(buffer |
+#ifndef DELETE_THIS_CODE_WHEN_SKPS_ARE_REBUILT_AT_V14_AND_ALL_OTHER_INSTANCES_TOO |
+ , newFormat |
+#endif |
+ ); |
+} |
+ |
uint32_t SkPath::writeToMemory(void* storage) const { |
SkDEBUGCODE(this->validate();) |
if (NULL == storage) { |
- const int byteCount = sizeof(int32_t) + fPathRef->writeSize(); |
- return SkAlign4(byteCount); |
+ return sizeInMemory(); |
} |
SkWBuffer buffer(storage); |
@@ -2110,7 +2127,9 @@ uint32_t SkPath::writeToMemory(void* storage) const { |
fPathRef->writeToBuffer(&buffer); |
buffer.padToAlign4(); |
- return SkToU32(buffer.pos()); |
+ uint32_t writeSize = SkToU32(buffer.pos()); |
+ SkASSERT(sizeInMemory() == writeSize); |
+ return writeSize; |
} |
uint32_t SkPath::readFromMemory(const void* storage) { |
@@ -2128,16 +2147,18 @@ uint32_t SkPath::readFromMemory(const void* storage) { |
fPathRef.reset(SkPathRef::CreateFromBuffer(&buffer |
#ifndef DELETE_THIS_CODE_WHEN_SKPS_ARE_REBUILT_AT_V14_AND_ALL_OTHER_INSTANCES_TOO |
- , newFormat, packed) |
+ , newFormat, packed |
#endif |
- ); |
+ )); |
buffer.skipToAlign4(); |
GEN_ID_INC; |
SkDEBUGCODE(this->validate();) |
- return SkToU32(buffer.pos()); |
+ uint32_t readSize = SkToU32(buffer.pos()); |
+ SkASSERT(sizeInMemory() == readSize); |
+ return readSize; |
} |
/////////////////////////////////////////////////////////////////////////////// |