| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
| 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 SkDecodingImageGenerator_DEFINED | 8 #ifndef SkDecodingImageGenerator_DEFINED |
| 9 #define SkDecodingImageGenerator_DEFINED | 9 #define SkDecodingImageGenerator_DEFINED |
| 10 | 10 |
| 11 #include "SkDiscardableMemory.h" |
| 11 #include "SkImageGenerator.h" | 12 #include "SkImageGenerator.h" |
| 12 | 13 |
| 13 class SkBitmap; | 14 class SkBitmap; |
| 14 | 15 |
| 15 /** | 16 /** |
| 16 * Calls into SkImageDecoder::DecodeMemoryToTarget to implement a | 17 * Calls into SkImageDecoder::DecodeMemoryToTarget to implement a |
| 17 * SkImageGenerator | 18 * SkImageGenerator |
| 18 */ | 19 */ |
| 19 class SkDecodingImageGenerator : public SkImageGenerator { | 20 class SkDecodingImageGenerator : public SkImageGenerator { |
| 20 public: | 21 public: |
| 21 /* | 22 /* |
| 22 * The constructor will take a reference to the SkData. The | 23 * The constructor will take a reference to the SkData. The |
| 23 * destructor will unref() it. | 24 * destructor will unref() it. |
| 24 */ | 25 */ |
| 25 SkDecodingImageGenerator(SkData* data); | 26 SkDecodingImageGenerator(SkData* data); |
| 26 virtual ~SkDecodingImageGenerator(); | 27 virtual ~SkDecodingImageGenerator(); |
| 27 | 28 |
| 28 virtual SkData* refEncodedData() SK_OVERRIDE; | 29 virtual SkData* refEncodedData() SK_OVERRIDE; |
| 29 | 30 |
| 30 virtual bool getInfo(SkImageInfo* info) SK_OVERRIDE; | 31 virtual bool getInfo(SkImageInfo* info) SK_OVERRIDE; |
| 31 | 32 |
| 32 virtual bool getPixels(const SkImageInfo& info, | 33 virtual bool getPixels(const SkImageInfo& info, |
| 33 void* pixels, | 34 void* pixels, |
| 34 size_t rowBytes) SK_OVERRIDE; | 35 size_t rowBytes) SK_OVERRIDE; |
| 35 | 36 |
| 36 /** | 37 /** |
| 37 * Install the SkData into the destination bitmap, using a new | 38 * Install the SkData into the destination bitmap, using a new |
| 38 * SkDiscardablePixelRef and a new SkDecodingImageGenerator. | 39 * SkDiscardablePixelRef and a new SkDecodingImageGenerator. |
| 40 * |
| 41 * @param data Contains the encoded image data that will be used |
| 42 * by the SkDecodingImageGenerator. Will be ref()ed. |
| 43 * |
| 44 * @param destination Upon success, this bitmap will be |
| 45 * configured and have a pixelref installed. |
| 46 * |
| 47 * @param factory If not NULL, this object will be used as a |
| 48 * source of discardable memory when decoding. If NULL, then |
| 49 * SkDiscardableMemory::Create() will be called. |
| 50 * |
| 51 * @return true iff successful. |
| 39 */ | 52 */ |
| 40 static bool Install(SkData* data, SkBitmap* destination); | 53 static bool Install(SkData* data, SkBitmap* destination, |
| 54 SkDiscardableMemory::Factory* factory = NULL); |
| 41 | 55 |
| 42 private: | 56 private: |
| 43 SkData* fData; | 57 SkData* fData; |
| 44 }; | 58 }; |
| 45 #endif // SkDecodingImageGenerator_DEFINED | 59 #endif // SkDecodingImageGenerator_DEFINED |
| OLD | NEW |