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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/gpu/SkGr.cpp ('k') | src/images/SkImageDecoder_libpng.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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;
252 if (colorCount > 256) {
253 colorCount = 256; // our kIndex8 can't support more
254 }
251 255
252 colorCount = cmap->ColorCount; 256 SkPMColor colorPtr[256]; // storage for worst-case
253 SkAutoTMalloc<SkPMColor> colorStorage(colorCount); 257 SkAlphaType alphaType = kOpaque_SkAlphaType;
254 SkPMColor* colorPtr = colorStorage.get();
255 for (int index = 0; index < colorCount; index++) { 258 for (int index = 0; index < colorCount; index++) {
256 colorPtr[index] = SkPackARGB32(0xFF, 259 colorPtr[index] = SkPackARGB32(0xFF,
257 cmap->Colors[index].Red, 260 cmap->Colors[index].Red,
258 cmap->Colors[index].Green, 261 cmap->Colors[index].Green,
259 cmap->Colors[index].Blue); 262 cmap->Colors[index].Blue);
260 } 263 }
261 264
262 transpIndex = find_transpIndex(temp_save, colorCount); 265 transpIndex = find_transpIndex(temp_save, colorCount);
263 bool reallyHasAlpha = transpIndex >= 0; 266 bool reallyHasAlpha = transpIndex >= 0;
264 if (reallyHasAlpha) { 267 if (reallyHasAlpha) {
265 colorPtr[transpIndex] = SK_ColorTRANSPARENT; // ram in a tra nsparent SkPMColor 268 colorPtr[transpIndex] = SK_ColorTRANSPARENT; // ram in a tra nsparent SkPMColor
269 alphaType = kPremul_SkAlphaType;
266 } 270 }
267 271
268 SkAutoTUnref<SkColorTable> ctable(SkNEW_ARGS(SkColorTable, (colo rPtr, colorCount))); 272 SkAutoTUnref<SkColorTable> ctable(SkNEW_ARGS(SkColorTable,
269 ctable->setIsOpaque(!reallyHasAlpha); 273 (colorPtr, colorCount,
274 alphaType)));
270 if (!this->allocPixelRef(bm, ctable)) { 275 if (!this->allocPixelRef(bm, ctable)) {
271 return error_return(gif, *bm, "allocPixelRef"); 276 return error_return(gif, *bm, "allocPixelRef");
272 } 277 }
273 } 278 }
274 279
275 const int innerWidth = desc.Width; 280 const int innerWidth = desc.Width;
276 const int innerHeight = desc.Height; 281 const int innerHeight = desc.Height;
277 282
278 // abort if either inner dimension is <= 0 283 // abort if either inner dimension is <= 0
279 if (innerWidth <= 0 || innerHeight <= 0) { 284 if (innerWidth <= 0 || innerHeight <= 0) {
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 static SkImageDecoder_DecodeReg gReg(sk_libgif_dfactory); 440 static SkImageDecoder_DecodeReg gReg(sk_libgif_dfactory);
436 441
437 static SkImageDecoder::Format get_format_gif(SkStreamRewindable* stream) { 442 static SkImageDecoder::Format get_format_gif(SkStreamRewindable* stream) {
438 if (is_gif(stream)) { 443 if (is_gif(stream)) {
439 return SkImageDecoder::kGIF_Format; 444 return SkImageDecoder::kGIF_Format;
440 } 445 }
441 return SkImageDecoder::kUnknown_Format; 446 return SkImageDecoder::kUnknown_Format;
442 } 447 }
443 448
444 static SkImageDecoder_FormatReg gFormatReg(get_format_gif); 449 static SkImageDecoder_FormatReg gFormatReg(get_format_gif);
OLDNEW
« 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