Index: include/codec/SkCodec.h |
diff --git a/include/codec/SkCodec.h b/include/codec/SkCodec.h |
index d06c2c3399e4858e30626945948f4933f5d059c6..c4b4fd12e6c0eb45804413dc07a7a5e1b3bc411b 100644 |
--- a/include/codec/SkCodec.h |
+++ b/include/codec/SkCodec.h |
@@ -278,6 +278,45 @@ public: |
Result getPixels(const SkImageInfo& info, void* pixels, size_t rowBytes); |
/** |
+ * If decoding to YUV is supported, this returns true and populates "sizes" with |
+ * the appropriate sizes of the Y, U, and V planes. |
+ */ |
+ bool getYUV8Sizes(SkISize sizes[3]) const { |
+ if (nullptr == sizes) { |
+ return false; |
+ } |
+ |
+ return this->onGetYUV8Sizes(sizes); |
+ } |
+ |
+ /** |
+ * @param sizes Sizes of each of the Y, U, and V planes |
+ * @param pixels Memory for each of the Y, U, and V planes |
+ * @param rowBytes Row bytes for each of the Y, U, and V planes |
+ * @param colorSpace If nullptr, this parameter is ignored. Otherwise, |
+ * if the decode is successful, this will bet set to |
+ * kJPEG_SkYUVColorSpace (JPEG is currently the only |
+ * format that supports YUV). |
+ * |
+ * Returns kSuccess, or another value explaining the type of failure. |
+ * This always attempts to perform a full decode. If the client only |
+ * wants size, it should call getYUV8Sizes(). |
+ */ |
+ Result getYUV8Planes(SkISize sizes[3], void* pixels[3], size_t rowBytes[3], |
+ SkYUVColorSpace* colorSpace) { |
+ if (nullptr == sizes || nullptr == pixels || nullptr == pixels[0] || |
+ nullptr == pixels[1] || nullptr == pixels[2] || nullptr == rowBytes) { |
+ return kInvalidInput; |
+ } |
+ |
+ if (!this->rewindIfNeeded()) { |
+ return kCouldNotRewind; |
+ } |
+ |
+ return this->onGetYUV8Planes(sizes, pixels, rowBytes, colorSpace); |
+ } |
+ |
+ /** |
* Some images may initially report that they have alpha due to the format |
* of the encoded data, but then never use any colors which have alpha |
* less than 100%. This function can be called *after* decoding to |
@@ -454,7 +493,7 @@ public: |
protected: |
SkCodec(const SkImageInfo&, SkStream*); |
- virtual SkISize onGetScaledDimensions(float /* desiredScale */) const { |
+ virtual SkISize onGetScaledDimensions(float /*desiredScale*/) const { |
msarett
2015/12/22 21:01:36
Just changing the comments here to be consistent w
|
// By default, scaling is not supported. |
return this->getInfo().dimensions(); |
} |
@@ -481,7 +520,16 @@ protected: |
SkPMColor ctable[], int* ctableCount, |
int* rowsDecoded) = 0; |
- virtual bool onGetValidSubset(SkIRect* /* desiredSubset */) const { |
+ virtual bool onGetYUV8Sizes(SkISize* /*sizes*/) const { |
+ return false; |
+ } |
+ |
+ virtual Result onGetYUV8Planes(SkISize* /*sizes*/, void** /*pixels*/, size_t* /*rowBytes*/, |
+ SkYUVColorSpace* /*colorSpace*/) { |
+ return kUnimplemented; |
+ } |
+ |
+ virtual bool onGetValidSubset(SkIRect* /*desiredSubset*/) const { |
// By default, subsets are not supported. |
return false; |
} |