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

Side by Side Diff: include/core/SkImageDecoder.h

Issue 331433003: hide SkImageDecoder::Chooser (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 6 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
« no previous file with comments | « no previous file | src/images/SkImageDecoder.cpp » ('j') | src/images/SkImageDecoder_libico.cpp » ('J')
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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 will cause the decoder to not return the image. 130 will cause the decoder to not return the image.
131 */ 131 */
132 virtual bool peek(const char tag[], const void* data, size_t length) = 0 ; 132 virtual bool peek(const char tag[], const void* data, size_t length) = 0 ;
133 private: 133 private:
134 typedef SkRefCnt INHERITED; 134 typedef SkRefCnt INHERITED;
135 }; 135 };
136 136
137 Peeker* getPeeker() const { return fPeeker; } 137 Peeker* getPeeker() const { return fPeeker; }
138 Peeker* setPeeker(Peeker*); 138 Peeker* setPeeker(Peeker*);
139 139
140 #ifdef SK_SUPPORT_LEGACY_IMAGEDECODER_CHOOSER
140 /** \class Chooser 141 /** \class Chooser
141 142
142 Base class for optional callbacks to choose an image from a format that 143 Base class for optional callbacks to choose an image from a format that
143 contains multiple images. 144 contains multiple images.
144 */ 145 */
145 class Chooser : public SkRefCnt { 146 class Chooser : public SkRefCnt {
146 public: 147 public:
147 SK_DECLARE_INST_COUNT(Chooser) 148 SK_DECLARE_INST_COUNT(Chooser)
148 149
149 virtual void begin(int count) {} 150 virtual void begin(int count) {}
150 virtual void inspect(int index, SkBitmap::Config config, int width, int height) {} 151 virtual void inspect(int index, SkBitmap::Config config, int width, int height) {}
151 /** Return the index of the subimage you want, or -1 to choose none of t hem. 152 /** Return the index of the subimage you want, or -1 to choose none of t hem.
152 */ 153 */
153 virtual int choose() = 0; 154 virtual int choose() = 0;
154 155
155 private: 156 private:
156 typedef SkRefCnt INHERITED; 157 typedef SkRefCnt INHERITED;
157 }; 158 };
158 159
159 Chooser* getChooser() const { return fChooser; } 160 Chooser* getChooser() const { return fChooser; }
160 Chooser* setChooser(Chooser*); 161 Chooser* setChooser(Chooser*);
162 #endif
161 163
162 /** 164 /**
163 * Optional table describing the caller's preferred config based on 165 * Optional table describing the caller's preferred config based on
164 * information about the src data. Each field should be set to the 166 * information about the src data. Each field should be set to the
165 * preferred config for a src described in the name of the field. The 167 * preferred config for a src described in the name of the field. The
166 * src attributes are described in terms of depth (8-index, 168 * src attributes are described in terms of depth (8-index,
167 * 8bit-grayscale, or 8-bits/component) and whether there is per-pixel 169 * 8bit-grayscale, or 8-bits/component) and whether there is per-pixel
168 * alpha (does not apply to grayscale). If the caller has no preference 170 * alpha (does not apply to grayscale). If the caller has no preference
169 * for a particular src type, its slot should be set to kNo_Config. 171 * for a particular src type, its slot should be set to kNo_Config.
170 * 172 *
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 431
430 Calling this outside of onDecode() may return undefined values. 432 Calling this outside of onDecode() may return undefined values.
431 */ 433 */
432 434
433 public: 435 public:
434 bool shouldCancelDecode() const { return fShouldCancelDecode; } 436 bool shouldCancelDecode() const { return fShouldCancelDecode; }
435 437
436 protected: 438 protected:
437 SkImageDecoder(); 439 SkImageDecoder();
438 440
441 #ifdef SK_SUPPORT_LEGACY_IMAGEDECODER_CHOOSER
439 // helper function for decoders to handle the (common) case where there is o nly 442 // helper function for decoders to handle the (common) case where there is o nly
440 // once choice available in the image file. 443 // once choice available in the image file.
441 bool chooseFromOneChoice(SkColorType, int width, int height) const; 444 bool chooseFromOneChoice(SkColorType, int width, int height) const;
445 #endif
442 446
443 /* Helper for subclasses. Call this to allocate the pixel memory given the bitmap's 447 /* Helper for subclasses. Call this to allocate the pixel memory given the bitmap's
444 width/height/rowbytes/config. Returns true on success. This method handl es checking 448 width/height/rowbytes/config. Returns true on success. This method handl es checking
445 for an optional Allocator. 449 for an optional Allocator.
446 */ 450 */
447 bool allocPixelRef(SkBitmap*, SkColorTable*) const; 451 bool allocPixelRef(SkBitmap*, SkColorTable*) const;
448 452
449 /** 453 /**
450 * The raw data of the src image. 454 * The raw data of the src image.
451 */ 455 */
(...skipping 10 matching lines...) Expand all
462 src image. This routine returns the caller's preference given 466 src image. This routine returns the caller's preference given
463 srcDepth and hasAlpha, or kUnknown_SkColorType if there is no preference . 467 srcDepth and hasAlpha, or kUnknown_SkColorType if there is no preference .
464 468
465 Note: this also takes into account GetDeviceConfig(), so the subclass 469 Note: this also takes into account GetDeviceConfig(), so the subclass
466 need not call that. 470 need not call that.
467 */ 471 */
468 SkColorType getPrefColorType(SrcDepth, bool hasAlpha) const; 472 SkColorType getPrefColorType(SrcDepth, bool hasAlpha) const;
469 473
470 private: 474 private:
471 Peeker* fPeeker; 475 Peeker* fPeeker;
476 #ifdef SK_SUPPORT_LEGACY_IMAGEDECODER_CHOOSER
472 Chooser* fChooser; 477 Chooser* fChooser;
478 #endif
473 SkBitmap::Allocator* fAllocator; 479 SkBitmap::Allocator* fAllocator;
474 int fSampleSize; 480 int fSampleSize;
475 SkBitmap::Config fDefaultPref; // use if fUsePrefTable is false 481 SkBitmap::Config fDefaultPref; // use if fUsePrefTable is false
476 PrefConfigTable fPrefTable; // use if fUsePrefTable is true 482 PrefConfigTable fPrefTable; // use if fUsePrefTable is true
477 bool fDitherImage; 483 bool fDitherImage;
478 bool fUsePrefTable; 484 bool fUsePrefTable;
479 bool fSkipWritingZeroes; 485 bool fSkipWritingZeroes;
480 mutable bool fShouldCancelDecode; 486 mutable bool fShouldCancelDecode;
481 bool fPreferQualityOverSpeed; 487 bool fPreferQualityOverSpeed;
482 bool fRequireUnpremultipliedColors; 488 bool fRequireUnpremultipliedColors;
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
529 DECLARE_DECODER_CREATOR(WEBPImageDecoder); 535 DECLARE_DECODER_CREATOR(WEBPImageDecoder);
530 DECLARE_DECODER_CREATOR(PKMImageDecoder); 536 DECLARE_DECODER_CREATOR(PKMImageDecoder);
531 DECLARE_DECODER_CREATOR(KTXImageDecoder); 537 DECLARE_DECODER_CREATOR(KTXImageDecoder);
532 538
533 // Typedefs to make registering decoder and formatter callbacks easier. 539 // Typedefs to make registering decoder and formatter callbacks easier.
534 // These have to be defined outside SkImageDecoder. :( 540 // These have to be defined outside SkImageDecoder. :(
535 typedef SkTRegistry<SkImageDecoder*(*)(SkStreamRewindable*)> SkImageDecod er_DecodeReg; 541 typedef SkTRegistry<SkImageDecoder*(*)(SkStreamRewindable*)> SkImageDecod er_DecodeReg;
536 typedef SkTRegistry<SkImageDecoder::Format(*)(SkStreamRewindable*)> SkImageDecod er_FormatReg; 542 typedef SkTRegistry<SkImageDecoder::Format(*)(SkStreamRewindable*)> SkImageDecod er_FormatReg;
537 543
538 #endif 544 #endif
OLDNEW
« no previous file with comments | « no previous file | src/images/SkImageDecoder.cpp » ('j') | src/images/SkImageDecoder_libico.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698