| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 SkYUVPlanesCache_DEFINED | 8 #ifndef SkYUVPlanesCache_DEFINED |
| 9 #define SkYUVPlanesCache_DEFINED | 9 #define SkYUVPlanesCache_DEFINED |
| 10 | 10 |
| 11 #include "SkCachedData.h" | 11 #include "SkCachedData.h" |
| 12 #include "SkImageInfo.h" | 12 #include "SkImageInfo.h" |
| 13 #include "SkYUVSizeInfo.h" | |
| 14 | 13 |
| 15 class SkResourceCache; | 14 class SkResourceCache; |
| 16 | 15 |
| 17 class SkYUVPlanesCache { | 16 class SkYUVPlanesCache { |
| 18 public: | 17 public: |
| 19 /** | 18 /** |
| 20 * The Info struct contains data about the 3 Y, U and V planes of memory sto
red | 19 * The Info struct contains data about the 3 Y, U and V planes of memory sto
red |
| 21 * contiguously, in that order, as a single block of memory within SkYUVPlan
esCache. | 20 * contiguously, in that order, as a single block of memory within SkYUVPlan
esCache. |
| 22 * | 21 * |
| 23 * fSizeInfo: fWidth, fHeight, and fWidthBytes of each of the Y, U, and V pl
anes. | 22 * fSize: Width and height of each of the 3 planes (in pixels). |
| 23 * fSizeInMemory: Amount of memory allocated for each plane (may be differen
t from |
| 24 "height * rowBytes", depending on the jpeg decoder's block
size). |
| 25 * The sum of these is the total size stored within SkYUVPlan
esCache. |
| 26 * fRowBytes: rowBytes for each of the 3 planes (in bytes). |
| 24 * fColorSpace: color space that will be used for the YUV -> RGB conversion. | 27 * fColorSpace: color space that will be used for the YUV -> RGB conversion. |
| 25 */ | 28 */ |
| 26 struct Info { | 29 struct Info { |
| 27 SkYUVSizeInfo fSizeInfo; | 30 SkISize fSize[3]; |
| 31 size_t fSizeInMemory[3]; |
| 32 size_t fRowBytes[3]; |
| 28 SkYUVColorSpace fColorSpace; | 33 SkYUVColorSpace fColorSpace; |
| 29 }; | 34 }; |
| 30 /** | 35 /** |
| 31 * On success, return a ref to the SkCachedData that holds the pixels. | 36 * On success, return a ref to the SkCachedData that holds the pixels. |
| 32 * | 37 * |
| 33 * On failure, return nullptr. | 38 * On failure, return nullptr. |
| 34 */ | 39 */ |
| 35 static SkCachedData* FindAndRef(uint32_t genID, Info* info, | 40 static SkCachedData* FindAndRef(uint32_t genID, Info* info, |
| 36 SkResourceCache* localCache = nullptr); | 41 SkResourceCache* localCache = nullptr); |
| 37 | 42 |
| 38 /** | 43 /** |
| 39 * Add a pixelRef ID and its YUV planes data to the cache. | 44 * Add a pixelRef ID and its YUV planes data to the cache. |
| 40 */ | 45 */ |
| 41 static void Add(uint32_t genID, SkCachedData* data, Info* info, | 46 static void Add(uint32_t genID, SkCachedData* data, Info* info, |
| 42 SkResourceCache* localCache = nullptr); | 47 SkResourceCache* localCache = nullptr); |
| 43 }; | 48 }; |
| 44 | 49 |
| 45 #endif | 50 #endif |
| OLD | NEW |