| Index: src/images/SkDecodingImageGenerator.cpp
|
| diff --git a/src/images/SkDecodingImageGenerator.cpp b/src/images/SkDecodingImageGenerator.cpp
|
| index b3924a7daa4d2b342cb6ea29f333ce93aa4b7390..e55af85a7dcdffcb3299a462325f3bf2384c83c5 100644
|
| --- a/src/images/SkDecodingImageGenerator.cpp
|
| +++ b/src/images/SkDecodingImageGenerator.cpp
|
| @@ -23,12 +23,6 @@ bool equal_modulo_alpha(const SkImageInfo& a, const SkImageInfo& b) {
|
| class DecodingImageGenerator : public SkImageGenerator {
|
| public:
|
| virtual ~DecodingImageGenerator();
|
| - virtual SkData* refEncodedData() SK_OVERRIDE;
|
| - // This implementaion of getInfo() always returns true.
|
| - virtual bool getInfo(SkImageInfo* info) SK_OVERRIDE;
|
| - virtual bool getPixels(const SkImageInfo& info,
|
| - void* pixels,
|
| - size_t rowBytes) SK_OVERRIDE;
|
|
|
| SkData* fData;
|
| SkStreamRewindable* fStream;
|
| @@ -41,6 +35,16 @@ public:
|
| const SkImageInfo& info,
|
| int sampleSize,
|
| bool ditherImage);
|
| +
|
| +protected:
|
| + virtual SkData* onRefEncodedData() SK_OVERRIDE;
|
| + // This implementaion of getInfo() always returns true.
|
| + virtual bool onGetInfo(SkImageInfo* info) SK_OVERRIDE;
|
| + virtual bool onGetPixels(const SkImageInfo& info,
|
| + void* pixels, size_t rowBytes,
|
| + SkPMColor ctable[], int* ctableCount) SK_OVERRIDE;
|
| +
|
| +private:
|
| typedef SkImageGenerator INHERITED;
|
| };
|
|
|
| @@ -123,14 +127,12 @@ DecodingImageGenerator::~DecodingImageGenerator() {
|
| fStream->unref();
|
| }
|
|
|
| -bool DecodingImageGenerator::getInfo(SkImageInfo* info) {
|
| - if (info != NULL) {
|
| - *info = fInfo;
|
| - }
|
| +bool DecodingImageGenerator::onGetInfo(SkImageInfo* info) {
|
| + *info = fInfo;
|
| return true;
|
| }
|
|
|
| -SkData* DecodingImageGenerator::refEncodedData() {
|
| +SkData* DecodingImageGenerator::onRefEncodedData() {
|
| // This functionality is used in `gm --serialize`
|
| // Does not encode options.
|
| if (fData != NULL) {
|
| @@ -151,22 +153,15 @@ SkData* DecodingImageGenerator::refEncodedData() {
|
| return SkSafeRef(fData);
|
| }
|
|
|
| -bool DecodingImageGenerator::getPixels(const SkImageInfo& info,
|
| - void* pixels,
|
| - size_t rowBytes) {
|
| - if (NULL == pixels) {
|
| - return false;
|
| - }
|
| +bool DecodingImageGenerator::onGetPixels(const SkImageInfo& info,
|
| + void* pixels, size_t rowBytes,
|
| + SkPMColor ctableEntries[], int* ctableCount) {
|
| if (fInfo != info) {
|
| // The caller has specified a different info. This is an
|
| // error for this kind of SkImageGenerator. Use the Options
|
| // to change the settings.
|
| return false;
|
| }
|
| - if (info.minRowBytes() > rowBytes) {
|
| - // The caller has specified a bad rowBytes.
|
| - return false;
|
| - }
|
|
|
| SkAssertResult(fStream->rewind());
|
| SkAutoTDelete<SkImageDecoder> decoder(SkImageDecoder::Factory(fStream));
|
| @@ -202,6 +197,20 @@ bool DecodingImageGenerator::getPixels(const SkImageInfo& info,
|
| } else {
|
| SkASSERT(check_alpha(info.alphaType(), bitmap.alphaType()));
|
| }
|
| +
|
| + if (kIndex_8_SkColorType == info.colorType()) {
|
| + if (kIndex_8_SkColorType != bitmap.colorType()) {
|
| + return false; // they asked for Index8, but we didn't receive that from decoder
|
| + }
|
| + SkColorTable* ctable = bitmap.getColorTable();
|
| + if (NULL == ctable) {
|
| + return false;
|
| + }
|
| + const int count = ctable->count();
|
| + memcpy(ctableEntries, ctable->lockColors(), count * sizeof(SkPMColor));
|
| + ctable->unlockColors();
|
| + *ctableCount = count;
|
| + }
|
| return true;
|
| }
|
|
|
|
|