Chromium Code Reviews| Index: include/core/SkImageGenerator.h |
| diff --git a/include/core/SkImageGenerator.h b/include/core/SkImageGenerator.h |
| index 0e2a45e145c5fb6403355b0ec86e63e4248be654..9108cc95757f97e2f580b0ab7842d9cf312e2c5c 100644 |
| --- a/include/core/SkImageGenerator.h |
| +++ b/include/core/SkImageGenerator.h |
| @@ -108,6 +108,36 @@ public: |
| SkPMColor ctable[], int* ctableCount); |
| /** |
| + * Some generators can efficiently scale their contents and provide multiple |
| + * different pixel formats while decoding. |
| + * If scaling is supported, the generator may only support certain scaled dimensions. |
| + * Call this with the desired scale and color type, and it will return true if scaling |
| + * and specified color type is supported. |
| + * |
| + * @param colorType A description of the color type expected by the caller. |
| + * Returns true if it is the same as getInfo() or if decoder implementations |
| + * support this output. |
| + * |
| + * @param scale Vale larger than 0 and less or equal to 1. |
| + * |
| + * @param availableSize If specified colorType and scale on decode is supported, |
| + * this holds a value of equal or nearest larger possible decode output. |
| + * Can be NULL, in which case caller specifies no interest in getting the value. |
| + * |
| + * @param lowerSize If specified colorType and scale on decode is supported, |
| + * this holds a value of nearest lower possible decode output. |
| + * Can be NULL, in which case caller specifies no interest in getting the value. |
| + * |
| + * Disclaimer: This method was added later to this class and it is possible |
| + * that some of the SkImageGenerator implementations are not overriding it to |
| + * precisely declare supported decoding. Purpose of this call is an attempt to prevent |
| + * fruitless memory allocations (from within Skia) before calling getPixels - it is |
| + * still OK to call getPixels even this method is not overridden in generator implementation. |
| + */ |
| + bool canDecodeAndScale(const SkColorType colorType, const SkScalar scale = SK_Scalar1, |
|
scroggo
2015/10/15 16:26:32
Should this also specify an alpha type? Or should
|
| + SkISize *availableSize = nullptr, SkISize *lowerSize = nullptr); |
|
scroggo
2015/10/15 16:26:32
I like that the sizes are named to distinguish wha
|
| + |
| + /** |
| * Simplified version of getPixels() that asserts that info is NOT kIndex8_SkColorType and |
| * uses the default Options. |
| */ |
| @@ -198,6 +228,9 @@ protected: |
| return nullptr; |
| } |
| + virtual bool onCanDecodeAndScale(const SkColorType colorType, const SkScalar scale, |
| + SkISize *availableSize, SkISize *lowerSize); |
| + |
| bool tryGenerateBitmap(SkBitmap* bm, const SkImageInfo* optionalInfo, SkBitmap::Allocator*); |
| private: |