From 39426e2bcc8463b88872d22d6ed2729c68323073 Mon Sep 17 00:00:00 2001 From: "commit-bot@chromium.org" Date: Wed, 16 Apr 2014 16:24:08 +0000 Subject: [PATCH] read/write function_ptrs as just void*, and not as 'array of bytes' BUG=skia: R=mtklein@google.com, bungeman@google.com Author: reed@google.com Review URL: https://codereview.chromium.org/240013005 git-svn-id: http://skia.googlecode.com/svn/trunk@14224 2bbb7eff-a529-9590-31e7-b0007b416f81 --- include/core/SkReadBuffer.h | 7 +------ include/core/SkWriteBuffer.h | 2 +- tests/PaintTest.cpp | 2 +- 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/include/core/SkReadBuffer.h b/include/core/SkReadBuffer.h index 3cb31a0e80..f6b1919133 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 332dfaea40..04acbf10cb 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 98110e0d8d..f6aede1200 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();