OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef SkImageDecoder_DEFINED | 8 #ifndef SkImageDecoder_DEFINED |
9 #define SkImageDecoder_DEFINED | 9 #define SkImageDecoder_DEFINED |
10 | 10 |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 */ | 126 */ |
127 bool getRequireUnpremultipliedColors() const { return fRequireUnpremultiplie
dColors; } | 127 bool getRequireUnpremultipliedColors() const { return fRequireUnpremultiplie
dColors; } |
128 | 128 |
129 /** \class Peeker | 129 /** \class Peeker |
130 | 130 |
131 Base class for optional callbacks to retrieve meta/chunk data out of | 131 Base class for optional callbacks to retrieve meta/chunk data out of |
132 an image as it is being decoded. | 132 an image as it is being decoded. |
133 */ | 133 */ |
134 class Peeker : public SkRefCnt { | 134 class Peeker : public SkRefCnt { |
135 public: | 135 public: |
136 SK_DECLARE_INST_COUNT(Peeker) | |
137 | |
138 /** Return true to continue decoding, or false to indicate an error, whi
ch | 136 /** Return true to continue decoding, or false to indicate an error, whi
ch |
139 will cause the decoder to not return the image. | 137 will cause the decoder to not return the image. |
140 */ | 138 */ |
141 virtual bool peek(const char tag[], const void* data, size_t length) = 0
; | 139 virtual bool peek(const char tag[], const void* data, size_t length) = 0
; |
142 private: | 140 private: |
143 typedef SkRefCnt INHERITED; | 141 typedef SkRefCnt INHERITED; |
144 }; | 142 }; |
145 | 143 |
146 Peeker* getPeeker() const { return fPeeker; } | 144 Peeker* getPeeker() const { return fPeeker; } |
147 Peeker* setPeeker(Peeker*); | 145 Peeker* setPeeker(Peeker*); |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 public: | 367 public: |
370 bool shouldCancelDecode() const { return fShouldCancelDecode; } | 368 bool shouldCancelDecode() const { return fShouldCancelDecode; } |
371 | 369 |
372 protected: | 370 protected: |
373 SkImageDecoder(); | 371 SkImageDecoder(); |
374 | 372 |
375 /** | 373 /** |
376 * Return the default preference being used by the current or latest call t
o decode. | 374 * Return the default preference being used by the current or latest call t
o decode. |
377 */ | 375 */ |
378 SkColorType getDefaultPref() { return fDefaultPref; } | 376 SkColorType getDefaultPref() { return fDefaultPref; } |
379 | 377 |
380 /* Helper for subclasses. Call this to allocate the pixel memory given the
bitmap's info. | 378 /* Helper for subclasses. Call this to allocate the pixel memory given the
bitmap's info. |
381 Returns true on success. This method handles checking for an optional Al
locator. | 379 Returns true on success. This method handles checking for an optional Al
locator. |
382 */ | 380 */ |
383 bool allocPixelRef(SkBitmap*, SkColorTable*) const; | 381 bool allocPixelRef(SkBitmap*, SkColorTable*) const; |
384 | 382 |
385 /** | 383 /** |
386 * The raw data of the src image. | 384 * The raw data of the src image. |
387 */ | 385 */ |
388 enum SrcDepth { | 386 enum SrcDepth { |
389 // Color-indexed. | 387 // Color-indexed. |
(...skipping 24 matching lines...) Expand all Loading... |
414 }; | 412 }; |
415 | 413 |
416 /** Calling newDecoder with a stream returns a new matching imagedecoder | 414 /** Calling newDecoder with a stream returns a new matching imagedecoder |
417 instance, or NULL if none can be found. The caller must manage its ownership | 415 instance, or NULL if none can be found. The caller must manage its ownership |
418 of the stream as usual, calling unref() when it is done, as the returned | 416 of the stream as usual, calling unref() when it is done, as the returned |
419 decoder may have called ref() (and if so, the decoder is responsible for | 417 decoder may have called ref() (and if so, the decoder is responsible for |
420 balancing its ownership when it is destroyed). | 418 balancing its ownership when it is destroyed). |
421 */ | 419 */ |
422 class SkImageDecoderFactory : public SkRefCnt { | 420 class SkImageDecoderFactory : public SkRefCnt { |
423 public: | 421 public: |
424 SK_DECLARE_INST_COUNT(SkImageDecoderFactory) | 422 |
425 | 423 |
426 virtual SkImageDecoder* newDecoder(SkStreamRewindable*) = 0; | 424 virtual SkImageDecoder* newDecoder(SkStreamRewindable*) = 0; |
427 | 425 |
428 private: | 426 private: |
429 typedef SkRefCnt INHERITED; | 427 typedef SkRefCnt INHERITED; |
430 }; | 428 }; |
431 | 429 |
432 class SkDefaultImageDecoderFactory : SkImageDecoderFactory { | 430 class SkDefaultImageDecoderFactory : SkImageDecoderFactory { |
433 public: | 431 public: |
434 // calls SkImageDecoder::Factory(stream) | 432 // calls SkImageDecoder::Factory(stream) |
(...skipping 26 matching lines...) Expand all Loading... |
461 DECLARE_DECODER_CREATOR(PKMImageDecoder); | 459 DECLARE_DECODER_CREATOR(PKMImageDecoder); |
462 DECLARE_DECODER_CREATOR(KTXImageDecoder); | 460 DECLARE_DECODER_CREATOR(KTXImageDecoder); |
463 DECLARE_DECODER_CREATOR(ASTCImageDecoder); | 461 DECLARE_DECODER_CREATOR(ASTCImageDecoder); |
464 | 462 |
465 // Typedefs to make registering decoder and formatter callbacks easier. | 463 // Typedefs to make registering decoder and formatter callbacks easier. |
466 // These have to be defined outside SkImageDecoder. :( | 464 // These have to be defined outside SkImageDecoder. :( |
467 typedef SkTRegistry<SkImageDecoder*(*)(SkStreamRewindable*)> SkImageDecod
er_DecodeReg; | 465 typedef SkTRegistry<SkImageDecoder*(*)(SkStreamRewindable*)> SkImageDecod
er_DecodeReg; |
468 typedef SkTRegistry<SkImageDecoder::Format(*)(SkStreamRewindable*)> SkImageDecod
er_FormatReg; | 466 typedef SkTRegistry<SkImageDecoder::Format(*)(SkStreamRewindable*)> SkImageDecod
er_FormatReg; |
469 | 467 |
470 #endif | 468 #endif |
OLD | NEW |