| Index: include/core/SkImageGenerator.h
|
| diff --git a/include/core/SkImageGenerator.h b/include/core/SkImageGenerator.h
|
| index 3d508ddfb1c7ec7f1ceb34b9a12d3ce3d50f6060..1abf4f123da4df6a0e42539303d2ca1503f98356 100644
|
| --- a/include/core/SkImageGenerator.h
|
| +++ b/include/core/SkImageGenerator.h
|
| @@ -109,6 +109,58 @@ public:
|
| SkPMColor ctable[], int* ctableCount);
|
|
|
| /**
|
| + * Used to describe the result of a call to canDecodeAndScale().
|
| + */
|
| + enum Result {
|
| + /**
|
| + * Cannot decode neither scale.
|
| + */
|
| + kNotAvailable = 0,
|
| + /**
|
| + * Can scale with color type defined in getInfo.
|
| + */
|
| + kScale,
|
| + /**
|
| + * Can convert to requested colorType, but cannot scale.
|
| + */
|
| + kDecode,
|
| + /**
|
| + * The generator can scale and decode to requested.
|
| + */
|
| + kAvailable = kScale | kDecode,
|
| + };
|
| +
|
| + /**
|
| + * 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.
|
| + */
|
| + Result canDecodeAndScale(const SkColorType colorType, const SkScalar scale = SK_Scalar1,
|
| + SkISize* availableSize = nullptr, SkISize* lowerSize = nullptr);
|
| +
|
| + /**
|
| * Simplified version of getPixels() that asserts that info is NOT kIndex8_SkColorType and
|
| * uses the default Options.
|
| */
|
| @@ -199,6 +251,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:
|
|
|