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 "../private/SkAtomics.h" | 11 #include "../private/SkAtomics.h" |
12 #include "../private/SkMutex.h" | 12 #include "../private/SkMutex.h" |
13 #include "../private/SkTDArray.h" | 13 #include "../private/SkTDArray.h" |
14 #include "SkBitmap.h" | 14 #include "SkBitmap.h" |
15 #include "SkFilterQuality.h" | 15 #include "SkFilterQuality.h" |
16 #include "SkImageInfo.h" | 16 #include "SkImageInfo.h" |
17 #include "SkPixmap.h" | 17 #include "SkPixmap.h" |
18 #include "SkRefCnt.h" | 18 #include "SkRefCnt.h" |
19 #include "SkSize.h" | 19 #include "SkSize.h" |
20 #include "SkString.h" | 20 #include "SkString.h" |
| 21 #include "SkYUVSizeInfo.h" |
21 | 22 |
22 class SkColorTable; | 23 class SkColorTable; |
23 class SkData; | 24 class SkData; |
24 struct SkIRect; | 25 struct SkIRect; |
25 | 26 |
26 class GrTexture; | 27 class GrTexture; |
27 class SkDiscardableMemory; | 28 class SkDiscardableMemory; |
28 | 29 |
29 /** \class SkPixelRef | 30 /** \class SkPixelRef |
30 | 31 |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 } | 204 } |
204 }; | 205 }; |
205 | 206 |
206 bool requestLock(const LockRequest&, LockResult*); | 207 bool requestLock(const LockRequest&, LockResult*); |
207 | 208 |
208 /** Are we really wrapping a texture instead of a bitmap? | 209 /** Are we really wrapping a texture instead of a bitmap? |
209 */ | 210 */ |
210 virtual GrTexture* getTexture() { return NULL; } | 211 virtual GrTexture* getTexture() { return NULL; } |
211 | 212 |
212 /** | 213 /** |
213 * If any planes or rowBytes is NULL, this should output the sizes and retu
rn true | 214 * If this can efficiently return YUV data, this should return true. |
214 * if it can efficiently return YUV planar data. If it cannot, it should re
turn false. | 215 * Otherwise this returns false and does not modify any of the parameters. |
215 * | 216 * |
216 * If all planes and rowBytes are not NULL, then it should copy the associa
ted Y,U,V data | 217 * @param sizeInfo Output parameter indicating the sizes and required |
217 * into those planes of memory supplied by the caller. It should validate t
hat the sizes | 218 * allocation widths of the Y, U, and V planes. |
218 * match what it expected. If the sizes do not match, it should return fals
e. | 219 * @param colorSpace Output parameter. |
| 220 */ |
| 221 bool queryYUV8(SkYUVSizeInfo* sizeInfo, SkYUVColorSpace* colorSpace) const { |
| 222 return this->onQueryYUV8(sizeInfo, colorSpace); |
| 223 } |
| 224 |
| 225 /** |
| 226 * Returns true on success and false on failure. |
| 227 * Copies YUV data into the provided YUV planes. |
219 * | 228 * |
220 * If colorSpace is not NULL, the YUV color space of the data should be sto
red in the address | 229 * @param sizeInfo Needs to exactly match the values returned by the |
221 * it points at. | 230 * query, except the WidthBytes may be larger than the |
| 231 * recommendation (but not smaller). |
| 232 * @param planes Memory for each of the Y, U, and V planes. |
222 */ | 233 */ |
223 bool getYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBytes[3], | 234 bool getYUV8Planes(const SkYUVSizeInfo& sizeInfo, void* planes[3]) { |
224 SkYUVColorSpace* colorSpace) { | 235 return this->onGetYUV8Planes(sizeInfo, planes); |
225 return this->onGetYUV8Planes(sizes, planes, rowBytes, colorSpace); | |
226 } | 236 } |
227 | 237 |
228 /** Populates dst with the pixels of this pixelRef, converting them to color
Type. */ | 238 /** Populates dst with the pixels of this pixelRef, converting them to color
Type. */ |
229 bool readPixels(SkBitmap* dst, SkColorType colorType, const SkIRect* subset
= NULL); | 239 bool readPixels(SkBitmap* dst, SkColorType colorType, const SkIRect* subset
= NULL); |
230 | 240 |
231 /** | 241 /** |
232 * Makes a deep copy of this PixelRef, respecting the requested config. | 242 * Makes a deep copy of this PixelRef, respecting the requested config. |
233 * @param colorType Desired colortype. | 243 * @param colorType Desired colortype. |
234 * @param profileType Desired colorprofiletype. | 244 * @param profileType Desired colorprofiletype. |
235 * @param subset Subset of this PixelRef to copy. Must be fully contained w
ithin the bounds of | 245 * @param subset Subset of this PixelRef to copy. Must be fully contained w
ithin the bounds of |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 * The base class implementation returns false; | 311 * The base class implementation returns false; |
302 */ | 312 */ |
303 virtual bool onReadPixels(SkBitmap* dst, SkColorType colorType, const SkIRec
t* subsetOrNull); | 313 virtual bool onReadPixels(SkBitmap* dst, SkColorType colorType, const SkIRec
t* subsetOrNull); |
304 | 314 |
305 // default impl returns NULL. | 315 // default impl returns NULL. |
306 virtual SkData* onRefEncodedData(); | 316 virtual SkData* onRefEncodedData(); |
307 | 317 |
308 // default impl does nothing. | 318 // default impl does nothing. |
309 virtual void onNotifyPixelsChanged(); | 319 virtual void onNotifyPixelsChanged(); |
310 | 320 |
311 // default impl returns false. | 321 virtual bool onQueryYUV8(SkYUVSizeInfo*, SkYUVColorSpace*) const { |
312 virtual bool onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBy
tes[3], | 322 return false; |
313 SkYUVColorSpace* colorSpace); | 323 } |
| 324 virtual bool onGetYUV8Planes(const SkYUVSizeInfo&, void*[3] /*planes*/) { |
| 325 return false; |
| 326 } |
314 | 327 |
315 /** | 328 /** |
316 * Returns the size (in bytes) of the internally allocated memory. | 329 * Returns the size (in bytes) of the internally allocated memory. |
317 * This should be implemented in all serializable SkPixelRef derived classe
s. | 330 * This should be implemented in all serializable SkPixelRef derived classe
s. |
318 * SkBitmap::fPixelRefOffset + SkBitmap::getSafeSize() should never overflo
w this value, | 331 * SkBitmap::fPixelRefOffset + SkBitmap::getSafeSize() should never overflo
w this value, |
319 * otherwise the rendering code may attempt to read memory out of bounds. | 332 * otherwise the rendering code may attempt to read memory out of bounds. |
320 * | 333 * |
321 * @return default impl returns 0. | 334 * @return default impl returns 0. |
322 */ | 335 */ |
323 virtual size_t getAllocatedSizeInBytes() const; | 336 virtual size_t getAllocatedSizeInBytes() const; |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
400 /** | 413 /** |
401 * Allocate a new pixelref matching the specified ImageInfo, allocating | 414 * Allocate a new pixelref matching the specified ImageInfo, allocating |
402 * the memory for the pixels. If the ImageInfo requires a ColorTable, | 415 * the memory for the pixels. If the ImageInfo requires a ColorTable, |
403 * the pixelref will ref() the colortable. | 416 * the pixelref will ref() the colortable. |
404 * On failure return NULL. | 417 * On failure return NULL. |
405 */ | 418 */ |
406 virtual SkPixelRef* create(const SkImageInfo&, size_t rowBytes, SkColorTable
*) = 0; | 419 virtual SkPixelRef* create(const SkImageInfo&, size_t rowBytes, SkColorTable
*) = 0; |
407 }; | 420 }; |
408 | 421 |
409 #endif | 422 #endif |
OLD | NEW |