Index: include/core/SkPixelSerializer.h |
diff --git a/include/core/SkPixelSerializer.h b/include/core/SkPixelSerializer.h |
index d089209909816b720fb710206b0a6e8005a38f57..6f3ad37c83f1a133279deb2b2a716a4ac06bc0b9 100644 |
--- a/include/core/SkPixelSerializer.h |
+++ b/include/core/SkPixelSerializer.h |
@@ -9,9 +9,9 @@ |
#define SkPixelSerializer_DEFINED |
#include "SkRefCnt.h" |
+#include "SkPixmap.h" |
class SkData; |
-struct SkImageInfo; |
/** |
* Interface for serializing pixels, e.g. SkBitmaps in an SkPicture. |
@@ -33,7 +33,17 @@ public: |
* returns NULL, serialize the raw pixels. |
*/ |
SkData* encodePixels(const SkImageInfo& info, const void* pixels, size_t rowBytes) { |
scroggo
2015/12/07 15:57:07
Does anyone call this other than SkWriteBuffer? Or
hal.canary
2015/12/07 20:25:01
done
|
- return this->onEncodePixels(info, pixels, rowBytes); |
+ return this->encode(SkPixmap(info, pixels, rowBytes, nullptr)); |
+ } |
+ |
+ /** |
+ * 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: |
@@ -47,6 +57,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. |
scroggo
2015/12/07 15:57:07
Does Chrome override this? Should we use a macro t
hal.canary
2015/12/07 20:25:01
Chrome and only Chrome overrides this. Macros are
|
+ // 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 |