Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(86)

Unified Diff: src/codec/SkGifCodec.cpp

Issue 1757333002: Fix bug in SkGifCodec / Switch SkImageDec tests to use Codec (Closed) Base URL: https://skia.googlesource.com/skia.git@m50
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tests/BadIcoTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/codec/SkGifCodec.cpp
diff --git a/src/codec/SkGifCodec.cpp b/src/codec/SkGifCodec.cpp
index c7b15e7a22d212a5d256626f600312e4c1f412d0..56d20e927c5033e011fb8c20345dc90b1c2a9ace 100644
--- a/src/codec/SkGifCodec.cpp
+++ b/src/codec/SkGifCodec.cpp
@@ -418,26 +418,30 @@ void SkGifCodec::initializeColorTable(const SkImageInfo& dstInfo, SkPMColor* inp
}
}
- // Gifs have the option to specify the color at a single index of the color
- // table as transparent. If the transparent index is greater than the
- // colorCount, we know that there is no valid transparent color in the color
- // table. If there is not valid transparent index, we will try to use the
- // backgroundIndex as the fill index. If the backgroundIndex is also not
- // valid, we will let fFillIndex default to 0 (it is set to zero in the
- // constructor). This behavior is not specified but matches
- // SkImageDecoder_libgif.
- uint32_t backgroundIndex = fGif->SBackGroundColor;
- if (fTransIndex < colorCount) {
- colorPtr[fTransIndex] = SK_ColorTRANSPARENT;
- fFillIndex = fTransIndex;
- } else if (backgroundIndex < colorCount) {
- fFillIndex = backgroundIndex;
- }
-
// Fill in the color table for indices greater than color count.
// This allows for predictable, safe behavior.
- for (uint32_t i = colorCount; i < maxColors; i++) {
- colorPtr[i] = colorPtr[fFillIndex];
+ if (colorCount > 0) {
+ // Gifs have the option to specify the color at a single index of the color
+ // table as transparent. If the transparent index is greater than the
+ // colorCount, we know that there is no valid transparent color in the color
+ // table. If there is not valid transparent index, we will try to use the
+ // backgroundIndex as the fill index. If the backgroundIndex is also not
+ // valid, we will let fFillIndex default to 0 (it is set to zero in the
+ // constructor). This behavior is not specified but matches
+ // SkImageDecoder_libgif.
+ uint32_t backgroundIndex = fGif->SBackGroundColor;
+ if (fTransIndex < colorCount) {
+ colorPtr[fTransIndex] = SK_ColorTRANSPARENT;
+ fFillIndex = fTransIndex;
+ } else if (backgroundIndex < colorCount) {
+ fFillIndex = backgroundIndex;
+ }
+
+ for (uint32_t i = colorCount; i < maxColors; i++) {
+ colorPtr[i] = colorPtr[fFillIndex];
+ }
+ } else {
+ sk_memset32(colorPtr, 0xFF000000, maxColors);
}
fColorTable.reset(new SkColorTable(colorPtr, maxColors));
« no previous file with comments | « no previous file | tests/BadIcoTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698