diff options
author | scroggo <scroggo@google.com> | 2015-03-17 05:02:17 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-03-17 05:02:17 -0700 |
commit | 9552662e9fee5eb0ef435e52ab9db505d7ebe4ad (patch) | |
tree | 14784df8eb591511d7a3580ebec89636e4d16710 /include/core | |
parent | d0a840d4d8bb6ebc9981cc331b1b231a6c6e0928 (diff) |
Option for SkCodec to treat dst as all zeroes.
This recreates SkImageDecoder's feature to skip writing zeroes for
SkCodec.
Review URL: https://codereview.chromium.org/980903002
Diffstat (limited to 'include/core')
-rw-r--r-- | include/core/SkImageGenerator.h | 40 |
1 files changed, 38 insertions, 2 deletions
diff --git a/include/core/SkImageGenerator.h b/include/core/SkImageGenerator.h index 5de9d3d85a..a5440bd3b4 100644 --- a/include/core/SkImageGenerator.h +++ b/include/core/SkImageGenerator.h @@ -15,6 +15,8 @@ class SkBitmap; class SkData; class SkImageGenerator; +//#define SK_SUPPORT_LEGACY_OPTIONLESS_GET_PIXELS + /** * Takes ownership of SkImageGenerator. If this method fails for * whatever reason, it will return false and immediatetely delete @@ -117,6 +119,34 @@ public: }; /** + * Whether or not the memory passed to getPixels is zero initialized. + */ + enum ZeroInitialized { + /** + * The memory passed to getPixels is zero initialized. The SkCodec + * may take advantage of this by skipping writing zeroes. + */ + kYes_ZeroInitialized, + /** + * The memory passed to getPixels has not been initialized to zero, + * so the SkCodec must write all zeroes to memory. + * + * This is the default. It will be used if no Options struct is used. + */ + kNo_ZeroInitialized, + }; + + /** + * Additional options to pass to getPixels. + */ + struct Options { + Options() + : fZeroInitialized(kNo_ZeroInitialized) {} + + ZeroInitialized fZeroInitialized; + }; + + /** * Decode into the given pixels, a block of memory of size at * least (info.fHeight - 1) * rowBytes + (info.fWidth * * bytesPerPixel) @@ -145,11 +175,12 @@ public: * * @return Result kSuccess, or another value explaining the type of failure. */ - Result getPixels(const SkImageInfo& info, void* pixels, size_t rowBytes, + Result getPixels(const SkImageInfo& info, void* pixels, size_t rowBytes, const Options*, SkPMColor ctable[], int* ctableCount); /** - * Simplified version of getPixels() that asserts that info is NOT kIndex8_SkColorType. + * Simplified version of getPixels() that asserts that info is NOT kIndex8_SkColorType and + * uses the default Options. */ Result getPixels(const SkImageInfo& info, void* pixels, size_t rowBytes); @@ -177,9 +208,14 @@ public: protected: virtual SkData* onRefEncodedData(); virtual bool onGetInfo(SkImageInfo* info); +#ifdef SK_SUPPORT_LEGACY_OPTIONLESS_GET_PIXELS virtual Result onGetPixels(const SkImageInfo& info, void* pixels, size_t rowBytes, SkPMColor ctable[], int* ctableCount); +#endif + virtual Result onGetPixels(const SkImageInfo& info, + void* pixels, size_t rowBytes, const Options&, + SkPMColor ctable[], int* ctableCount); virtual bool onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBytes[3]); virtual bool onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBytes[3], SkYUVColorSpace* colorSpace); |