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

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: Rebase, plus update the benchmark 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
« no previous file with comments | « bench/SkipZeroesBench.cpp ('k') | src/images/SkImageDecoder.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/core/SkImageDecoder.h
diff --git a/include/core/SkImageDecoder.h b/include/core/SkImageDecoder.h
index bff749538f9176ea1eb644efbdda04cf2b53d00c..eac2157708354c80940a4d674b83b4811e410f6d 100644
--- a/include/core/SkImageDecoder.h
+++ b/include/core/SkImageDecoder.h
@@ -60,6 +60,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.
*/
@@ -508,6 +525,7 @@ private:
PrefConfigTable fPrefTable; // use if fUsePrefTable is true
bool fDitherImage;
bool fUsePrefTable;
+ bool fSkipWritingZeroes;
mutable bool fShouldCancelDecode;
bool fPreferQualityOverSpeed;
bool fRequireUnpremultipliedColors;
« no previous file with comments | « bench/SkipZeroesBench.cpp ('k') | src/images/SkImageDecoder.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698