Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 | 8 |
| 9 #include "SkColor.h" | 9 #include "SkColor.h" |
| 10 #include "SkColorPriv.h" | 10 #include "SkColorPriv.h" |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 241 return error_return(gif, *bm, "TopLeft"); | 241 return error_return(gif, *bm, "TopLeft"); |
| 242 } | 242 } |
| 243 | 243 |
| 244 // now we decode the colortable | 244 // now we decode the colortable |
| 245 int colorCount = 0; | 245 int colorCount = 0; |
| 246 { | 246 { |
| 247 const ColorMapObject* cmap = find_colormap(gif); | 247 const ColorMapObject* cmap = find_colormap(gif); |
| 248 if (NULL == cmap) { | 248 if (NULL == cmap) { |
| 249 return error_return(gif, *bm, "null cmap"); | 249 return error_return(gif, *bm, "null cmap"); |
| 250 } | 250 } |
| 251 colorCount = cmap->ColorCount; | |
| 251 | 252 |
| 252 colorCount = cmap->ColorCount; | 253 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.
| |
| 253 SkAutoTMalloc<SkPMColor> colorStorage(colorCount); | 254 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
| |
| 254 SkPMColor* colorPtr = colorStorage.get(); | |
| 255 for (int index = 0; index < colorCount; index++) { | 255 for (int index = 0; index < colorCount; index++) { |
| 256 colorPtr[index] = SkPackARGB32(0xFF, | 256 colorPtr[index] = SkPackARGB32(0xFF, |
| 257 cmap->Colors[index].Red, | 257 cmap->Colors[index].Red, |
| 258 cmap->Colors[index].Green, | 258 cmap->Colors[index].Green, |
| 259 cmap->Colors[index].Blue); | 259 cmap->Colors[index].Blue); |
| 260 } | 260 } |
| 261 | 261 |
| 262 transpIndex = find_transpIndex(temp_save, colorCount); | 262 transpIndex = find_transpIndex(temp_save, colorCount); |
| 263 bool reallyHasAlpha = transpIndex >= 0; | 263 bool reallyHasAlpha = transpIndex >= 0; |
| 264 if (reallyHasAlpha) { | 264 if (reallyHasAlpha) { |
| 265 colorPtr[transpIndex] = SK_ColorTRANSPARENT; // ram in a tra nsparent SkPMColor | 265 colorPtr[transpIndex] = SK_ColorTRANSPARENT; // ram in a tra nsparent SkPMColor |
| 266 alphaType = kPremul_SkAlphaType; | |
| 266 } | 267 } |
| 267 | 268 |
| 268 SkAutoTUnref<SkColorTable> ctable(SkNEW_ARGS(SkColorTable, (colo rPtr, colorCount))); | 269 SkAutoTUnref<SkColorTable> ctable(SkNEW_ARGS(SkColorTable, |
| 269 ctable->setIsOpaque(!reallyHasAlpha); | 270 (colorPtr, colorCount, |
| 271 alphaType))); | |
| 270 if (!this->allocPixelRef(bm, ctable)) { | 272 if (!this->allocPixelRef(bm, ctable)) { |
| 271 return error_return(gif, *bm, "allocPixelRef"); | 273 return error_return(gif, *bm, "allocPixelRef"); |
| 272 } | 274 } |
| 273 } | 275 } |
| 274 | 276 |
| 275 const int innerWidth = desc.Width; | 277 const int innerWidth = desc.Width; |
| 276 const int innerHeight = desc.Height; | 278 const int innerHeight = desc.Height; |
| 277 | 279 |
| 278 // abort if either inner dimension is <= 0 | 280 // abort if either inner dimension is <= 0 |
| 279 if (innerWidth <= 0 || innerHeight <= 0) { | 281 if (innerWidth <= 0 || innerHeight <= 0) { |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 435 static SkImageDecoder_DecodeReg gReg(sk_libgif_dfactory); | 437 static SkImageDecoder_DecodeReg gReg(sk_libgif_dfactory); |
| 436 | 438 |
| 437 static SkImageDecoder::Format get_format_gif(SkStreamRewindable* stream) { | 439 static SkImageDecoder::Format get_format_gif(SkStreamRewindable* stream) { |
| 438 if (is_gif(stream)) { | 440 if (is_gif(stream)) { |
| 439 return SkImageDecoder::kGIF_Format; | 441 return SkImageDecoder::kGIF_Format; |
| 440 } | 442 } |
| 441 return SkImageDecoder::kUnknown_Format; | 443 return SkImageDecoder::kUnknown_Format; |
| 442 } | 444 } |
| 443 | 445 |
| 444 static SkImageDecoder_FormatReg gFormatReg(get_format_gif); | 446 static SkImageDecoder_FormatReg gFormatReg(get_format_gif); |
| OLD | NEW |