Chromium Code Reviews| Index: include/core/SkImageGenerator.h |
| diff --git a/include/core/SkImageGenerator.h b/include/core/SkImageGenerator.h |
| index f399ab538e9ea05d125ab1b21ec387640d69ffc3..80a5aee751a03004911fe5dce8c600d6e3e25810 100644 |
| --- a/include/core/SkImageGenerator.h |
| +++ b/include/core/SkImageGenerator.h |
| @@ -9,6 +9,7 @@ |
| #define SkImageGenerator_DEFINED |
| #include "SkImageInfo.h" |
| +#include "SkColor.h" |
| class SkBitmap; |
| class SkData; |
| @@ -47,6 +48,13 @@ public: |
| */ |
| virtual ~SkImageGenerator() { } |
| +#ifdef SK_SUPPORT_LEGACY_IMAGEGENERATORAPI |
| + virtual bool refEncodedData() { return this->onRefEncodedData(); } |
| + virtual bool getInfo(SkImageInfo* info) { return this->onGetInfo(info); } |
| + virtual bool getPixels(const SkImageInfo& info, void* pixels, size_t rowBytes) { |
| + return this->onGetPixels(info, pixels, rowBytes, NULL, NULL); |
| + } |
| +#else |
| /** |
| * Return a ref to the encoded (i.e. compressed) representation, |
| * of this data. |
| @@ -54,7 +62,7 @@ public: |
| * If non-NULL is returned, the caller is responsible for calling |
| * unref() on the data when it is finished. |
| */ |
| - virtual SkData* refEncodedData() { return NULL; } |
| + SkData* refEncodedData() { return this->onRefEncodedData(); } |
| /** |
| * Return some information about the image, allowing the owner of |
| @@ -65,7 +73,7 @@ public: |
| * |
| * @return false if anything goes wrong. |
| */ |
| - virtual bool getInfo(SkImageInfo* info) = 0; |
| + bool getInfo(SkImageInfo* info); |
|
scroggo
2014/05/27 16:13:58
So long as we're updating the API - SkBitmap origi
reed1
2014/05/27 18:05:46
A generate can fail because it has bad data, or so
|
| /** |
| * Decode into the given pixels, a block of memory of size at |
| @@ -83,12 +91,31 @@ public: |
| * different output-configs, which the implementation can |
| * decide to support or not. |
| * |
| + * If info is kIndex8_SkColorType, then the caller must provide storage for up to 256 |
| + * SkPMColor values in ctable. On success the generator must copy N colors into that storage, |
| + * (where N is the logical number of table entries) and set ctableCount to N. |
| + * |
| + * If info is not kIndex8_SkColorType, then the caller must pass NULL for both ctable and |
| + * ctableCount. |
| + * |
| * @return false if anything goes wrong or if the image info is |
| * unsupported. |
| */ |
| - virtual bool getPixels(const SkImageInfo& info, |
| - void* pixels, |
| - size_t rowBytes) = 0; |
| + bool getPixels(const SkImageInfo& info, void* pixels, size_t rowBytes, |
| + SkPMColor ctable[], int* ctableCount); |
| + |
| + /** |
| + * Simplified version of getPixels() that asserts that info is NOT kIndex8_SkColorType. |
| + */ |
| + bool getPixels(const SkImageInfo& info, void* pixels, size_t rowBytes); |
| +#endif |
| + |
| +protected: |
| + virtual SkData* onRefEncodedData(); |
| + virtual bool onGetInfo(SkImageInfo* info); |
| + virtual bool onGetPixels(const SkImageInfo& info, |
| + void* pixels, size_t rowBytes, |
| + SkPMColor ctable[], int* ctableCount); |
| }; |
| #endif // SkImageGenerator_DEFINED |