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

Unified Diff: include/core/SkPixelSerializer.h

Issue 1501303002: SkPixelSerializer: support indexed pixels (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2015-12-06 (Sunday) 17:21:55 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
Index: include/core/SkPixelSerializer.h
diff --git a/include/core/SkPixelSerializer.h b/include/core/SkPixelSerializer.h
index d089209909816b720fb710206b0a6e8005a38f57..e26e47ed4e01c92390107b8ab69d3f310c8be5ea 100644
--- a/include/core/SkPixelSerializer.h
+++ b/include/core/SkPixelSerializer.h
@@ -8,10 +8,11 @@
#ifndef SkPixelSerializer_DEFINED
#define SkPixelSerializer_DEFINED
+class SkData;
+
#include "SkRefCnt.h"
+#include "SkPixmap.h"
-class SkData;
-struct SkImageInfo;
/**
* Interface for serializing pixels, e.g. SkBitmaps in an SkPicture.
@@ -36,6 +37,16 @@ public:
return this->onEncodePixels(info, pixels, rowBytes);
}
+ /**
+ * Call to get the client's version of encoding these pixels. If it
+ * returns NULL, serialize the raw pixels.
+ */
+ SkData* encode(const SkPixmap& pixmap) {
+ SkData* data = this->onEncode(pixmap);
+ return data ? data : this->onEncodePixels(
+ pixmap.info(), pixmap.addr(), pixmap.rowBytes());
+ }
+
protected:
/**
* Return true if you want to serialize the encoded data, false if you want
@@ -47,6 +58,15 @@ protected:
* If you want to encode these pixels, return the encoded data as an SkData
* Return null if you want to serialize the raw pixels.
*/
- virtual SkData* onEncodePixels(const SkImageInfo&, const void* pixels, size_t rowBytes) = 0;
+ // NOTE: onEncodePixels() is deprecated and removed in a later CL.
+ // Subclasses should implement onEncode() instead. Subclasses
+ // should implement at least one of onEncodePixels() or
+ // onUseEncodedData().
+ virtual SkData* onEncodePixels(const SkImageInfo&,
+ const void* /*pixels*/,
+ size_t /*rowBytes*/) {
+ return nullptr;
+ }
+ virtual SkData* onEncode(const SkPixmap&) { return nullptr; }
};
#endif // SkPixelSerializer_DEFINED

Powered by Google App Engine
This is Rietveld 408576698