| OLD | NEW |
| 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 |
| 11 #define SkImageDecoder_DEFINED | 11 #define SkImageDecoder_DEFINED |
| 12 | 12 |
| 13 #include "SkBitmap.h" | 13 #include "SkBitmap.h" |
| 14 #include "SkBitmapFactory.h" | 14 #include "SkBitmapFactory.h" |
| 15 #include "SkImage.h" | 15 #include "SkImage.h" |
| 16 #include "SkRect.h" | 16 #include "SkRect.h" |
| 17 #include "SkRefCnt.h" | 17 #include "SkRefCnt.h" |
| 18 | 18 |
| 19 class SkStream; | 19 class SkStream; |
| 20 | 20 |
| 21 /** \class SkImageDecoder | 21 /** \class SkImageDecoder |
| 22 | 22 |
| 23 Base class for decoding compressed images into a SkBitmap | 23 Base class for decoding compressed images into a SkBitmap |
| 24 */ | 24 */ |
| 25 class SkImageDecoder { | 25 class SkImageDecoder { |
| 26 public: | 26 public: |
| 27 virtual ~SkImageDecoder(); | 27 virtual ~SkImageDecoder(); |
| 28 | 28 |
| 29 // Should be consistent with sFormatName | |
| 30 enum Format { | 29 enum Format { |
| 31 kUnknown_Format, | 30 kUnknown_Format, |
| 32 kBMP_Format, | 31 kBMP_Format, |
| 33 kGIF_Format, | 32 kGIF_Format, |
| 34 kICO_Format, | 33 kICO_Format, |
| 35 kJPEG_Format, | 34 kJPEG_Format, |
| 36 kPNG_Format, | 35 kPNG_Format, |
| 37 kWBMP_Format, | 36 kWBMP_Format, |
| 38 kWEBP_Format, | 37 kWEBP_Format, |
| 39 | 38 |
| 40 kLastKnownFormat = kWEBP_Format | 39 kLastKnownFormat = kWEBP_Format, |
| 41 }; | 40 }; |
| 42 | 41 |
| 43 /** Return the format of image this decoder can decode. If this decoder can
decode multiple | 42 /** Return the format of image this decoder can decode. If this decoder can
decode multiple |
| 44 formats, kUnknown_Format will be returned. | 43 formats, kUnknown_Format will be returned. |
| 45 */ | 44 */ |
| 46 virtual Format getFormat() const; | 45 virtual Format getFormat() const; |
| 47 | 46 |
| 47 /** Return the format of the SkStream or kUnknown_Format if it cannot be det
ermined. Rewinds the |
| 48 stream before returning. |
| 49 */ |
| 50 static Format GetStreamFormat(SkStream*); |
| 51 |
| 48 /** Return a readable string of the value returned by getFormat(). | 52 /** Return a readable string of the value returned by getFormat(). |
| 49 */ | 53 */ |
| 50 const char* getFormatName() const; | 54 const char* getFormatName() const; |
| 51 | 55 |
| 52 /** Returns true if the decoder should try to dither the resulting image. | 56 /** Returns true if the decoder should try to dither the resulting image. |
| 53 The default setting is true. | 57 The default setting is true. |
| 54 */ | 58 */ |
| 55 bool getDitherImage() const { return fDitherImage; } | 59 bool getDitherImage() const { return fDitherImage; } |
| 56 | 60 |
| 57 /** Set to true if the the decoder should try to dither the resulting image. | 61 /** Set to true if the the decoder should try to dither the resulting image. |
| (...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 409 Chooser* fChooser; | 413 Chooser* fChooser; |
| 410 SkBitmap::Allocator* fAllocator; | 414 SkBitmap::Allocator* fAllocator; |
| 411 int fSampleSize; | 415 int fSampleSize; |
| 412 SkBitmap::Config fDefaultPref; // use if fUsePrefTable is false | 416 SkBitmap::Config fDefaultPref; // use if fUsePrefTable is false |
| 413 SkBitmap::Config fPrefTable[6]; // use if fUsePrefTable is true | 417 SkBitmap::Config fPrefTable[6]; // use if fUsePrefTable is true |
| 414 bool fDitherImage; | 418 bool fDitherImage; |
| 415 bool fUsePrefTable; | 419 bool fUsePrefTable; |
| 416 mutable bool fShouldCancelDecode; | 420 mutable bool fShouldCancelDecode; |
| 417 bool fPreferQualityOverSpeed; | 421 bool fPreferQualityOverSpeed; |
| 418 | 422 |
| 419 /** Contains the image format name. | |
| 420 * This should be consistent with Format. | |
| 421 * | |
| 422 * The format name gives a more meaningful error message than enum. | |
| 423 */ | |
| 424 static const char* sFormatName[]; | |
| 425 | |
| 426 // illegal | 423 // illegal |
| 427 SkImageDecoder(const SkImageDecoder&); | 424 SkImageDecoder(const SkImageDecoder&); |
| 428 SkImageDecoder& operator=(const SkImageDecoder&); | 425 SkImageDecoder& operator=(const SkImageDecoder&); |
| 429 }; | 426 }; |
| 430 | 427 |
| 431 /** Calling newDecoder with a stream returns a new matching imagedecoder | 428 /** Calling newDecoder with a stream returns a new matching imagedecoder |
| 432 instance, or NULL if none can be found. The caller must manage its ownership | 429 instance, or NULL if none can be found. The caller must manage its ownership |
| 433 of the stream as usual, calling unref() when it is done, as the returned | 430 of the stream as usual, calling unref() when it is done, as the returned |
| 434 decoder may have called ref() (and if so, the decoder is responsible for | 431 decoder may have called ref() (and if so, the decoder is responsible for |
| 435 balancing its ownership when it is destroyed). | 432 balancing its ownership when it is destroyed). |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 468 // not all of these will be available | 465 // not all of these will be available |
| 469 DECLARE_DECODER_CREATOR(BMPImageDecoder); | 466 DECLARE_DECODER_CREATOR(BMPImageDecoder); |
| 470 DECLARE_DECODER_CREATOR(GIFImageDecoder); | 467 DECLARE_DECODER_CREATOR(GIFImageDecoder); |
| 471 DECLARE_DECODER_CREATOR(ICOImageDecoder); | 468 DECLARE_DECODER_CREATOR(ICOImageDecoder); |
| 472 DECLARE_DECODER_CREATOR(JPEGImageDecoder); | 469 DECLARE_DECODER_CREATOR(JPEGImageDecoder); |
| 473 DECLARE_DECODER_CREATOR(PNGImageDecoder); | 470 DECLARE_DECODER_CREATOR(PNGImageDecoder); |
| 474 DECLARE_DECODER_CREATOR(WBMPImageDecoder); | 471 DECLARE_DECODER_CREATOR(WBMPImageDecoder); |
| 475 DECLARE_DECODER_CREATOR(WEBPImageDecoder); | 472 DECLARE_DECODER_CREATOR(WEBPImageDecoder); |
| 476 | 473 |
| 477 #endif | 474 #endif |
| OLD | NEW |