| 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 |
| 11 #include "SkBitmap.h" | 11 #include "SkBitmap.h" |
| 12 #include "SkDynamicAnnotations.h" | 12 #include "SkDynamicAnnotations.h" |
| 13 #include "SkRefCnt.h" | 13 #include "SkRefCnt.h" |
| 14 #include "SkString.h" | 14 #include "SkString.h" |
| 15 #include "SkImageInfo.h" | 15 #include "SkImageInfo.h" |
| 16 #include "SkSize.h" |
| 16 #include "SkTDArray.h" | 17 #include "SkTDArray.h" |
| 17 | 18 |
| 18 //#define xed | 19 //#define xed |
| 19 | 20 |
| 20 #ifdef SK_DEBUG | 21 #ifdef SK_DEBUG |
| 21 /** | 22 /** |
| 22 * Defining SK_IGNORE_PIXELREF_SETPRELOCKED will force all pixelref | 23 * Defining SK_IGNORE_PIXELREF_SETPRELOCKED will force all pixelref |
| 23 * subclasses to correctly handle lock/unlock pixels. For performance | 24 * subclasses to correctly handle lock/unlock pixels. For performance |
| 24 * reasons, simple malloc-based subclasses call setPreLocked() to skip | 25 * reasons, simple malloc-based subclasses call setPreLocked() to skip |
| 25 * the overhead of implementing these calls. | 26 * the overhead of implementing these calls. |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 */ | 213 */ |
| 213 bool decodeInto(int pow2, SkBitmap* bitmap) { | 214 bool decodeInto(int pow2, SkBitmap* bitmap) { |
| 214 SkASSERT(pow2 >= 0); | 215 SkASSERT(pow2 >= 0); |
| 215 return this->onDecodeInto(pow2, bitmap); | 216 return this->onDecodeInto(pow2, bitmap); |
| 216 } | 217 } |
| 217 | 218 |
| 218 /** Are we really wrapping a texture instead of a bitmap? | 219 /** Are we really wrapping a texture instead of a bitmap? |
| 219 */ | 220 */ |
| 220 virtual GrTexture* getTexture() { return NULL; } | 221 virtual GrTexture* getTexture() { return NULL; } |
| 221 | 222 |
| 223 /** |
| 224 * If any planes or rowBytes is NULL, this should output the sizes and retu
rn true |
| 225 * if it can efficiently return YUV planar data. If it cannot, it should re
turn false. |
| 226 * |
| 227 * If all planes and rowBytes are not NULL, then it should copy the associa
ted Y,U,V data |
| 228 * into those planes of memory supplied by the caller. It should validate t
hat the sizes |
| 229 * match what it expected. If the sizes do not match, it should return fals
e. |
| 230 */ |
| 231 bool getYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBytes[3]) { |
| 232 return this->onGetYUV8Planes(sizes, planes, rowBytes); |
| 233 } |
| 234 |
| 222 bool readPixels(SkBitmap* dst, const SkIRect* subset = NULL); | 235 bool readPixels(SkBitmap* dst, const SkIRect* subset = NULL); |
| 223 | 236 |
| 224 /** | 237 /** |
| 225 * Makes a deep copy of this PixelRef, respecting the requested config. | 238 * Makes a deep copy of this PixelRef, respecting the requested config. |
| 226 * @param colorType Desired colortype. | 239 * @param colorType Desired colortype. |
| 227 * @param subset Subset of this PixelRef to copy. Must be fully contained w
ithin the bounds of | 240 * @param subset Subset of this PixelRef to copy. Must be fully contained w
ithin the bounds of |
| 228 * of this PixelRef. | 241 * of this PixelRef. |
| 229 * @return A new SkPixelRef, or NULL if either there is an error (e.g. the
destination could | 242 * @return A new SkPixelRef, or NULL if either there is an error (e.g. the
destination could |
| 230 * not be created with the given config), or this PixelRef does not
support deep | 243 * not be created with the given config), or this PixelRef does not
support deep |
| 231 * copies. | 244 * copies. |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 * For pixelrefs that don't have access to their raw pixels, they may be | 311 * For pixelrefs that don't have access to their raw pixels, they may be |
| 299 * able to make a copy of them (e.g. if the pixels are on the GPU). | 312 * able to make a copy of them (e.g. if the pixels are on the GPU). |
| 300 * | 313 * |
| 301 * The base class implementation returns false; | 314 * The base class implementation returns false; |
| 302 */ | 315 */ |
| 303 virtual bool onReadPixels(SkBitmap* dst, const SkIRect* subsetOrNull); | 316 virtual bool onReadPixels(SkBitmap* dst, const SkIRect* subsetOrNull); |
| 304 | 317 |
| 305 // default impl returns NULL. | 318 // default impl returns NULL. |
| 306 virtual SkData* onRefEncodedData(); | 319 virtual SkData* onRefEncodedData(); |
| 307 | 320 |
| 321 // default impl returns false. |
| 322 virtual bool onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBy
tes[3]); |
| 323 |
| 308 /** | 324 /** |
| 309 * Returns the size (in bytes) of the internally allocated memory. | 325 * Returns the size (in bytes) of the internally allocated memory. |
| 310 * This should be implemented in all serializable SkPixelRef derived classe
s. | 326 * This should be implemented in all serializable SkPixelRef derived classe
s. |
| 311 * SkBitmap::fPixelRefOffset + SkBitmap::getSafeSize() should never overflo
w this value, | 327 * SkBitmap::fPixelRefOffset + SkBitmap::getSafeSize() should never overflo
w this value, |
| 312 * otherwise the rendering code may attempt to read memory out of bounds. | 328 * otherwise the rendering code may attempt to read memory out of bounds. |
| 313 * | 329 * |
| 314 * @return default impl returns 0. | 330 * @return default impl returns 0. |
| 315 */ | 331 */ |
| 316 virtual size_t getAllocatedSizeInBytes() const; | 332 virtual size_t getAllocatedSizeInBytes() const; |
| 317 | 333 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 365 /** | 381 /** |
| 366 * Allocate a new pixelref matching the specified ImageInfo, allocating | 382 * Allocate a new pixelref matching the specified ImageInfo, allocating |
| 367 * the memory for the pixels. If the ImageInfo requires a ColorTable, | 383 * the memory for the pixels. If the ImageInfo requires a ColorTable, |
| 368 * the pixelref will ref() the colortable. | 384 * the pixelref will ref() the colortable. |
| 369 * On failure return NULL. | 385 * On failure return NULL. |
| 370 */ | 386 */ |
| 371 virtual SkPixelRef* create(const SkImageInfo&, size_t rowBytes, SkColorTable
*) = 0; | 387 virtual SkPixelRef* create(const SkImageInfo&, size_t rowBytes, SkColorTable
*) = 0; |
| 372 }; | 388 }; |
| 373 | 389 |
| 374 #endif | 390 #endif |
| OLD | NEW |