1 | /* |
2 | * Copyright 2015 Google Inc. |
3 | * |
4 | * Use of this source code is governed by a BSD-style license that can be |
5 | * found in the LICENSE file. |
6 | */ |
7 | |
8 | #ifndef SkYUVPlanesCache_DEFINED |
9 | #define SkYUVPlanesCache_DEFINED |
10 | |
11 | #include "include/core/SkImageInfo.h" |
12 | #include "include/core/SkYUVAIndex.h" |
13 | #include "include/core/SkYUVASizeInfo.h" |
14 | #include "src/core/SkCachedData.h" |
15 | |
16 | class SkResourceCache; |
17 | |
18 | class SkYUVPlanesCache { |
19 | public: |
20 | /** |
21 | * The Info struct contains data about the 4 Y, U, V, and A planes of memory stored |
22 | * contiguously, in that order, as a single block of memory within SkYUVPlanesCache. |
23 | * |
24 | * fSizeInfo: fWidth, fHeight, and fWidthBytes of each of the Y, U, V, and A planes. |
25 | * fColorSpace: color space that will be used for the YUV -> RGB conversion. |
26 | */ |
27 | struct Info { |
28 | SkYUVASizeInfo fSizeInfo; |
29 | SkYUVAIndex fYUVAIndices[SkYUVAIndex::kIndexCount]; |
30 | SkYUVColorSpace fColorSpace; |
31 | }; |
32 | /** |
33 | * On success, return a ref to the SkCachedData that holds the pixels. |
34 | * |
35 | * On failure, return nullptr. |
36 | */ |
37 | static SkCachedData* FindAndRef(uint32_t genID, Info* info, |
38 | SkResourceCache* localCache = nullptr); |
39 | |
40 | /** |
41 | * Add a pixelRef ID and its YUV planes data to the cache. |
42 | */ |
43 | static void Add(uint32_t genID, SkCachedData* data, Info* info, |
44 | SkResourceCache* localCache = nullptr); |
45 | }; |
46 | |
47 | #endif |
48 | |