OLD | NEW |
---|---|
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2006 The Android Open Source Project | 3 * Copyright 2006 The Android Open Source Project |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #include "SkImageDecoder.h" | 10 #include "SkImageDecoder.h" |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
218 } | 218 } |
219 | 219 |
220 // now we decode the colortable | 220 // now we decode the colortable |
221 int colorCount = 0; | 221 int colorCount = 0; |
222 { | 222 { |
223 const ColorMapObject* cmap = find_colormap(gif); | 223 const ColorMapObject* cmap = find_colormap(gif); |
224 if (NULL == cmap) { | 224 if (NULL == cmap) { |
225 return error_return(gif, *bm, "null cmap"); | 225 return error_return(gif, *bm, "null cmap"); |
226 } | 226 } |
227 | 227 |
228 SkPMColor colorPtr[256]; // storage for worse-case | |
scroggo
2013/10/07 21:58:42
worst*
reed1
2013/10/09 12:19:54
Done.
| |
228 colorCount = cmap->ColorCount; | 229 colorCount = cmap->ColorCount; |
229 SkColorTable* ctable = SkNEW_ARGS(SkColorTable, (colorCount)); | 230 SkAlphaType alphaType = kOpaque_SkAlphaType; |
230 SkPMColor* colorPtr = ctable->lockColors(); | |
231 for (int index = 0; index < colorCount; index++) | 231 for (int index = 0; index < colorCount; index++) |
232 colorPtr[index] = SkPackARGB32(0xFF, | 232 colorPtr[index] = SkPackARGB32(0xFF, |
233 cmap->Colors[index].Red, | 233 cmap->Colors[index].Red, |
234 cmap->Colors[index].Green, | 234 cmap->Colors[index].Green, |
235 cmap->Colors[index].Blue); | 235 cmap->Colors[index].Blue); |
236 | 236 |
237 transpIndex = find_transpIndex(temp_save, colorCount); | 237 transpIndex = find_transpIndex(temp_save, colorCount); |
238 if (transpIndex < 0) | 238 if (transpIndex >= 0) { |
239 ctable->setFlags(ctable->getFlags() | SkColorTable::kColorsA reOpaque_Flag); | 239 SkASSERT((unsigned)transpIndex < (unsigned)colorCount); |
240 else | |
241 colorPtr[transpIndex] = 0; // ram in a transparent SkPMColor | 240 colorPtr[transpIndex] = 0; // ram in a transparent SkPMColor |
242 ctable->unlockColors(true); | 241 alphaType = kPremul_SkAlphaType; |
242 } | |
243 | 243 |
244 SkAutoUnref aurts(ctable); | 244 SkAutoTUnref<SkColorTable> ctable(SkNEW_ARGS(SkColorTable, |
245 (colorPtr, colorCount, | |
246 alphaType))); | |
245 if (!this->allocPixelRef(bm, ctable)) { | 247 if (!this->allocPixelRef(bm, ctable)) { |
246 return error_return(gif, *bm, "allocPixelRef"); | 248 return error_return(gif, *bm, "allocPixelRef"); |
247 } | 249 } |
248 } | 250 } |
249 | 251 |
250 SkAutoLockPixels alp(*bm); | 252 SkAutoLockPixels alp(*bm); |
251 | 253 |
252 // time to decode the scanlines | 254 // time to decode the scanlines |
253 // | 255 // |
254 uint8_t* scanline = bm->getAddr8(0, 0); | 256 uint8_t* scanline = bm->getAddr8(0, 0); |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
378 static SkImageDecoder_DecodeReg gReg(sk_libgif_dfactory); | 380 static SkImageDecoder_DecodeReg gReg(sk_libgif_dfactory); |
379 | 381 |
380 static SkImageDecoder::Format get_format_gif(SkStreamRewindable* stream) { | 382 static SkImageDecoder::Format get_format_gif(SkStreamRewindable* stream) { |
381 if (is_gif(stream)) { | 383 if (is_gif(stream)) { |
382 return SkImageDecoder::kGIF_Format; | 384 return SkImageDecoder::kGIF_Format; |
383 } | 385 } |
384 return SkImageDecoder::kUnknown_Format; | 386 return SkImageDecoder::kUnknown_Format; |
385 } | 387 } |
386 | 388 |
387 static SkImageDecoder_FormatReg gFormatReg(get_format_gif); | 389 static SkImageDecoder_FormatReg gFormatReg(get_format_gif); |
OLD | NEW |