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

Unified Diff: src/core/SkWriteBuffer.cpp

Issue 1371983003: Revert of change pixel-serializer to support reencoding existing data (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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 1799df1714b15e4faab98afba9c65fbd9d6e92da..1dfe0b3972c62b6b8e68cc6f6d92dc8782935b97 100644
--- a/src/core/SkWriteBuffer.cpp
+++ b/src/core/SkWriteBuffer.cpp
@@ -186,15 +186,13 @@
SkPixelRef* pixelRef = bitmap.pixelRef();
if (pixelRef) {
// see if the pixelref already has an encoded version
- SkAutoDataUnref encodedData(pixelRef->refEncodedData());
- if (encodedData) {
+ SkAutoDataUnref existingData(pixelRef->refEncodedData());
+ if (existingData.get() != nullptr) {
// Assumes that if the client did not set a serializer, they are
// happy to get the encoded data.
- if (fPixelSerializer) {
- encodedData.reset(fPixelSerializer->reencodeData(encodedData));
- }
- if (encodedData) {
- write_encoded_bitmap(this, encodedData, bitmap.pixelRefOrigin());
+ if (!fPixelSerializer || fPixelSerializer->useEncodedData(existingData->data(),
+ existingData->size())) {
+ write_encoded_bitmap(this, existingData, bitmap.pixelRefOrigin());
return;
}
}
@@ -202,9 +200,12 @@
// 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(result.pixmap()));
- if (data) {
+ SkAutoDataUnref data(fPixelSerializer->encodePixels(pmap.info(),
+ pmap.addr(),
+ pmap.rowBytes()));
+ if (data.get() != nullptr) {
// 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