| 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 |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 will cause the decoder to not return the image. | 110 will cause the decoder to not return the image. |
| 111 */ | 111 */ |
| 112 virtual bool peek(const char tag[], const void* data, size_t length) = 0
; | 112 virtual bool peek(const char tag[], const void* data, size_t length) = 0
; |
| 113 private: | 113 private: |
| 114 typedef SkRefCnt INHERITED; | 114 typedef SkRefCnt INHERITED; |
| 115 }; | 115 }; |
| 116 | 116 |
| 117 Peeker* getPeeker() const { return fPeeker; } | 117 Peeker* getPeeker() const { return fPeeker; } |
| 118 Peeker* setPeeker(Peeker*); | 118 Peeker* setPeeker(Peeker*); |
| 119 | 119 |
| 120 /** \class Peeker | 120 /** \class Chooser |
| 121 | 121 |
| 122 Base class for optional callbacks to retrieve meta/chunk data out of | 122 Base class for optional callbacks to choose an image from a format that |
| 123 an image as it is being decoded. | 123 contains multiple images. |
| 124 */ | 124 */ |
| 125 class Chooser : public SkRefCnt { | 125 class Chooser : public SkRefCnt { |
| 126 public: | 126 public: |
| 127 SK_DECLARE_INST_COUNT(Chooser) | 127 SK_DECLARE_INST_COUNT(Chooser) |
| 128 | 128 |
| 129 virtual void begin(int count) {} | 129 virtual void begin(int count) {} |
| 130 virtual void inspect(int index, SkBitmap::Config config, int width, int
height) {} | 130 virtual void inspect(int index, SkBitmap::Config config, int width, int
height) {} |
| 131 /** Return the index of the subimage you want, or -1 to choose none of t
hem. | 131 /** Return the index of the subimage you want, or -1 to choose none of t
hem. |
| 132 */ | 132 */ |
| 133 virtual int choose() = 0; | 133 virtual int choose() = 0; |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 If the decoder can decompress the image, it calls bitmap.setConfig(), | 212 If the decoder can decompress the image, it calls bitmap.setConfig(), |
| 213 and then if the Mode is kDecodePixels_Mode, call allocPixelRef(), | 213 and then if the Mode is kDecodePixels_Mode, call allocPixelRef(), |
| 214 which will allocated a pixelRef. To access the pixel memory, the codec | 214 which will allocated a pixelRef. To access the pixel memory, the codec |
| 215 needs to call lockPixels/unlockPixels on the | 215 needs to call lockPixels/unlockPixels on the |
| 216 bitmap. It can then set the pixels with the decompressed image. | 216 bitmap. It can then set the pixels with the decompressed image. |
| 217 * If the image cannot be decompressed, return false. After the | 217 * If the image cannot be decompressed, return false. After the |
| 218 * decoding, the function converts the decoded config in bitmap | 218 * decoding, the function converts the decoded config in bitmap |
| 219 * to pref if possible. Whether a conversion is feasible is | 219 * to pref if possible. Whether a conversion is feasible is |
| 220 * tested by Bitmap::canCopyTo(pref). | 220 * tested by Bitmap::canCopyTo(pref). |
| 221 | 221 |
| 222 note: document use of Allocator, Peeker and Chooser | 222 If an SkBitmap::Allocator is installed via setAllocator, it will be |
| 223 used to allocate the pixel memory. A clever allocator can be used |
| 224 to allocate the memory from a cache, volatile memory, or even from |
| 225 an existing bitmap's memory. |
| 226 |
| 227 If a Peeker is installed via setPeeker, it may be used to peek into |
| 228 meta data during the decode. |
| 229 |
| 230 If a Chooser is installed via setChooser, it may be used to select |
| 231 which image to return from a format that contains multiple images. |
| 223 */ | 232 */ |
| 224 bool decode(SkStream*, SkBitmap* bitmap, SkBitmap::Config pref, Mode, bool r
euseBitmap = false); | 233 bool decode(SkStream*, SkBitmap* bitmap, SkBitmap::Config pref, Mode); |
| 225 bool decode(SkStream* stream, SkBitmap* bitmap, Mode mode, bool reuseBitmap
= false) { | 234 bool decode(SkStream* stream, SkBitmap* bitmap, Mode mode) { |
| 226 return this->decode(stream, bitmap, SkBitmap::kNo_Config, mode, reuseBit
map); | 235 return this->decode(stream, bitmap, SkBitmap::kNo_Config, mode); |
| 227 } | 236 } |
| 228 | 237 |
| 229 /** | 238 /** |
| 230 * Given a stream, build an index for doing tile-based decode. | 239 * Given a stream, build an index for doing tile-based decode. |
| 231 * The built index will be saved in the decoder, and the image size will | 240 * The built index will be saved in the decoder, and the image size will |
| 232 * be returned in width and height. | 241 * be returned in width and height. |
| 233 * | 242 * |
| 234 * Return true for success or false on failure. | 243 * Return true for success or false on failure. |
| 235 */ | 244 */ |
| 236 bool buildTileIndex(SkStream*, int *width, int *height); | 245 bool buildTileIndex(SkStream*, int *width, int *height); |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 491 // not all of these will be available | 500 // not all of these will be available |
| 492 DECLARE_DECODER_CREATOR(BMPImageDecoder); | 501 DECLARE_DECODER_CREATOR(BMPImageDecoder); |
| 493 DECLARE_DECODER_CREATOR(GIFImageDecoder); | 502 DECLARE_DECODER_CREATOR(GIFImageDecoder); |
| 494 DECLARE_DECODER_CREATOR(ICOImageDecoder); | 503 DECLARE_DECODER_CREATOR(ICOImageDecoder); |
| 495 DECLARE_DECODER_CREATOR(JPEGImageDecoder); | 504 DECLARE_DECODER_CREATOR(JPEGImageDecoder); |
| 496 DECLARE_DECODER_CREATOR(PNGImageDecoder); | 505 DECLARE_DECODER_CREATOR(PNGImageDecoder); |
| 497 DECLARE_DECODER_CREATOR(WBMPImageDecoder); | 506 DECLARE_DECODER_CREATOR(WBMPImageDecoder); |
| 498 DECLARE_DECODER_CREATOR(WEBPImageDecoder); | 507 DECLARE_DECODER_CREATOR(WEBPImageDecoder); |
| 499 | 508 |
| 500 #endif | 509 #endif |
| OLD | NEW |