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

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: 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 unified diff | Download patch | Annotate | Revision Log
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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 static Format GetStreamFormat(SkStream*); 52 static Format GetStreamFormat(SkStream*);
53 53
54 /** Return a readable string of the Format provided. 54 /** Return a readable string of the Format provided.
55 */ 55 */
56 static const char* GetFormatName(Format); 56 static const char* GetFormatName(Format);
57 57
58 /** Return a readable string of the value returned by getFormat(). 58 /** Return a readable string of the value returned by getFormat().
59 */ 59 */
60 const char* getFormatName() const; 60 const char* getFormatName() const;
61 61
62 /** Whether the decoder should skip writing zeroes to output if possible.
63 */
64 bool getSkipWritingZeroes() const { return fSkipWritingZeroes; }
65
66 /** Set to true if the decoder should skip writing any zeroes when
67 creating the output image.
68 This is a hint that may not be respected by the decoder.
69 It should only be used if it is known that the memory to write
70 to has already been set to 0; otherwise the resulting image will
71 have garbage.
72 This is ideal for images that contain a lot of completely transparent
73 pixels, but may be a performance hit for an image that has only a
74 few transparent pixels.
75 The default is false.
76 */
77 void setSkipWritingZeroes(bool skip) { fSkipWritingZeroes = skip; }
78
62 /** Returns true if the decoder should try to dither the resulting image. 79 /** Returns true if the decoder should try to dither the resulting image.
63 The default setting is true. 80 The default setting is true.
64 */ 81 */
65 bool getDitherImage() const { return fDitherImage; } 82 bool getDitherImage() const { return fDitherImage; }
66 83
67 /** Set to true if the the decoder should try to dither the resulting image. 84 /** Set to true if the the decoder should try to dither the resulting image.
68 The default setting is true. 85 The default setting is true.
69 */ 86 */
70 void setDitherImage(bool dither) { fDitherImage = dither; } 87 void setDitherImage(bool dither) { fDitherImage = dither; }
71 88
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 517
501 private: 518 private:
502 Peeker* fPeeker; 519 Peeker* fPeeker;
503 Chooser* fChooser; 520 Chooser* fChooser;
504 SkBitmap::Allocator* fAllocator; 521 SkBitmap::Allocator* fAllocator;
505 int fSampleSize; 522 int fSampleSize;
506 SkBitmap::Config fDefaultPref; // use if fUsePrefTable is false 523 SkBitmap::Config fDefaultPref; // use if fUsePrefTable is false
507 PrefConfigTable fPrefTable; // use if fUsePrefTable is true 524 PrefConfigTable fPrefTable; // use if fUsePrefTable is true
508 bool fDitherImage; 525 bool fDitherImage;
509 bool fUsePrefTable; 526 bool fUsePrefTable;
527 bool fSkipWritingZeroes;
510 mutable bool fShouldCancelDecode; 528 mutable bool fShouldCancelDecode;
511 bool fPreferQualityOverSpeed; 529 bool fPreferQualityOverSpeed;
512 bool fRequireUnpremultipliedColors; 530 bool fRequireUnpremultipliedColors;
513 }; 531 };
514 532
515 /** Calling newDecoder with a stream returns a new matching imagedecoder 533 /** Calling newDecoder with a stream returns a new matching imagedecoder
516 instance, or NULL if none can be found. The caller must manage its ownership 534 instance, or NULL if none can be found. The caller must manage its ownership
517 of the stream as usual, calling unref() when it is done, as the returned 535 of the stream as usual, calling unref() when it is done, as the returned
518 decoder may have called ref() (and if so, the decoder is responsible for 536 decoder may have called ref() (and if so, the decoder is responsible for
519 balancing its ownership when it is destroyed). 537 balancing its ownership when it is destroyed).
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 DECLARE_DECODER_CREATOR(WBMPImageDecoder); 576 DECLARE_DECODER_CREATOR(WBMPImageDecoder);
559 DECLARE_DECODER_CREATOR(WEBPImageDecoder); 577 DECLARE_DECODER_CREATOR(WEBPImageDecoder);
560 578
561 579
562 // Typedefs to make registering decoder and formatter callbacks easier. 580 // Typedefs to make registering decoder and formatter callbacks easier.
563 // These have to be defined outside SkImageDecoder. :( 581 // These have to be defined outside SkImageDecoder. :(
564 typedef SkTRegistry<SkImageDecoder*(*)(SkStream*)> SkImageDecoder_DecodeR eg; 582 typedef SkTRegistry<SkImageDecoder*(*)(SkStream*)> SkImageDecoder_DecodeR eg;
565 typedef SkTRegistry<SkImageDecoder::Format(*)(SkStream*)> SkImageDecoder_FormatR eg; 583 typedef SkTRegistry<SkImageDecoder::Format(*)(SkStream*)> SkImageDecoder_FormatR eg;
566 584
567 #endif 585 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698