diff --git a/include/core/SkReadBuffer.h b/include/core/SkReadBuffer.h index 3cb31a0e8..f6b191913 100644 --- a/include/core/SkReadBuffer.h +++ b/include/core/SkReadBuffer.h @@ -73,6 +73,7 @@ public: uint32_t offset() { return fReader.offset(); } bool eof() { return fReader.eof(); } const void* skip(size_t size) { return fReader.skip(size); } + void* readFunctionPtr() { return fReader.readPtr(); } // primitives virtual bool readBool(); @@ -83,12 +84,6 @@ public: virtual uint32_t readUInt(); virtual int32_t read32(); - void* readFunctionPtr() { - void* ptr; - this->readByteArray(&ptr, sizeof(ptr)); - return ptr; - } - // strings -- the caller is responsible for freeing the string contents virtual void readString(SkString* string); virtual void* readEncodedString(size_t* length, SkPaint::TextEncoding encoding); diff --git a/include/core/SkWriteBuffer.h b/include/core/SkWriteBuffer.h index 332dfaea4..04acbf10c 100644 --- a/include/core/SkWriteBuffer.h +++ b/include/core/SkWriteBuffer.h @@ -58,7 +58,7 @@ public: void write32(int32_t value); void writeString(const char* value); void writeEncodedString(const void* value, size_t byteLength, SkPaint::TextEncoding encoding); - void writeFunctionPtr(void* ptr) { this->writeByteArray(&ptr, sizeof(ptr)); } + void writeFunctionPtr(void* ptr) { fWriter.writePtr(ptr); } void writeFlattenable(const SkFlattenable* flattenable); void writeColor(const SkColor& color); diff --git a/tests/PaintTest.cpp b/tests/PaintTest.cpp index 98110e0d8..f6aede120 100644 --- a/tests/PaintTest.cpp +++ b/tests/PaintTest.cpp @@ -325,7 +325,7 @@ DEF_TEST(Paint_FlatteningTraits, r) { SkWriteBuffer writer; SkPaint::FlatteningTraits::Flatten(writer, paint); - const size_t expectedBytesWritten = sizeof(void*) == 8 ? 48 : 40; + const size_t expectedBytesWritten = sizeof(void*) == 8 ? 40 : 32; ASSERT(expectedBytesWritten == writer.bytesWritten()); const uint32_t* written = writer.getWriter32()->contiguousArray();