remove SkWriteBuffer::getWriter32().

SkWriteBuffer exposes its lower-level implementation SkWriter32 through
this one call.  It's not currently used in any interesting way:
   - write_encoded_bitmap() uses it to manually re-create writeDataAsByteArray();
   - unit tests use it incidentally as a quick way to read the serialized bytes.

This should be SkWriteBuffer no longer necessarily needs to have an SkWriter32.

Landing this will let us then remove SkWriter32::contiguousArray().

BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1936563002

TBR=reed@google.com
Just deleting API

Review-Url: https://codereview.chromium.org/1936563002
This commit is contained in:
mtklein 2016-04-29 13:58:09 -07:00 committed by Commit bot
parent 900bd4a046
commit b4c899d48d
3 changed files with 8 additions and 6 deletions

View File

@ -38,7 +38,6 @@ public:
return SkToBool(fFlags & kCrossProcess_Flag); return SkToBool(fFlags & kCrossProcess_Flag);
} }
SkWriter32* getWriter32() { return &fWriter; }
void reset(void* storage = NULL, size_t storageSize = 0) { void reset(void* storage = NULL, size_t storageSize = 0) {
fWriter.reset(storage, storageSize); fWriter.reset(storage, storageSize);
} }

View File

@ -136,8 +136,7 @@ bool SkWriteBuffer::writeToStream(SkWStream* stream) {
static void write_encoded_bitmap(SkWriteBuffer* buffer, SkData* data, static void write_encoded_bitmap(SkWriteBuffer* buffer, SkData* data,
const SkIPoint& origin) { const SkIPoint& origin) {
buffer->writeUInt(SkToU32(data->size())); buffer->writeDataAsByteArray(data);
buffer->getWriter32()->writePad(data->data(), data->size());
buffer->write32(origin.fX); buffer->write32(origin.fX);
buffer->write32(origin.fY); buffer->write32(origin.fY);
} }

View File

@ -258,8 +258,9 @@ DEF_TEST(Paint_flattening, reporter) {
SkWriteBuffer writer; SkWriteBuffer writer;
paint.flatten(writer); paint.flatten(writer);
const uint32_t* written = writer.getWriter32()->contiguousArray(); SkAutoMalloc buf(writer.bytesWritten());
SkReadBuffer reader(written, writer.bytesWritten()); writer.writeToMemory(buf.get());
SkReadBuffer reader(buf.get(), writer.bytesWritten());
SkPaint paint2; SkPaint paint2;
paint2.unflatten(reader); paint2.unflatten(reader);
@ -297,7 +298,10 @@ DEF_TEST(Paint_MoreFlattening, r) {
SkWriteBuffer writer; SkWriteBuffer writer;
paint.flatten(writer); paint.flatten(writer);
SkReadBuffer reader(writer.getWriter32()->contiguousArray(), writer.bytesWritten()); SkAutoMalloc buf(writer.bytesWritten());
writer.writeToMemory(buf.get());
SkReadBuffer reader(buf.get(), writer.bytesWritten());
SkPaint other; SkPaint other;
other.unflatten(reader); other.unflatten(reader);
ASSERT(reader.offset() == writer.bytesWritten()); ASSERT(reader.offset() == writer.bytesWritten());