From abaef86f2b37d8a939506a2076da07f6db456951 Mon Sep 17 00:00:00 2001 From: rileya Date: Fri, 12 Sep 2014 17:45:58 -0700 Subject: Add support for the Rec601 YUV color space to GrYUVtoRGBEffect. R=bsalomon@google.com, senorblanco@chromium.org, sugoi@chromium.org, reed@google.com Author: rileya@chromium.org Review URL: https://codereview.chromium.org/516463005 --- include/core/SkImageGenerator.h | 7 +++++-- include/core/SkImageInfo.h | 15 +++++++++++++++ include/core/SkPixelRef.h | 11 ++++++++--- 3 files changed, 28 insertions(+), 5 deletions(-) (limited to 'include') diff --git a/include/core/SkImageGenerator.h b/include/core/SkImageGenerator.h index 4eb5cf85d6..fc6b1b4421 100644 --- a/include/core/SkImageGenerator.h +++ b/include/core/SkImageGenerator.h @@ -8,8 +8,8 @@ #ifndef SkImageGenerator_DEFINED #define SkImageGenerator_DEFINED -#include "SkImageInfo.h" #include "SkColor.h" +#include "SkImageInfo.h" class SkBitmap; class SkData; @@ -121,7 +121,8 @@ public: * 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. */ - bool getYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBytes[3]); + bool getYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBytes[3], + SkYUVColorSpace* colorSpace); protected: virtual SkData* onRefEncodedData(); @@ -130,6 +131,8 @@ protected: 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); }; #endif // SkImageGenerator_DEFINED diff --git a/include/core/SkImageInfo.h b/include/core/SkImageInfo.h index 6204cb3b81..7fedfa1a4a 100644 --- a/include/core/SkImageInfo.h +++ b/include/core/SkImageInfo.h @@ -132,6 +132,21 @@ bool SkColorTypeValidateAlphaType(SkColorType colorType, SkAlphaType alphaType, /////////////////////////////////////////////////////////////////////////////// +/** + * Describes the color space a YUV pixel. + */ +enum SkYUVColorSpace { + /** Standard JPEG color space. */ + kJPEG_SkYUVColorSpace, + /** SDTV standard Rec. 601 color space. Uses "studio swing" [16, 235] color + range. See http://en.wikipedia.org/wiki/Rec._601 for details. */ + kRec601_SkYUVColorSpace, + + kLastEnum_SkYUVColorSpace = kRec601_SkYUVColorSpace +}; + +/////////////////////////////////////////////////////////////////////////////// + /** * Describe an image's dimensions and pixel type. */ diff --git a/include/core/SkPixelRef.h b/include/core/SkPixelRef.h index afab7fad9e..02d696edd8 100644 --- a/include/core/SkPixelRef.h +++ b/include/core/SkPixelRef.h @@ -227,9 +227,13 @@ public: * If all planes and rowBytes are not NULL, then it should copy the associated Y,U,V 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. + * + * If colorSpace is not NULL, the YUV color space of the data should be stored in the address + * it points at. */ - bool getYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBytes[3]) { - return this->onGetYUV8Planes(sizes, planes, rowBytes); + bool getYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBytes[3], + SkYUVColorSpace* colorSpace) { + return this->onGetYUV8Planes(sizes, planes, rowBytes, colorSpace); } bool readPixels(SkBitmap* dst, const SkIRect* subset = NULL); @@ -319,7 +323,8 @@ protected: virtual SkData* onRefEncodedData(); // default impl returns false. - 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); /** * Returns the size (in bytes) of the internally allocated memory. -- cgit v1.2.3