Index: src/core/SkWriteBuffer.cpp |
diff --git a/src/core/SkWriteBuffer.cpp b/src/core/SkWriteBuffer.cpp |
index 7ddc77f93beffab298ca8ac183a1b1570c9cff3e..ac3d678dbc011a70b9c38cdd91ce4199f633750c 100644 |
--- a/src/core/SkWriteBuffer.cpp |
+++ b/src/core/SkWriteBuffer.cpp |
@@ -218,31 +218,16 @@ void SkWriteBuffer::writeBitmap(const SkBitmap& bitmap) { |
SkBitmap::WriteRawPixels(this, bitmap); |
} |
-static bool try_write_encoded(SkWriteBuffer* buffer, SkData* encoded) { |
- SkPixelSerializer* ps = buffer->getPixelSerializer(); |
- // Assumes that if the client did not set a serializer, they are |
- // happy to get the encoded data. |
- if (!ps || ps->useEncodedData(encoded->data(), encoded->size())) { |
- write_encoded_bitmap(buffer, encoded, SkIPoint::Make(0, 0)); |
- return true; |
- } |
- return false; |
-} |
- |
void SkWriteBuffer::writeImage(const SkImage* image) { |
this->writeInt(image->width()); |
this->writeInt(image->height()); |
- SkAutoTUnref<SkData> encoded(image->refEncoded()); |
- if (encoded && try_write_encoded(this, encoded)) { |
+ SkAutoTUnref<SkData> encoded(image->encode(this->getPixelSerializer())); |
+ if (encoded) { |
+ write_encoded_bitmap(this, encoded, SkIPoint::Make(0, 0)); |
return; |
} |
- encoded.reset(image->encode(SkImageEncoder::kPNG_Type, 100)); |
- if (encoded && try_write_encoded(this, encoded)) { |
- return; |
- } |
- |
this->writeUInt(0); // signal no pixels (in place of the size of the encoded data) |
} |