diff options
author | msarett <msarett@google.com> | 2016-03-10 05:44:43 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-03-10 05:44:43 -0800 |
commit | 4984c3c95f18eda44492a2126c9958e447f2cca8 (patch) | |
tree | add5bdca2495968a8acc1affd10e5cfe225ff4d0 /include/core/SkImageGenerator.h | |
parent | d6215cf4a5f416cf0b64a4fbba95c519f03fe467 (diff) |
Update Skia's YUV API
We should match the recently designed API in SkCodec.
https://codereview.chromium.org/1549473003/
This requires changes in Chromium as well.
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1716523002
Committed: https://skia.googlesource.com/skia/+/095d31c8a0eeb5d491febf064bc3c8a44e22b94f
Review URL: https://codereview.chromium.org/1716523002
Diffstat (limited to 'include/core/SkImageGenerator.h')
-rw-r--r-- | include/core/SkImageGenerator.h | 39 |
1 files changed, 26 insertions, 13 deletions
diff --git a/include/core/SkImageGenerator.h b/include/core/SkImageGenerator.h index 86e3053a06..1a46f6b9cd 100644 --- a/include/core/SkImageGenerator.h +++ b/include/core/SkImageGenerator.h @@ -11,6 +11,7 @@ #include "SkBitmap.h" #include "SkColor.h" #include "SkImageInfo.h" +#include "SkYUVSizeInfo.h" class GrContext; class GrTexture; @@ -129,18 +130,26 @@ public: bool getPixels(const SkImageInfo& info, void* pixels, size_t rowBytes); /** - * If planes or rowBytes is NULL or if any entry in planes is NULL or if any entry in rowBytes - * is 0, this imagegenerator should output the sizes and return true if it can efficiently - * return YUV planar data. If it cannot, it should return false. Note that either planes and - * rowBytes are both fully defined and non NULL/non 0 or they are both NULL or have NULL or 0 - * entries only. Having only partial planes/rowBytes information is not supported. + * If decoding to YUV is supported, this returns true. Otherwise, this + * returns false and does not modify any of the parameters. * - * If all planes and rowBytes entries are non NULL or non 0, then it should copy the - * associated YUV data into those planes of memory supplied by the caller. It should validate - * that the sizes match what it expected. If the sizes do not match, it should return false. + * @param sizeInfo Output parameter indicating the sizes and required + * allocation widths of the Y, U, and V planes. + * @param colorSpace Output parameter. */ - bool getYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBytes[3], - SkYUVColorSpace* colorSpace); + bool queryYUV8(SkYUVSizeInfo* sizeInfo, SkYUVColorSpace* colorSpace) const; + + /** + * Returns true on success and false on failure. + * This always attempts to perform a full decode. If the client only + * wants size, it should call queryYUV8(). + * + * @param sizeInfo Needs to exactly match the values returned by the + * query, except the WidthBytes may be larger than the + * recommendation (but not smaller). + * @param planes Memory for each of the Y, U, and V planes. + */ + bool getYUV8Planes(const SkYUVSizeInfo& sizeInfo, void* planes[3]); /** * If the generator can natively/efficiently return its pixels as a GPU image (backed by a @@ -248,9 +257,13 @@ protected: virtual bool onGetPixels(const SkImageInfo& info, void* pixels, size_t rowBytes, SkPMColor ctable[], int* ctableCount); - virtual bool onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBytes[3]); - virtual bool onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBytes[3], - SkYUVColorSpace* colorSpace); + + virtual bool onQueryYUV8(SkYUVSizeInfo*, SkYUVColorSpace*) const { + return false; + } + virtual bool onGetYUV8Planes(const SkYUVSizeInfo&, void*[3] /*planes*/) { + return false; + } virtual GrTexture* onGenerateTexture(GrContext*, const SkIRect*) { return nullptr; |