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

Side by Side 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, 2 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « bench/SkipZeroesBench.cpp ('k') | src/images/SkImageDecoder.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2006 The Android Open Source Project 3 * Copyright 2006 The Android Open Source Project
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 #ifndef SkImageDecoder_DEFINED 10 #ifndef SkImageDecoder_DEFINED
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 static Format GetStreamFormat(SkStreamRewindable*); 53 static Format GetStreamFormat(SkStreamRewindable*);
54 54
55 /** Return a readable string of the Format provided. 55 /** Return a readable string of the Format provided.
56 */ 56 */
57 static const char* GetFormatName(Format); 57 static const char* GetFormatName(Format);
58 58
59 /** Return a readable string of the value returned by getFormat(). 59 /** Return a readable string of the value returned by getFormat().
60 */ 60 */
61 const char* getFormatName() const; 61 const char* getFormatName() const;
62 62
63 /** Whether the decoder should skip writing zeroes to output if possible.
64 */
65 bool getSkipWritingZeroes() const { return fSkipWritingZeroes; }
66
67 /** Set to true if the decoder should skip writing any zeroes when
68 creating the output image.
69 This is a hint that may not be respected by the decoder.
70 It should only be used if it is known that the memory to write
71 to has already been set to 0; otherwise the resulting image will
72 have garbage.
73 This is ideal for images that contain a lot of completely transparent
74 pixels, but may be a performance hit for an image that has only a
75 few transparent pixels.
76 The default is false.
77 */
78 void setSkipWritingZeroes(bool skip) { fSkipWritingZeroes = skip; }
79
63 /** Returns true if the decoder should try to dither the resulting image. 80 /** Returns true if the decoder should try to dither the resulting image.
64 The default setting is true. 81 The default setting is true.
65 */ 82 */
66 bool getDitherImage() const { return fDitherImage; } 83 bool getDitherImage() const { return fDitherImage; }
67 84
68 /** Set to true if the the decoder should try to dither the resulting image. 85 /** Set to true if the the decoder should try to dither the resulting image.
69 The default setting is true. 86 The default setting is true.
70 */ 87 */
71 void setDitherImage(bool dither) { fDitherImage = dither; } 88 void setDitherImage(bool dither) { fDitherImage = dither; }
72 89
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 518
502 private: 519 private:
503 Peeker* fPeeker; 520 Peeker* fPeeker;
504 Chooser* fChooser; 521 Chooser* fChooser;
505 SkBitmap::Allocator* fAllocator; 522 SkBitmap::Allocator* fAllocator;
506 int fSampleSize; 523 int fSampleSize;
507 SkBitmap::Config fDefaultPref; // use if fUsePrefTable is false 524 SkBitmap::Config fDefaultPref; // use if fUsePrefTable is false
508 PrefConfigTable fPrefTable; // use if fUsePrefTable is true 525 PrefConfigTable fPrefTable; // use if fUsePrefTable is true
509 bool fDitherImage; 526 bool fDitherImage;
510 bool fUsePrefTable; 527 bool fUsePrefTable;
528 bool fSkipWritingZeroes;
511 mutable bool fShouldCancelDecode; 529 mutable bool fShouldCancelDecode;
512 bool fPreferQualityOverSpeed; 530 bool fPreferQualityOverSpeed;
513 bool fRequireUnpremultipliedColors; 531 bool fRequireUnpremultipliedColors;
514 }; 532 };
515 533
516 /** Calling newDecoder with a stream returns a new matching imagedecoder 534 /** Calling newDecoder with a stream returns a new matching imagedecoder
517 instance, or NULL if none can be found. The caller must manage its ownership 535 instance, or NULL if none can be found. The caller must manage its ownership
518 of the stream as usual, calling unref() when it is done, as the returned 536 of the stream as usual, calling unref() when it is done, as the returned
519 decoder may have called ref() (and if so, the decoder is responsible for 537 decoder may have called ref() (and if so, the decoder is responsible for
520 balancing its ownership when it is destroyed). 538 balancing its ownership when it is destroyed).
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 DECLARE_DECODER_CREATOR(WBMPImageDecoder); 577 DECLARE_DECODER_CREATOR(WBMPImageDecoder);
560 DECLARE_DECODER_CREATOR(WEBPImageDecoder); 578 DECLARE_DECODER_CREATOR(WEBPImageDecoder);
561 579
562 580
563 // Typedefs to make registering decoder and formatter callbacks easier. 581 // Typedefs to make registering decoder and formatter callbacks easier.
564 // These have to be defined outside SkImageDecoder. :( 582 // These have to be defined outside SkImageDecoder. :(
565 typedef SkTRegistry<SkImageDecoder*(*)(SkStreamRewindable*)> SkImageDecod er_DecodeReg; 583 typedef SkTRegistry<SkImageDecoder*(*)(SkStreamRewindable*)> SkImageDecod er_DecodeReg;
566 typedef SkTRegistry<SkImageDecoder::Format(*)(SkStreamRewindable*)> SkImageDecod er_FormatReg; 584 typedef SkTRegistry<SkImageDecoder::Format(*)(SkStreamRewindable*)> SkImageDecod er_FormatReg;
567 585
568 #endif 586 #endif
OLDNEW
« 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