Index: src/core/SkImageGenerator.cpp |
diff --git a/src/core/SkImageGenerator.cpp b/src/core/SkImageGenerator.cpp |
index 5e401920cd97a68cf5cb5e88e73a3fa9d6092c99..3712c4c46b99c1ca880afe8b5554f5ff365f16d6 100644 |
--- a/src/core/SkImageGenerator.cpp |
+++ b/src/core/SkImageGenerator.cpp |
@@ -177,6 +177,14 @@ bool SkImageGenerator::tryGenerateBitmap(SkBitmap* bitmap, const SkImageInfo* in |
int ctCount = 0; |
if (!this->getPixels(bitmap->info(), bitmap->getPixels(), bitmap->rowBytes(), |
ctStorage, &ctCount)) { |
+ // Generator failing to decode to declared colorType, could decode to N32. |
+ // This is important for Chromium Index8 decoding - GIF multiframe animation frames are |
+ // decoded to Index8 format by default but in rare cases some of the frames are N32. |
+ if (bitmap->colorType() != kN32_SkColorType) { |
+ bitmap->reset(); |
+ info = SkImageInfo::MakeN32(info.width(), info.height(), info.alphaType()); |
+ return tryGenerateBitmap(bitmap, &info, allocator); |
+ } |
return reset_and_return_false(bitmap); |
} |