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 "SkBitmap.h" | 11 #include "SkBitmap.h" |
12 #include "SkColor.h" | 12 #include "SkColor.h" |
13 #include "SkImageInfo.h" | 13 #include "SkImageInfo.h" |
| 14 #include "SkYUVSizeInfo.h" |
14 | 15 |
15 class GrContext; | 16 class GrContext; |
16 class GrTexture; | 17 class GrTexture; |
17 class GrTextureParams; | 18 class GrTextureParams; |
18 class SkBitmap; | 19 class SkBitmap; |
19 class SkData; | 20 class SkData; |
20 class SkImageGenerator; | 21 class SkImageGenerator; |
21 class SkMatrix; | 22 class SkMatrix; |
22 class SkPaint; | 23 class SkPaint; |
23 class SkPicture; | 24 class SkPicture; |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 bool getPixels(const SkImageInfo& info, void* pixels, size_t rowBytes, | 123 bool getPixels(const SkImageInfo& info, void* pixels, size_t rowBytes, |
123 SkPMColor ctable[], int* ctableCount); | 124 SkPMColor ctable[], int* ctableCount); |
124 | 125 |
125 /** | 126 /** |
126 * Simplified version of getPixels() that asserts that info is NOT kIndex8_
SkColorType and | 127 * Simplified version of getPixels() that asserts that info is NOT kIndex8_
SkColorType and |
127 * uses the default Options. | 128 * uses the default Options. |
128 */ | 129 */ |
129 bool getPixels(const SkImageInfo& info, void* pixels, size_t rowBytes); | 130 bool getPixels(const SkImageInfo& info, void* pixels, size_t rowBytes); |
130 | 131 |
131 /** | 132 /** |
132 * If planes or rowBytes is NULL or if any entry in planes is NULL or if an
y entry in rowBytes | 133 * If decoding to YUV is supported, this returns true. Otherwise, this |
133 * is 0, this imagegenerator should output the sizes and return true if it
can efficiently | 134 * returns false and does not modify any of the parameters. |
134 * return YUV planar data. If it cannot, it should return false. Note that
either planes and | |
135 * rowBytes are both fully defined and non NULL/non 0 or they are both NULL
or have NULL or 0 | |
136 * entries only. Having only partial planes/rowBytes information is not sup
ported. | |
137 * | 135 * |
138 * If all planes and rowBytes entries are non NULL or non 0, then it should
copy the | 136 * @param sizeInfo Output parameter indicating the sizes and required |
139 * associated YUV data into those planes of memory supplied by the caller.
It should validate | 137 * allocation widths of the Y, U, and V planes. |
140 * that the sizes match what it expected. If the sizes do not match, it sho
uld return false. | 138 * @param colorSpace Output parameter. |
141 */ | 139 */ |
142 bool getYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBytes[3], | 140 bool queryYUV8(SkYUVSizeInfo* sizeInfo, SkYUVColorSpace* colorSpace) const; |
143 SkYUVColorSpace* colorSpace); | 141 |
| 142 /** |
| 143 * Returns true on success and false on failure. |
| 144 * This always attempts to perform a full decode. If the client only |
| 145 * wants size, it should call queryYUV8(). |
| 146 * |
| 147 * @param sizeInfo Needs to exactly match the values returned by the |
| 148 * query, except the WidthBytes may be larger than the |
| 149 * recommendation (but not smaller). |
| 150 * @param planes Memory for each of the Y, U, and V planes. |
| 151 */ |
| 152 bool getYUV8Planes(const SkYUVSizeInfo& sizeInfo, void* planes[3]); |
144 | 153 |
145 /** | 154 /** |
146 * If the generator can natively/efficiently return its pixels as a GPU ima
ge (backed by a | 155 * If the generator can natively/efficiently return its pixels as a GPU ima
ge (backed by a |
147 * texture) this will return that image. If not, this will return NULL. | 156 * texture) this will return that image. If not, this will return NULL. |
148 * | 157 * |
149 * Regarding the GrContext parameter: | 158 * Regarding the GrContext parameter: |
150 * | 159 * |
151 * The caller may pass NULL for the context. In that case the generator may
assume that its | 160 * The caller may pass NULL for the context. In that case the generator may
assume that its |
152 * internal context is current. If it has no internal context, then it shou
ld just return | 161 * internal context is current. If it has no internal context, then it shou
ld just return |
153 * null. | 162 * null. |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 } | 250 } |
242 } | 251 } |
243 | 252 |
244 protected: | 253 protected: |
245 SkImageGenerator(const SkImageInfo& info); | 254 SkImageGenerator(const SkImageInfo& info); |
246 | 255 |
247 virtual SkData* onRefEncodedData(SK_REFENCODEDDATA_CTXPARAM); | 256 virtual SkData* onRefEncodedData(SK_REFENCODEDDATA_CTXPARAM); |
248 | 257 |
249 virtual bool onGetPixels(const SkImageInfo& info, void* pixels, size_t rowBy
tes, | 258 virtual bool onGetPixels(const SkImageInfo& info, void* pixels, size_t rowBy
tes, |
250 SkPMColor ctable[], int* ctableCount); | 259 SkPMColor ctable[], int* ctableCount); |
251 virtual bool onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBy
tes[3]); | 260 |
252 virtual bool onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBy
tes[3], | 261 virtual bool onQueryYUV8(SkYUVSizeInfo*, SkYUVColorSpace*) const { |
253 SkYUVColorSpace* colorSpace); | 262 return false; |
| 263 } |
| 264 virtual bool onGetYUV8Planes(const SkYUVSizeInfo&, void*[3] /*planes*/) { |
| 265 return false; |
| 266 } |
254 | 267 |
255 virtual GrTexture* onGenerateTexture(GrContext*, const SkIRect*) { | 268 virtual GrTexture* onGenerateTexture(GrContext*, const SkIRect*) { |
256 return nullptr; | 269 return nullptr; |
257 } | 270 } |
258 | 271 |
259 virtual bool onComputeScaledDimensions(SkScalar, SupportedSizes*) { | 272 virtual bool onComputeScaledDimensions(SkScalar, SupportedSizes*) { |
260 return false; | 273 return false; |
261 } | 274 } |
262 virtual bool onGenerateScaledPixels(const SkISize&, const SkIPoint&, const S
kPixmap&) { | 275 virtual bool onGenerateScaledPixels(const SkISize&, const SkIPoint&, const S
kPixmap&) { |
263 return false; | 276 return false; |
264 } | 277 } |
265 | 278 |
266 bool tryGenerateBitmap(SkBitmap* bm, const SkImageInfo* optionalInfo, SkBitm
ap::Allocator*); | 279 bool tryGenerateBitmap(SkBitmap* bm, const SkImageInfo* optionalInfo, SkBitm
ap::Allocator*); |
267 | 280 |
268 private: | 281 private: |
269 const SkImageInfo fInfo; | 282 const SkImageInfo fInfo; |
270 const uint32_t fUniqueID; | 283 const uint32_t fUniqueID; |
271 | 284 |
272 // This is our default impl, which may be different on different platforms. | 285 // This is our default impl, which may be different on different platforms. |
273 // It is called from NewFromEncoded() after it has checked for any runtime f
actory. | 286 // It is called from NewFromEncoded() after it has checked for any runtime f
actory. |
274 // The SkData will never be NULL, as that will have been checked by NewFromE
ncoded. | 287 // The SkData will never be NULL, as that will have been checked by NewFromE
ncoded. |
275 static SkImageGenerator* NewFromEncodedImpl(SkData*); | 288 static SkImageGenerator* NewFromEncodedImpl(SkData*); |
276 }; | 289 }; |
277 | 290 |
278 #endif // SkImageGenerator_DEFINED | 291 #endif // SkImageGenerator_DEFINED |
OLD | NEW |