OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright 2013 Google Inc. |
| 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. |
| 6 */ |
| 7 |
| 8 #ifndef SkImageGenerator_DEFINED |
| 9 #define SkImageGenerator_DEFINED |
| 10 |
| 11 #include "SkImageInfo.h" |
| 12 |
| 13 class SkData; |
| 14 |
| 15 /** |
| 16 * An interface that allows a purgeable PixelRef (such as a |
| 17 * SkDiscardablePixelRef) to decode and re-decode an image as needed. |
| 18 */ |
| 19 class SkImageGenerator { |
| 20 public: |
| 21 /** |
| 22 * The PixelRef which takes ownership of this SkImageGenerator |
| 23 * will call the image generator's destructor. |
| 24 */ |
| 25 virtual ~SkImageGenerator() { } |
| 26 |
| 27 /** |
| 28 * Return a ref to the encoded (i.e. compressed) representation, |
| 29 * of this data. |
| 30 * |
| 31 * If non-NULL is returned, the caller is responsible for calling |
| 32 * unref() on the data when it is finished. |
| 33 */ |
| 34 virtual SkData* refEncodedData() { return NULL; } |
| 35 |
| 36 /** |
| 37 * Return some information about the image, allowing the owner of |
| 38 * this object to allocate pixels. |
| 39 * |
| 40 * @return false if anything goes wrong. |
| 41 */ |
| 42 virtual bool getInfo(SkImageInfo* info) = 0; |
| 43 |
| 44 /** |
| 45 * Decode into the given pixels, a block of memory of size at |
| 46 * least (info.fHeight - 1) * rowBytes + (info.fWidth * |
| 47 * bytesPerPixel) |
| 48 * |
| 49 * @param info A description of the format (config, size) |
| 50 * expected by the caller. This can simply be identical |
| 51 * to the info returned by getInfo(). |
| 52 * |
| 53 * This contract also allows the caller to specify |
| 54 * different output-configs, which the implementation can |
| 55 * decide to support or not. |
| 56 * |
| 57 * @return false if anything goes wrong or if the image info is |
| 58 * unsupported. |
| 59 */ |
| 60 virtual bool getPixels(const SkImageInfo& info, |
| 61 void* pixels, |
| 62 size_t rowBytes) = 0; |
| 63 }; |
| 64 |
| 65 #endif // SkImageGenerator_DEFINED |
OLD | NEW |