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