Chromium Code Reviews| 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 { |
|
scroggo
2016/01/04 18:29:15
crrev.com/863053002 proposed suggesting both a log
msarett
2016/01/04 21:46:46
I think this is the hard question for this API. I
msarett
2016/01/12 14:25:27
I have invented "widthBytes" which almost means th
|
| + if (nullptr == sizes) { |
| + return false; |
| + } |
| + |
| + return this->onGetYUV8Sizes(sizes); |
| + } |
| + |
| + /** |
|
scroggo
2016/01/04 18:29:15
nit: Typically the first line will describe genera
msarett
2016/01/12 14:25:27
Done.
|
| + * @param sizes Sizes of each of the Y, U, and V planes |
| + * @param pixels Memory for each of the Y, U, and V planes |
|
scroggo
2016/01/04 18:29:15
Maybe this is just due to my lack of knowledge abo
msarett
2016/01/04 21:46:46
Will add comments. Each Y, U, or V sample is a si
msarett
2016/01/12 14:25:27
Added more detail.
|
| + * @param rowBytes Row bytes for each of the Y, U, and V planes |
| + * @param colorSpace If nullptr, this parameter is ignored. Otherwise, |
|
scroggo
2016/01/04 18:29:15
Do we need this here? In https://codereview.chromi
msarett
2016/01/04 21:46:46
Happy to add this to the query step.
What is this
|
| + * 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], |
|
reed1
2016/01/04 15:50:55
can sizes[] be const? Seems much simplier if they
scroggo
2016/01/04 18:29:15
Looks like rowBytes can also be const?
Alternativ
msarett
2016/01/04 21:46:46
Depends on how we choose to deal with AllocatedSiz
msarett
2016/01/12 14:25:27
Using structs now.
"sizes" and "widthBytes" are c
|
| + 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 { |
| // 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*/, |
|
scroggo
2016/01/04 18:29:15
Why does this use different notations from getYUV8
|
| + SkYUVColorSpace* /*colorSpace*/) { |
| + return kUnimplemented; |
| + } |
| + |
| + virtual bool onGetValidSubset(SkIRect* /*desiredSubset*/) const { |
| // By default, subsets are not supported. |
| return false; |
| } |