Chromium Code Reviews| Index: include/codec/SkCodec.h |
| diff --git a/include/codec/SkCodec.h b/include/codec/SkCodec.h |
| index cc635e012ca82bd2c11839ab10fe51ab5f9625a7..ab2033948fa476ce0eea146d62530aafaf954acb 100644 |
| --- a/include/codec/SkCodec.h |
| +++ b/include/codec/SkCodec.h |
| @@ -58,6 +58,25 @@ public: |
| } |
| /** |
| + * Return (via desiredSubset) a subset which can decoded from this codec, |
| + * or false if this codec cannot decode subsets or anything similar to |
| + * desiredSubset. |
| + * |
| + * @param desiredSubset In/out parameter. As input, a desired subset of |
| + * the original bounds (as specified by getInfo). If true is returned, |
| + * desiredSubset may have been modified to a subset which is |
| + * supported. Although a particular change may have been made to |
| + * desiredSubset to create something supported, it is possible other |
| + * changes could result in a valid subset. |
| + * If false is returned, desiredSubset's value is undefined. |
| + * @return true if this codec supports decoding desiredSubset (as |
| + * returned, potentially modified) |
| + */ |
| + bool getValidSubset(SkIRect* desiredSubset) const { |
| + return this->onGetValidSubset(desiredSubset); |
| + } |
| + |
| + /** |
| * Format of the encoded data. |
| */ |
| SkEncodedFormat getEncodedFormat() const { return this->onGetEncodedFormat(); } |
| @@ -128,9 +147,21 @@ public: |
| */ |
| struct Options { |
| Options() |
| - : fZeroInitialized(kNo_ZeroInitialized) {} |
| + : fZeroInitialized(kNo_ZeroInitialized) |
| + { |
| + fSubset.setEmpty(); |
| + } |
| ZeroInitialized fZeroInitialized; |
| + /** |
| + * If not empty, represents a subset of the original image to decode. |
| + * |
| + * Must intersect with the bounds returned by getInfo(). |
| + * |
| + * If the EncodedFormat is kWEBP_SkEncodedFormat (the only one which |
| + * currently supports subsets), the top and left values must be even. |
| + */ |
| + SkIRect fSubset; |
|
scroggo
2015/07/21 14:53:45
This might be better as a pointer, where NULL mean
msarett
2015/07/21 15:19:37
I would lean towards using a pointer, but I don't
emmaleer
2015/07/21 15:24:55
I think making it a pointer makes more sense. Beca
|
| }; |
| /** |
| @@ -228,6 +259,11 @@ protected: |
| void* pixels, size_t rowBytes, const Options&, |
| SkPMColor ctable[], int* ctableCount) = 0; |
| + virtual bool onGetValidSubset(SkIRect* /* desiredSubset */) const { |
| + // By default, subsets are not supported. |
| + return false; |
| + } |
| + |
| /** |
| * Override if your codec supports scanline decoding. |
| * |