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

Unified Diff: src/images/SkImageDecoder_libgif.cpp

Issue 25353002: change SkColorTable to be immutable (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: rebase 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
Index: src/images/SkImageDecoder_libgif.cpp
diff --git a/src/images/SkImageDecoder_libgif.cpp b/src/images/SkImageDecoder_libgif.cpp
index 08f37efced9fc8bdee36b286dc52ad44f06ac028..730f52f434f15d1bc47776e6feef1080039260b5 100644
--- a/src/images/SkImageDecoder_libgif.cpp
+++ b/src/images/SkImageDecoder_libgif.cpp
@@ -248,10 +248,10 @@ 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();
+
+ SkPMColor colorPtr[256]; // storage for worst-case
djsollen 2013/10/09 15:42:18 we should assert that colorCount is not greater th
reed1 2013/10/09 15:51:25 Done.
+ SkAlphaType alphaType = kOpaque_SkAlphaType;
djsollen 2013/10/09 15:42:18 is it safe to assume always opaque without checkin
reed1 2013/10/09 15:51:25 That is detected on line 266
for (int index = 0; index < colorCount; index++) {
colorPtr[index] = SkPackARGB32(0xFF,
cmap->Colors[index].Red,
@@ -263,10 +263,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");
}

Powered by Google App Engine
This is Rietveld 408576698