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