From 9552662e9fee5eb0ef435e52ab9db505d7ebe4ad Mon Sep 17 00:00:00 2001 From: scroggo Date: Tue, 17 Mar 2015 05:02:17 -0700 Subject: 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 --- include/core/SkImageGenerator.h | 40 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) (limited to 'include/core/SkImageGenerator.h') 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 @@ -116,6 +118,34 @@ public: kUnimplemented, }; + /** + * 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 * @@ -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); -- cgit v1.2.3