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
This commit is contained in:
commit-bot@chromium.org 2014-04-16 16:24:08 +00:00
parent 9631337be0
commit 39426e2bcc
3 changed files with 3 additions and 8 deletions

View File

@ -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);

View File

@ -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);

View File

@ -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();