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

Unified Diff: src/core/SkWriteBuffer.cpp

Issue 1373683003: change pixel-serializer to support reencoding existing data Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: I hate this warning 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 | « src/core/SkPixelSerializer.cpp ('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 1dfe0b3972c62b6b8e68cc6f6d92dc8782935b97..1799df1714b15e4faab98afba9c65fbd9d6e92da 100644
--- a/src/core/SkWriteBuffer.cpp
+++ b/src/core/SkWriteBuffer.cpp
@@ -186,13 +186,15 @@ void SkWriteBuffer::writeBitmap(const SkBitmap& bitmap) {
SkPixelRef* pixelRef = bitmap.pixelRef();
if (pixelRef) {
// see if the pixelref already has an encoded version
- SkAutoDataUnref existingData(pixelRef->refEncodedData());
- if (existingData.get() != nullptr) {
+ SkAutoDataUnref encodedData(pixelRef->refEncodedData());
+ if (encodedData) {
// Assumes that if the client did not set a serializer, they are
// happy to get the encoded data.
- if (!fPixelSerializer || fPixelSerializer->useEncodedData(existingData->data(),
- existingData->size())) {
- write_encoded_bitmap(this, existingData, bitmap.pixelRefOrigin());
+ if (fPixelSerializer) {
+ encodedData.reset(fPixelSerializer->reencodeData(encodedData));
+ }
+ if (encodedData) {
+ write_encoded_bitmap(this, encodedData, bitmap.pixelRefOrigin());
return;
}
}
@@ -200,12 +202,9 @@ void SkWriteBuffer::writeBitmap(const SkBitmap& bitmap) {
// see if the caller wants to manually encode
SkAutoPixmapUnlock result;
if (fPixelSerializer && bitmap.requestLock(&result)) {
- const SkPixmap& pmap = result.pixmap();
SkASSERT(nullptr == fBitmapHeap);
- SkAutoDataUnref data(fPixelSerializer->encodePixels(pmap.info(),
- pmap.addr(),
- pmap.rowBytes()));
- if (data.get() != nullptr) {
+ SkAutoDataUnref data(fPixelSerializer->encodePixels(result.pixmap()));
+ if (data) {
// if we have to "encode" the bitmap, then we assume there is no
// offset to share, since we are effectively creating a new pixelref
write_encoded_bitmap(this, data, SkIPoint::Make(0, 0));
« no previous file with comments | « src/core/SkPixelSerializer.cpp ('k') | src/image/SkImage.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698