OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2008 The Android Open Source Project | 2 * Copyright 2008 The Android Open Source Project |
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 SkPixelRef_DEFINED | 8 #ifndef SkPixelRef_DEFINED |
9 #define SkPixelRef_DEFINED | 9 #define SkPixelRef_DEFINED |
10 | 10 |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 */ | 225 */ |
226 bool decodeInto(int pow2, SkBitmap* bitmap) { | 226 bool decodeInto(int pow2, SkBitmap* bitmap) { |
227 SkASSERT(pow2 >= 0); | 227 SkASSERT(pow2 >= 0); |
228 return this->onDecodeInto(pow2, bitmap); | 228 return this->onDecodeInto(pow2, bitmap); |
229 } | 229 } |
230 | 230 |
231 /** Are we really wrapping a texture instead of a bitmap? | 231 /** Are we really wrapping a texture instead of a bitmap? |
232 */ | 232 */ |
233 virtual GrTexture* getTexture() { return NULL; } | 233 virtual GrTexture* getTexture() { return NULL; } |
234 | 234 |
| 235 #ifdef SK_SUPPORT_LEGACY_IMAGEGENERATOR_YUV_API |
235 /** | 236 /** |
236 * If any planes or rowBytes is NULL, this should output the sizes and retu
rn true | 237 * If any planes or rowBytes is NULL, this should output the sizes and retu
rn true |
237 * if it can efficiently return YUV planar data. If it cannot, it should re
turn false. | 238 * if it can efficiently return YUV planar data. If it cannot, it should re
turn false. |
238 * | 239 * |
239 * If all planes and rowBytes are not NULL, then it should copy the associa
ted Y,U,V data | 240 * If all planes and rowBytes are not NULL, then it should copy the associa
ted Y,U,V data |
240 * into those planes of memory supplied by the caller. It should validate t
hat the sizes | 241 * into those planes of memory supplied by the caller. It should validate t
hat the sizes |
241 * match what it expected. If the sizes do not match, it should return fals
e. | 242 * match what it expected. If the sizes do not match, it should return fals
e. |
242 * | 243 * |
243 * If colorSpace is not NULL, the YUV color space of the data should be sto
red in the address | 244 * If colorSpace is not NULL, the YUV color space of the data should be sto
red in the address |
244 * it points at. | 245 * it points at. |
245 */ | 246 */ |
246 bool getYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBytes[3], | 247 bool getYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBytes[3], |
247 SkYUVColorSpace* colorSpace) { | 248 SkYUVColorSpace* colorSpace) { |
248 return this->onGetYUV8Planes(sizes, planes, rowBytes, colorSpace); | 249 return this->onGetYUV8Planes(sizes, planes, rowBytes, colorSpace); |
249 } | 250 } |
| 251 #endif |
| 252 |
| 253 /** |
| 254 * If this pixelref supports returning planar YUV data, return true, and re
turn |
| 255 * the logicalSizes (if not NULL) and the optimalAllocationSizes (if not NU
LL), where each |
| 256 * array represents [0]=Y, [1]=U, [2]=V |
| 257 * |
| 258 * The optimalAllocationSizes may be the same as the logicalSizes, but they
may also be larger |
| 259 * if that will aid the pixelref (for performance). |
| 260 * |
| 261 * If this returns false, the value of the (optional) sizes parameters is u
ndefined. |
| 262 */ |
| 263 bool queryYUV8(SkISize logicalSizes[3], SkISize optimalAllocationSizes[3]) { |
| 264 return this->onQueryYUV8(logicalSizes, optimalAllocationSizes); |
| 265 } |
| 266 |
| 267 /** |
| 268 * If this pixelref supports returning planar YUV data, and can fulfill the
requested |
| 269 * sizes for each plane, return true and write the YUV data into the planes
. |
| 270 * |
| 271 * Calling queryYUV8() will return both the logical sizes (W/H) and the opt
imal-allocation |
| 272 * sizes for the 3 planes. For getYUV8(), tt is legal to pass the logical s
izes |
| 273 * (though smaller than those will return false). However, this may |
| 274 * (depending on the implementation) be slower than passing in the optimal-
allocation sizes |
| 275 * (or larger). The extra space may allow the implementation to run faster
at the cost of |
| 276 * slightly more ram being allocated. There should be no performance penalt
y for the |
| 277 * allocationSizes to larger than the values in optimalAllocationSizes, as
they are just the |
| 278 * minimum sizes for best performance. |
| 279 * |
| 280 * If colorSpace is not NULL, return the corresponding colorSpace for the Y
UV data. |
| 281 */ |
| 282 bool getYUV8(const SkISize allocationSizes[3], void* planes[3], SkYUVColorSp
ace* colorSpace) { |
| 283 return this->onGetYUV8(allocationSizes, planes, colorSpace); |
| 284 } |
250 | 285 |
251 bool readPixels(SkBitmap* dst, const SkIRect* subset = NULL); | 286 bool readPixels(SkBitmap* dst, const SkIRect* subset = NULL); |
252 | 287 |
253 /** | 288 /** |
254 * Makes a deep copy of this PixelRef, respecting the requested config. | 289 * Makes a deep copy of this PixelRef, respecting the requested config. |
255 * @param colorType Desired colortype. | 290 * @param colorType Desired colortype. |
256 * @param profileType Desired colorprofiletype. | 291 * @param profileType Desired colorprofiletype. |
257 * @param subset Subset of this PixelRef to copy. Must be fully contained w
ithin the bounds of | 292 * @param subset Subset of this PixelRef to copy. Must be fully contained w
ithin the bounds of |
258 * of this PixelRef. | 293 * of this PixelRef. |
259 * @return A new SkPixelRef, or NULL if either there is an error (e.g. the
destination could | 294 * @return A new SkPixelRef, or NULL if either there is an error (e.g. the
destination could |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 * For pixelrefs that don't have access to their raw pixels, they may be | 363 * For pixelrefs that don't have access to their raw pixels, they may be |
329 * able to make a copy of them (e.g. if the pixels are on the GPU). | 364 * able to make a copy of them (e.g. if the pixels are on the GPU). |
330 * | 365 * |
331 * The base class implementation returns false; | 366 * The base class implementation returns false; |
332 */ | 367 */ |
333 virtual bool onReadPixels(SkBitmap* dst, const SkIRect* subsetOrNull); | 368 virtual bool onReadPixels(SkBitmap* dst, const SkIRect* subsetOrNull); |
334 | 369 |
335 // default impl returns NULL. | 370 // default impl returns NULL. |
336 virtual SkData* onRefEncodedData(); | 371 virtual SkData* onRefEncodedData(); |
337 | 372 |
338 // default impl returns false. | 373 virtual bool onQueryYUV8(SkISize logicalSizes[3], SkISize optimalAllocationS
izes[3]) { |
| 374 return false; |
| 375 } |
| 376 |
| 377 virtual bool onGetYUV8(const SkISize sizes[3], void* planes[3], SkYUVColorSp
ace*) { |
| 378 return false; |
| 379 } |
| 380 |
| 381 #ifdef SK_SUPPORT_LEGACY_IMAGEGENERATOR_YUV_API |
339 virtual bool onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBy
tes[3], | 382 virtual bool onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBy
tes[3], |
340 SkYUVColorSpace* colorSpace); | 383 SkYUVColorSpace* colorSpace) { |
| 384 return false; |
| 385 } |
| 386 #endif |
341 | 387 |
342 /** | 388 /** |
343 * Returns the size (in bytes) of the internally allocated memory. | 389 * Returns the size (in bytes) of the internally allocated memory. |
344 * This should be implemented in all serializable SkPixelRef derived classe
s. | 390 * This should be implemented in all serializable SkPixelRef derived classe
s. |
345 * SkBitmap::fPixelRefOffset + SkBitmap::getSafeSize() should never overflo
w this value, | 391 * SkBitmap::fPixelRefOffset + SkBitmap::getSafeSize() should never overflo
w this value, |
346 * otherwise the rendering code may attempt to read memory out of bounds. | 392 * otherwise the rendering code may attempt to read memory out of bounds. |
347 * | 393 * |
348 * @return default impl returns 0. | 394 * @return default impl returns 0. |
349 */ | 395 */ |
350 virtual size_t getAllocatedSizeInBytes() const; | 396 virtual size_t getAllocatedSizeInBytes() const; |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
402 /** | 448 /** |
403 * Allocate a new pixelref matching the specified ImageInfo, allocating | 449 * Allocate a new pixelref matching the specified ImageInfo, allocating |
404 * the memory for the pixels. If the ImageInfo requires a ColorTable, | 450 * the memory for the pixels. If the ImageInfo requires a ColorTable, |
405 * the pixelref will ref() the colortable. | 451 * the pixelref will ref() the colortable. |
406 * On failure return NULL. | 452 * On failure return NULL. |
407 */ | 453 */ |
408 virtual SkPixelRef* create(const SkImageInfo&, size_t rowBytes, SkColorTable
*) = 0; | 454 virtual SkPixelRef* create(const SkImageInfo&, size_t rowBytes, SkColorTable
*) = 0; |
409 }; | 455 }; |
410 | 456 |
411 #endif | 457 #endif |
OLD | NEW |