diff options
author | 2015-09-28 09:58:41 -0700 | |
---|---|---|
committer | 2015-09-28 09:58:41 -0700 | |
commit | c9e190ddac3d193e89e580ea3819a55c28f15e61 (patch) | |
tree | 0ed534fa007d732ad9d90f33f604e0e845ee2ce4 /include/core | |
parent | 25a5b0dd0c9e94d508b8a9f4de1f977e63775bd1 (diff) |
Revert of change pixel-serializer to support reencoding existing data (patchset #5 id:80001 of https://codereview.chromium.org/1373683003/ )
Reason for revert:
Need to somehow get access to encoders in chrome -- link error on the roll since SkImageEncoder is not built as part of chrome.
Original issue's description:
> change pixel-serializer to support reencoding existing data
>
> Trying to evolve this interface so it can
> - support rich set of backend-encoders (including ones like ETC1 that can cheaply convert to KXT
> - allow for encoding images as well as bitmaps (e.g. for picture serialization)
> - perhaps replace SkImageEncoder as an API (assuming we create a factory that returns a serializer given a format)
>
> BUG=skia:
>
> Committed: https://skia.googlesource.com/skia/+/13f48dc85aa68a60da66aaf39c93d527d11d1278
TBR=scroggo@google.com,msarett@google.com
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=skia:
Review URL: https://codereview.chromium.org/1371983003
Diffstat (limited to 'include/core')
-rw-r--r-- | include/core/SkImageEncoder.h | 13 | ||||
-rw-r--r-- | include/core/SkPixelSerializer.h | 42 |
2 files changed, 19 insertions, 36 deletions
diff --git a/include/core/SkImageEncoder.h b/include/core/SkImageEncoder.h index 5fa69f7992..fc999dcc18 100644 --- a/include/core/SkImageEncoder.h +++ b/include/core/SkImageEncoder.h @@ -13,8 +13,6 @@ class SkBitmap; class SkData; -class SkPixmap; -class SkPixelSerializer; class SkWStream; class SkImageEncoder { @@ -62,11 +60,8 @@ public: */ bool encodeStream(SkWStream* stream, const SkBitmap& bm, int quality); - SkPixelSerializer* refSerializer(); - static SkData* EncodeData(const SkImageInfo&, const void* pixels, size_t rowBytes, Type, int quality); - static SkData* EncodeData(const SkPixmap&, Type, int quality); static SkData* EncodeData(const SkBitmap&, Type, int quality); static bool EncodeFile(const char file[], const SkBitmap&, Type, @@ -74,12 +69,6 @@ public: static bool EncodeStream(SkWStream*, const SkBitmap&, Type, int quality); - /** - * If the existing data can be re-encoded into the specified type (efficiently), this - * returns that new data (which the caller must unref()). If not, this returns null. - */ - static SkData* ReencodeData(SkData* encoded, Type); - protected: /** * Encode bitmap 'bm' in the desired format, writing results to @@ -89,8 +78,6 @@ protected: * This must be overridden by each SkImageEncoder implementation. */ virtual bool onEncode(SkWStream* stream, const SkBitmap& bm, int quality) = 0; - - virtual SkData* onReencodeData(SkData*) { return nullptr; } }; // This macro declares a global (i.e., non-class owned) creation entry point diff --git a/include/core/SkPixelSerializer.h b/include/core/SkPixelSerializer.h index 4ac5253077..d089209909 100644 --- a/include/core/SkPixelSerializer.h +++ b/include/core/SkPixelSerializer.h @@ -8,10 +8,9 @@ #ifndef SkPixelSerializer_DEFINED #define SkPixelSerializer_DEFINED -#include "SkData.h" -#include "SkPixmap.h" #include "SkRefCnt.h" +class SkData; struct SkImageInfo; /** @@ -19,38 +18,35 @@ struct SkImageInfo; */ class SkPixelSerializer : public SkRefCnt { public: + virtual ~SkPixelSerializer() {} + /** - * 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. + * Call to determine if the client wants to serialize the encoded data. If + * false, serialize another version (e.g. the result of encodePixels). */ - SkData* reencodeData(SkData* encoded); + bool useEncodedData(const void* data, size_t len) { + return this->onUseEncodedData(data, len); + } /** * 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); + SkData* encodePixels(const SkImageInfo& info, const void* pixels, size_t rowBytes) { + return this->onEncodePixels(info, pixels, rowBytes); + } +protected: /** - * Call to get the client's version of encoding these pixels. If it - * returns NULL, serialize the raw pixels. + * Return true if you want to serialize the encoded data, false if you want + * another version serialized (e.g. the result of encodePixels). */ - 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); - } + virtual bool onUseEncodedData(const void* data, size_t len) = 0; + /** + * 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 |