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

Unified Diff: include/core/SkPixelSerializer.h

Issue 1373683003: change pixel-serializer to support reencoding existing data Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: I hate this warning 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 | « include/core/SkImageEncoder.h ('k') | src/core/SkPixelSerializer.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/core/SkPixelSerializer.h
diff --git a/include/core/SkPixelSerializer.h b/include/core/SkPixelSerializer.h
index d089209909816b720fb710206b0a6e8005a38f57..4ac52530778491e798d622ae10f237bceb46fc68 100644
--- a/include/core/SkPixelSerializer.h
+++ b/include/core/SkPixelSerializer.h
@@ -8,9 +8,10 @@
#ifndef SkPixelSerializer_DEFINED
#define SkPixelSerializer_DEFINED
+#include "SkData.h"
+#include "SkPixmap.h"
#include "SkRefCnt.h"
-class SkData;
struct SkImageInfo;
/**
@@ -18,35 +19,38 @@ struct SkImageInfo;
*/
class SkPixelSerializer : public SkRefCnt {
public:
- virtual ~SkPixelSerializer() {}
-
/**
- * Call to determine if the client wants to serialize the encoded data. If
- * false, serialize another version (e.g. the result of encodePixels).
+ * Call to determine if the client wants to serialize the encoded data.
+ *
+ * If the encoded data is can be re-encoded (or taken as is), this returns a ref to a data
+ * with the result, which the caller must unref() when they are through. The returned
+ * data may be the same as the input, or it may be different, but either way the caller is
+ * responsible for calling unref() on it.
+ *
+ * If the encoded data is not acceptable to this pixel serializer, this returns NULL.
*/
- bool useEncodedData(const void* data, size_t len) {
- return this->onUseEncodedData(data, len);
- }
+ SkData* reencodeData(SkData* encoded);
/**
* Call to get the client's version of encoding these pixels. If it
* returns NULL, serialize the raw pixels.
*/
- SkData* encodePixels(const SkImageInfo& info, const void* pixels, size_t rowBytes) {
- return this->onEncodePixels(info, pixels, rowBytes);
- }
+ SkData* encodePixels(const SkImageInfo& info, const void* pixels, size_t rowBytes);
-protected:
/**
- * Return true if you want to serialize the encoded data, false if you want
- * another version serialized (e.g. the result of encodePixels).
+ * Call to get the client's version of encoding these pixels. If it
+ * returns NULL, serialize the raw pixels.
*/
- virtual bool onUseEncodedData(const void* data, size_t len) = 0;
+ SkData* encodePixels(const SkPixmap& pixmap);
+
+protected:
+ // DEPRECATED -- this is no longer called, so remove from your subclasses!
+ virtual bool onUseEncodedData(const void*, size_t) { return true; }
+
+ virtual SkData* onReencodeData(SkData* encoded) {
+ return SkRef(encoded);
+ }
- /**
- * 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;
};
#endif // SkPixelSerializer_DEFINED
« no previous file with comments | « include/core/SkImageEncoder.h ('k') | src/core/SkPixelSerializer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698