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

Unified Diff: src/images/SkImageDecoder_libgif.cpp

Issue 26572006: Revert "Revert "change SkColorTable to be immutable"" (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 2 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 | « src/gpu/SkGr.cpp ('k') | src/images/SkImageDecoder_libpng.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/images/SkImageDecoder_libgif.cpp
diff --git a/src/images/SkImageDecoder_libgif.cpp b/src/images/SkImageDecoder_libgif.cpp
index 08f37efced9fc8bdee36b286dc52ad44f06ac028..ab0fbdaf3f777855d2b8621eed7a1c1c4abe7325 100644
--- a/src/images/SkImageDecoder_libgif.cpp
+++ b/src/images/SkImageDecoder_libgif.cpp
@@ -248,10 +248,13 @@ bool SkGIFImageDecoder::onDecode(SkStream* sk_stream, SkBitmap* bm, Mode mode) {
if (NULL == cmap) {
return error_return(gif, *bm, "null cmap");
}
-
colorCount = cmap->ColorCount;
- SkAutoTMalloc<SkPMColor> colorStorage(colorCount);
- SkPMColor* colorPtr = colorStorage.get();
+ if (colorCount > 256) {
+ colorCount = 256; // our kIndex8 can't support more
+ }
+
+ SkPMColor colorPtr[256]; // storage for worst-case
+ SkAlphaType alphaType = kOpaque_SkAlphaType;
for (int index = 0; index < colorCount; index++) {
colorPtr[index] = SkPackARGB32(0xFF,
cmap->Colors[index].Red,
@@ -263,10 +266,12 @@ bool SkGIFImageDecoder::onDecode(SkStream* sk_stream, SkBitmap* bm, Mode mode) {
bool reallyHasAlpha = transpIndex >= 0;
if (reallyHasAlpha) {
colorPtr[transpIndex] = SK_ColorTRANSPARENT; // ram in a transparent SkPMColor
+ alphaType = kPremul_SkAlphaType;
}
- SkAutoTUnref<SkColorTable> ctable(SkNEW_ARGS(SkColorTable, (colorPtr, colorCount)));
- ctable->setIsOpaque(!reallyHasAlpha);
+ SkAutoTUnref<SkColorTable> ctable(SkNEW_ARGS(SkColorTable,
+ (colorPtr, colorCount,
+ alphaType)));
if (!this->allocPixelRef(bm, ctable)) {
return error_return(gif, *bm, "allocPixelRef");
}
« no previous file with comments | « src/gpu/SkGr.cpp ('k') | src/images/SkImageDecoder_libpng.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698