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

Side by Side Diff: src/images/SkImageDecoder_libgif.cpp

Issue 611093002: remove alphatype from colortable (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: update codecs Created 6 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
« no previous file with comments | « src/core/SkReadBuffer.h ('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 #include "SkColor.h" 8 #include "SkColor.h"
9 #include "SkColorPriv.h" 9 #include "SkColorPriv.h"
10 #include "SkColorTable.h" 10 #include "SkColorTable.h"
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 return true; 325 return true;
326 } 326 }
327 327
328 328
329 // now we decode the colortable 329 // now we decode the colortable
330 int colorCount = 0; 330 int colorCount = 0;
331 { 331 {
332 // Declare colorPtr here for scope. 332 // Declare colorPtr here for scope.
333 SkPMColor colorPtr[256]; // storage for worst-case 333 SkPMColor colorPtr[256]; // storage for worst-case
334 const ColorMapObject* cmap = find_colormap(gif); 334 const ColorMapObject* cmap = find_colormap(gif);
335 SkAlphaType alphaType = kOpaque_SkAlphaType;
336 if (cmap != NULL) { 335 if (cmap != NULL) {
337 SkASSERT(cmap->ColorCount == (1 << (cmap->BitsPerPixel))); 336 SkASSERT(cmap->ColorCount == (1 << (cmap->BitsPerPixel)));
338 colorCount = cmap->ColorCount; 337 colorCount = cmap->ColorCount;
339 if (colorCount > 256) { 338 if (colorCount > 256) {
340 colorCount = 256; // our kIndex8 can't support more 339 colorCount = 256; // our kIndex8 can't support more
341 } 340 }
342 for (int index = 0; index < colorCount; index++) { 341 for (int index = 0; index < colorCount; index++) {
343 colorPtr[index] = SkPackARGB32(0xFF, 342 colorPtr[index] = SkPackARGB32(0xFF,
344 cmap->Colors[index].Red, 343 cmap->Colors[index].Red,
345 cmap->Colors[index].Green , 344 cmap->Colors[index].Green ,
346 cmap->Colors[index].Blue) ; 345 cmap->Colors[index].Blue) ;
347 } 346 }
348 } else { 347 } else {
349 // find_colormap() returned NULL. Some (rare, broken) 348 // find_colormap() returned NULL. Some (rare, broken)
350 // GIFs don't have a color table, so we force one. 349 // GIFs don't have a color table, so we force one.
351 gif_warning(*bm, "missing colormap"); 350 gif_warning(*bm, "missing colormap");
352 colorCount = 256; 351 colorCount = 256;
353 sk_memset32(colorPtr, SK_ColorWHITE, colorCount); 352 sk_memset32(colorPtr, SK_ColorWHITE, colorCount);
354 } 353 }
355 transpIndex = find_transpIndex(temp_save, colorCount); 354 transpIndex = find_transpIndex(temp_save, colorCount);
356 if (transpIndex >= 0) { 355 if (transpIndex >= 0) {
357 colorPtr[transpIndex] = SK_ColorTRANSPARENT; // ram in a tra nsparent SkPMColor 356 colorPtr[transpIndex] = SK_ColorTRANSPARENT; // ram in a tra nsparent SkPMColor
358 alphaType = kPremul_SkAlphaType;
359 fillIndex = transpIndex; 357 fillIndex = transpIndex;
360 } else if (fillIndex >= colorCount) { 358 } else if (fillIndex >= colorCount) {
361 // gif->SBackGroundColor should be less than colorCount. 359 // gif->SBackGroundColor should be less than colorCount.
362 fillIndex = 0; // If not, fix it. 360 fillIndex = 0; // If not, fix it.
363 } 361 }
364 362
365 SkAutoTUnref<SkColorTable> ctable(SkNEW_ARGS(SkColorTable, 363 SkAutoTUnref<SkColorTable> ctable(SkNEW_ARGS(SkColorTable, (colo rPtr, colorCount)));
366 (colorPtr, colorCount,
367 alphaType)));
368 if (!this->allocPixelRef(bm, ctable)) { 364 if (!this->allocPixelRef(bm, ctable)) {
369 return error_return(*bm, "allocPixelRef"); 365 return error_return(*bm, "allocPixelRef");
370 } 366 }
371 } 367 }
372 368
373 // abort if either inner dimension is <= 0 369 // abort if either inner dimension is <= 0
374 if (innerWidth <= 0 || innerHeight <= 0) { 370 if (innerWidth <= 0 || innerHeight <= 0) {
375 return error_return(*bm, "non-pos inner width/height"); 371 return error_return(*bm, "non-pos inner width/height");
376 } 372 }
377 373
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
531 static SkImageDecoder_DecodeReg gReg(sk_libgif_dfactory); 527 static SkImageDecoder_DecodeReg gReg(sk_libgif_dfactory);
532 528
533 static SkImageDecoder::Format get_format_gif(SkStreamRewindable* stream) { 529 static SkImageDecoder::Format get_format_gif(SkStreamRewindable* stream) {
534 if (is_gif(stream)) { 530 if (is_gif(stream)) {
535 return SkImageDecoder::kGIF_Format; 531 return SkImageDecoder::kGIF_Format;
536 } 532 }
537 return SkImageDecoder::kUnknown_Format; 533 return SkImageDecoder::kUnknown_Format;
538 } 534 }
539 535
540 static SkImageDecoder_FormatReg gFormatReg(get_format_gif); 536 static SkImageDecoder_FormatReg gFormatReg(get_format_gif);
OLDNEW
« no previous file with comments | « src/core/SkReadBuffer.h ('k') | src/images/SkImageDecoder_libpng.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698