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 GrYUVProvider_DEFINED | 8 #ifndef GrYUVProvider_DEFINED |
9 #define GrYUVProvider_DEFINED | 9 #define GrYUVProvider_DEFINED |
10 | 10 |
11 #include "GrTypes.h" | 11 #include "GrTypes.h" |
12 #include "SkImageInfo.h" | 12 #include "SkImageInfo.h" |
| 13 #include "SkYUVSizeInfo.h" |
13 | 14 |
14 class GrContext; | 15 class GrContext; |
15 class GrTexture; | 16 class GrTexture; |
16 | 17 |
17 /** | 18 /** |
18 * There are at least 2 different ways to extract/retrieve YUV planar data... | 19 * There are at least 2 different ways to extract/retrieve YUV planar data... |
19 * - SkPixelRef | 20 * - SkPixelRef |
20 * - SkImageGeneartor | 21 * - SkImageGeneartor |
21 * | 22 * |
22 * To share common functionality around using the planar data, we use this abst
ract base-class | 23 * To share common functionality around using the planar data, we use this abst
ract base-class |
23 * to represent accessing that data. | 24 * to represent accessing that data. |
24 */ | 25 */ |
25 class GrYUVProvider { | 26 class GrYUVProvider { |
26 public: | 27 public: |
27 virtual ~GrYUVProvider() {} | 28 virtual ~GrYUVProvider() {} |
28 | 29 |
29 /** | 30 /** |
30 * On success, this returns a texture that has converted the YUV data from
the provider | 31 * On success, this returns a texture that has converted the YUV data from
the provider |
31 * into a form that is supported by the GPU (typically transformed into RGB
). If useCache | 32 * into a form that is supported by the GPU (typically transformed into RGB
). If useCache |
32 * is true, then the texture will automatically have a key added, so it can
be retrieved | 33 * is true, then the texture will automatically have a key added, so it can
be retrieved |
33 * from the cache (assuming it is requested by a provider w/ the same genID
). | 34 * from the cache (assuming it is requested by a provider w/ the same genID
). |
34 * | 35 * |
35 * On failure (e.g. the provider had no data), this returns NULL. | 36 * On failure (e.g. the provider had no data), this returns NULL. |
36 */ | 37 */ |
37 GrTexture* refAsTexture(GrContext*, const GrSurfaceDesc&, bool useCache); | 38 GrTexture* refAsTexture(GrContext*, const GrSurfaceDesc&, bool useCache); |
38 | 39 |
39 virtual uint32_t onGetID() = 0; | 40 virtual uint32_t onGetID() = 0; |
40 | 41 |
41 enum { | |
42 kY_Index = 0, | |
43 kU_Index = 1, | |
44 kV_Index = 2, | |
45 | |
46 kPlaneCount = 3 | |
47 }; | |
48 | |
49 // These are not meant to be called by a client, only by the implementation | 42 // These are not meant to be called by a client, only by the implementation |
50 | 43 |
51 /** | 44 /** |
52 * Return the 3 dimensions for each plane and return true. On failure, retu
rn false and | 45 * If decoding to YUV is supported, this returns true. Otherwise, this |
53 * ignore the sizes parameter. Typical failure is that the provider does no
t contain YUV | 46 * returns false and does not modify any of the parameters. |
54 * data, and may just be an RGB src. | 47 * |
| 48 * @param sizeInfo Output parameter indicating the sizes and required |
| 49 * allocation widths of the Y, U, and V planes. |
| 50 * @param colorSpace Output parameter. |
55 */ | 51 */ |
56 virtual bool onGetYUVSizes(SkISize sizes[kPlaneCount]) = 0; | 52 virtual bool onQueryYUV8(SkYUVSizeInfo* sizeInfo, SkYUVColorSpace* colorSpac
e) const = 0; |
57 | 53 |
58 /** | 54 /** |
59 * On success, return true, and set sizes, rowbytes and colorspace to the a
ppropriate values. | 55 * Returns true on success and false on failure. |
60 * planes[] will have already been allocated by the client (based on the wo
rst-case sizes | 56 * This always attempts to perform a full decode. If the client only |
61 * returned by onGetYUVSizes(). This method copies its planar data into tho
se buffers. | 57 * wants size, it should call onQueryYUV8(). |
62 * | 58 * |
63 * On failure, return false and ignore other parameters. | 59 * @param sizeInfo Needs to exactly match the values returned by the |
| 60 * query, except the WidthBytes may be larger than the |
| 61 * recommendation (but not smaller). |
| 62 * @param planes Memory for each of the Y, U, and V planes. |
64 */ | 63 */ |
65 virtual bool onGetYUVPlanes(SkISize sizes[kPlaneCount], void* planes[kPlaneC
ount], | 64 virtual bool onGetYUV8Planes(const SkYUVSizeInfo& sizeInfo, void* planes[3])
= 0; |
66 size_t rowBytes[kPlaneCount], SkYUVColorSpace*)
= 0; | |
67 }; | 65 }; |
68 | 66 |
69 #endif | 67 #endif |
OLD | NEW |