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

Unified Diff: include/core/SkImageDecoder.h

Issue 24269006: Add an option on SkImageDecoder to skip writing 0s. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 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
Index: include/core/SkImageDecoder.h
diff --git a/include/core/SkImageDecoder.h b/include/core/SkImageDecoder.h
index a8cbe6341332e4efcffe751589736c7b67d01758..16216c8ccbce70b5894d88b2bf39d56a511d3dd0 100644
--- a/include/core/SkImageDecoder.h
+++ b/include/core/SkImageDecoder.h
@@ -59,6 +59,23 @@ public:
*/
const char* getFormatName() const;
+ /** Whether the decoder should skip writing zeroes to output if possible.
+ */
+ bool getSkipWritingZeroes() const { return fSkipWritingZeroes; }
+
+ /** Set to true if the decoder should skip writing any zeroes when
+ creating the output image.
+ This is a hint that may not be respected by the decoder.
+ It should only be used if it is known that the memory to write
+ to has already been set to 0; otherwise the resulting image will
+ have garbage.
+ This is ideal for images that contain a lot of completely transparent
+ pixels, but may be a performance hit for an image that has only a
+ few transparent pixels.
+ The default is false.
+ */
+ void setSkipWritingZeroes(bool skip) { fSkipWritingZeroes = skip; }
+
/** Returns true if the decoder should try to dither the resulting image.
The default setting is true.
*/
@@ -507,6 +524,7 @@ private:
PrefConfigTable fPrefTable; // use if fUsePrefTable is true
bool fDitherImage;
bool fUsePrefTable;
+ bool fSkipWritingZeroes;
mutable bool fShouldCancelDecode;
bool fPreferQualityOverSpeed;
bool fRequireUnpremultipliedColors;

Powered by Google App Engine
This is Rietveld 408576698