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

Unified Diff: include/core/SkImageGenerator.h

Issue 980903002: Option for SkCodec to treat dst as all zeroes. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Update SkBmpCodec to use new ZeroInitialized API. Created 5 years, 9 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/codec/SkCodec.h ('k') | src/codec/SkCodec_libbmp.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/core/SkImageGenerator.h
diff --git a/include/core/SkImageGenerator.h b/include/core/SkImageGenerator.h
index 5de9d3d85ace1d64a1cf2b7a3e3c1b412b6a2b68..a5440bd3b4d88011bb70dee991a28c2c1c61771c 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);
« no previous file with comments | « include/codec/SkCodec.h ('k') | src/codec/SkCodec_libbmp.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698