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

Unified Diff: src/image/SkImage.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/SkWriteBuffer.cpp ('k') | src/images/SkImageDecoder_ktx.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/image/SkImage.cpp
diff --git a/src/image/SkImage.cpp b/src/image/SkImage.cpp
index 240c06e63be94fe3a5c0e6e680dd65105868b2a0..ee76a7ea39ed825e357227fe812cb12c5f3b4e67 100644
--- a/src/image/SkImage.cpp
+++ b/src/image/SkImage.cpp
@@ -74,14 +74,6 @@
}
SkData* SkImage::encode(SkImageEncoder::Type type, int quality) const {
- SkAutoDataUnref encoded(this->refEncoded());
- if (encoded) {
- SkAutoDataUnref reencoded(SkImageEncoder::ReencodeData(encoded, type));
- if (reencoded) {
- return reencoded.detach();
- }
- }
-
SkBitmap bm;
if (as_IB(this)->getROPixels(&bm)) {
return SkImageEncoder::EncodeData(bm, type, quality);
@@ -93,6 +85,10 @@
class DefaultSerializer : public SkPixelSerializer {
protected:
+ bool onUseEncodedData(const void *data, size_t len) override {
+ return true;
+ }
+
SkData* onEncodePixels(const SkImageInfo& info, const void* pixels, size_t rowBytes) override {
return SkImageEncoder::EncodeData(info, pixels, rowBytes, SkImageEncoder::kPNG_Type, 100);
}
@@ -105,17 +101,15 @@
SkPixelSerializer* effectiveSerializer = serializer ? serializer : &defaultSerializer;
SkAutoTUnref<SkData> encoded(this->refEncoded());
- if (encoded) {
- encoded.reset(effectiveSerializer->reencodeData(encoded));
- if (encoded) {
- return encoded.detach();
- }
+ if (encoded && effectiveSerializer->useEncodedData(encoded->data(), encoded->size())) {
+ return encoded.detach();
}
SkBitmap bm;
SkAutoPixmapUnlock apu;
if (as_IB(this)->getROPixels(&bm) && bm.requestLock(&apu)) {
- return effectiveSerializer->encodePixels(apu.pixmap());
+ const SkPixmap& pmap = apu.pixmap();
+ return effectiveSerializer->encodePixels(pmap.info(), pmap.addr(), pmap.rowBytes());
}
return nullptr;
« no previous file with comments | « src/core/SkWriteBuffer.cpp ('k') | src/images/SkImageDecoder_ktx.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698