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

Unified Diff: src/image/SkImage.cpp

Issue 1501303002: SkPixelSerializer: support indexed pixels (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2015-12-07 (Monday) 15:24:44 EST Created 5 years 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') | no next file » | 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 be837f28a8fa8782e16afdc5ed0763c8668c6440..7db5b4e0a8e66b7bd477844d46b4b8830a5237f6 100644
--- a/src/image/SkImage.cpp
+++ b/src/image/SkImage.cpp
@@ -185,9 +185,16 @@ 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);
+ SkData* onEncode(const SkPixmap& pixmap) override {
+ SkBitmap bm;
+ if (!bm.installPixels(pixmap.info(),
+ const_cast<void*>(pixmap.addr()),
+ pixmap.rowBytes(),
+ pixmap.ctable(),
+ nullptr, nullptr)) {
+ return nullptr;
+ }
+ return SkImageEncoder::EncodeData(bm, SkImageEncoder::kPNG_Type, 100);
}
};
@@ -205,8 +212,7 @@ SkData* SkImage::encode(SkPixelSerializer* serializer) const {
SkBitmap bm;
SkAutoPixmapUnlock apu;
if (as_IB(this)->getROPixels(&bm) && bm.requestLock(&apu)) {
- const SkPixmap& pmap = apu.pixmap();
- return effectiveSerializer->encodePixels(pmap.info(), pmap.addr(), pmap.rowBytes());
+ return effectiveSerializer->encode(apu.pixmap());
}
return nullptr;
« no previous file with comments | « src/core/SkWriteBuffer.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698