Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(131)

Unified Diff: src/core/SkWriteBuffer.cpp

Issue 1310633006: Add a SkPixelSerializer SkImage encode variant (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: moar comment tweaks Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/core/SkImage.h ('k') | src/image/SkImage.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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)
}
« no previous file with comments | « include/core/SkImage.h ('k') | src/image/SkImage.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698