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 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 /** | 58 /** |
59 * Return a ref to the encoded (i.e. compressed) representation, | 59 * Return a ref to the encoded (i.e. compressed) representation, |
60 * of this data. | 60 * of this data. |
61 * | 61 * |
62 * If non-NULL is returned, the caller is responsible for calling | 62 * If non-NULL is returned, the caller is responsible for calling |
63 * unref() on the data when it is finished. | 63 * unref() on the data when it is finished. |
64 */ | 64 */ |
65 SkData* refEncodedData() { return this->onRefEncodedData(); } | 65 SkData* refEncodedData() { return this->onRefEncodedData(); } |
66 | 66 |
67 /** | 67 /** |
68 * Return some information about the image, allowing the owner of | 68 * Return the ImageInfo associated with this generator. |
69 * this object to allocate pixels. | |
70 * | |
71 * Repeated calls to this function should give the same results, | |
72 * allowing the PixelRef to be immutable. | |
73 * | |
74 * @return false if anything goes wrong. | |
75 */ | 69 */ |
76 bool getInfo(SkImageInfo* info); | 70 #ifdef SK_SUPPORT_LEGACY_BOOL_ONGETINFO |
| 71 SkImageInfo getInfo(); |
| 72 bool getInfo(SkImageInfo* info) { |
| 73 if (info) { |
| 74 *info = this->getInfo(); |
| 75 } |
| 76 return true; |
| 77 } |
| 78 #else |
| 79 const SkImageInfo& getInfo() const { return fInfo; } |
| 80 #endif |
77 | 81 |
78 /** | 82 /** |
79 * Used to describe the result of a call to getPixels(). | 83 * Used to describe the result of a call to getPixels(). |
80 * | 84 * |
81 * Result is the union of possible results from subclasses. | 85 * Result is the union of possible results from subclasses. |
82 */ | 86 */ |
83 enum Result { | 87 enum Result { |
84 /** | 88 /** |
85 * General return value for success. | 89 * General return value for success. |
86 */ | 90 */ |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 SkYUVColorSpace* colorSpace); | 203 SkYUVColorSpace* colorSpace); |
200 | 204 |
201 /** | 205 /** |
202 * If the default image decoder system can interpret the specified (encoded
) data, then | 206 * If the default image decoder system can interpret the specified (encoded
) data, then |
203 * this returns a new ImageGenerator for it. Otherwise this returns NULL. E
ither way | 207 * this returns a new ImageGenerator for it. Otherwise this returns NULL. E
ither way |
204 * the caller is still responsible for managing their ownership of the data
. | 208 * the caller is still responsible for managing their ownership of the data
. |
205 */ | 209 */ |
206 static SkImageGenerator* NewFromData(SkData*); | 210 static SkImageGenerator* NewFromData(SkData*); |
207 | 211 |
208 protected: | 212 protected: |
| 213 #ifdef SK_SUPPORT_LEGACY_BOOL_ONGETINFO |
| 214 SkImageGenerator() : fInfo(SkImageInfo::MakeUnknown(0, 0) ) {} |
| 215 virtual bool onGetInfo(SkImageInfo* info); |
| 216 #endif |
| 217 SkImageGenerator(const SkImageInfo& info) : fInfo(info) {} |
| 218 |
209 virtual SkData* onRefEncodedData(); | 219 virtual SkData* onRefEncodedData(); |
210 virtual bool onGetInfo(SkImageInfo* info); | 220 |
211 #ifdef SK_SUPPORT_LEGACY_OPTIONLESS_GET_PIXELS | 221 #ifdef SK_SUPPORT_LEGACY_OPTIONLESS_GET_PIXELS |
212 virtual Result onGetPixels(const SkImageInfo& info, | 222 virtual Result onGetPixels(const SkImageInfo& info, |
213 void* pixels, size_t rowBytes, | 223 void* pixels, size_t rowBytes, |
214 SkPMColor ctable[], int* ctableCount); | 224 SkPMColor ctable[], int* ctableCount); |
215 #endif | 225 #endif |
216 virtual Result onGetPixels(const SkImageInfo& info, | 226 virtual Result onGetPixels(const SkImageInfo& info, |
217 void* pixels, size_t rowBytes, const Options&, | 227 void* pixels, size_t rowBytes, const Options&, |
218 SkPMColor ctable[], int* ctableCount); | 228 SkPMColor ctable[], int* ctableCount); |
219 virtual bool onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBy
tes[3]); | 229 virtual bool onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBy
tes[3]); |
220 virtual bool onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBy
tes[3], | 230 virtual bool onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBy
tes[3], |
221 SkYUVColorSpace* colorSpace); | 231 SkYUVColorSpace* colorSpace); |
| 232 |
| 233 private: |
| 234 const SkImageInfo fInfo; |
222 }; | 235 }; |
223 | 236 |
224 #endif // SkImageGenerator_DEFINED | 237 #endif // SkImageGenerator_DEFINED |
OLD | NEW |