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 SkImageGenerator_DEFINED | 8 #ifndef SkImageGenerator_DEFINED |
9 #define SkImageGenerator_DEFINED | 9 #define SkImageGenerator_DEFINED |
10 | 10 |
| 11 #include "SkDiscardableMemory.h" |
11 #include "SkImageInfo.h" | 12 #include "SkImageInfo.h" |
12 | 13 |
| 14 class SkBitmap; |
13 class SkData; | 15 class SkData; |
| 16 class SkImageGenerator; |
| 17 |
| 18 /** |
| 19 * Takes ownership of SkImageGenerator. If this method fails for |
| 20 * whatever reason, it will return false and immediatetely delete |
| 21 * the generator. If it succeeds, it will modify destination |
| 22 * bitmap. |
| 23 * |
| 24 * If this fails or when the SkDiscardablePixelRef that is |
| 25 * installed into destination is destroyed, it will call |
| 26 * SkDELETE() on the generator. Therefore, generator should be |
| 27 * allocated with SkNEW() or SkNEW_ARGS(). |
| 28 * |
| 29 * @param destination Upon success, this bitmap will be |
| 30 * configured and have a pixelref installed. |
| 31 * |
| 32 * @param factory If not NULL, this object will be used as a |
| 33 * source of discardable memory when decoding. If NULL, then |
| 34 * SkDiscardableMemory::Create() will be called. |
| 35 * |
| 36 * @return true iff successful. |
| 37 */ |
| 38 SK_API bool SkInstallDiscardablePixelRef(SkImageGenerator* generator, |
| 39 SkBitmap* destination, |
| 40 SkDiscardableMemory::Factory* factory =
NULL); |
| 41 |
14 | 42 |
15 /** | 43 /** |
16 * An interface that allows a purgeable PixelRef (such as a | 44 * An interface that allows a purgeable PixelRef (such as a |
17 * SkDiscardablePixelRef) to decode and re-decode an image as needed. | 45 * SkDiscardablePixelRef) to decode and re-decode an image as needed. |
18 */ | 46 */ |
19 class SkImageGenerator { | 47 class SK_API SkImageGenerator { |
20 public: | 48 public: |
21 /** | 49 /** |
22 * The PixelRef which takes ownership of this SkImageGenerator | 50 * The PixelRef which takes ownership of this SkImageGenerator |
23 * will call the image generator's destructor. | 51 * will call the image generator's destructor. |
24 */ | 52 */ |
25 virtual ~SkImageGenerator() { } | 53 virtual ~SkImageGenerator() { } |
26 | 54 |
27 /** | 55 /** |
28 * Return a ref to the encoded (i.e. compressed) representation, | 56 * Return a ref to the encoded (i.e. compressed) representation, |
29 * of this data. | 57 * of this data. |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 * | 90 * |
63 * @return false if anything goes wrong or if the image info is | 91 * @return false if anything goes wrong or if the image info is |
64 * unsupported. | 92 * unsupported. |
65 */ | 93 */ |
66 virtual bool getPixels(const SkImageInfo& info, | 94 virtual bool getPixels(const SkImageInfo& info, |
67 void* pixels, | 95 void* pixels, |
68 size_t rowBytes) = 0; | 96 size_t rowBytes) = 0; |
69 }; | 97 }; |
70 | 98 |
71 #endif // SkImageGenerator_DEFINED | 99 #endif // SkImageGenerator_DEFINED |
OLD | NEW |