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

Side by Side Diff: third_party/gif/SkGifImageReader.cpp

Issue 2461813002: Treat a GIF with no color table as transparent (Closed)
Patch Set: Created 4 years, 1 month 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* ***** BEGIN LICENSE BLOCK ***** 2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 * 4 *
5 * The contents of this file are subject to the Mozilla Public License Version 5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with 6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at 7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/ 8 * http://www.mozilla.org/MPL/
9 * 9 *
10 * Software distributed under the License is distributed on an "AS IS" basis, 10 * Software distributed under the License is distributed on an "AS IS" basis,
(...skipping 719 matching lines...) Expand 10 before | Expand all | Expand 10 after
730 } 730 }
731 } 731 }
732 732
733 const bool isLocalColormapDefined = SkToBool(currentComponent[8] & 0 x80); 733 const bool isLocalColormapDefined = SkToBool(currentComponent[8] & 0 x80);
734 // The three low-order bits of currentComponent[8] specify the bits per pixel. 734 // The three low-order bits of currentComponent[8] specify the bits per pixel.
735 const size_t numColors = 2 << (currentComponent[8] & 0x7); 735 const size_t numColors = 2 << (currentComponent[8] & 0x7);
736 if (currentFrameIsFirstFrame()) { 736 if (currentFrameIsFirstFrame()) {
737 bool hasTransparentPixel; 737 bool hasTransparentPixel;
738 if (m_frames.size() == 0) { 738 if (m_frames.size() == 0) {
739 // We did not see a Graphics Control Extension, so no transp arent 739 // We did not see a Graphics Control Extension, so no transp arent
740 // pixel was specified. 740 // pixel was specified. But if there is no color table, this frame is
741 hasTransparentPixel = false; 741 // still transparent.
742 hasTransparentPixel = !isLocalColormapDefined
743 && m_globalColorMap.numColors() == 0;
742 } else { 744 } else {
743 // This means we did see a Graphics Control Extension, which specifies 745 // This means we did see a Graphics Control Extension, which specifies
744 // the transparent pixel 746 // the transparent pixel
745 const size_t transparentPixel = m_frames[0]->transparentPixe l(); 747 const size_t transparentPixel = m_frames[0]->transparentPixe l();
746 if (isLocalColormapDefined) { 748 if (isLocalColormapDefined) {
747 hasTransparentPixel = transparentPixel < numColors; 749 hasTransparentPixel = transparentPixel < numColors;
748 } else { 750 } else {
749 const size_t globalColors = m_globalColorMap.numColors() ; 751 const size_t globalColors = m_globalColorMap.numColors() ;
750 if (!globalColors) { 752 if (!globalColors) {
751 // No color table for this frame, so the frame is em pty. 753 // No color table for this frame, so the frame is em pty.
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
963 rowsRemaining = m_frameContext->height(); 965 rowsRemaining = m_frameContext->height();
964 966
965 // Clearing the whole suffix table lets us be more tolerant of bad data. 967 // Clearing the whole suffix table lets us be more tolerant of bad data.
966 for (int i = 0; i < clearCode; ++i) { 968 for (int i = 0; i < clearCode; ++i) {
967 suffix[i] = i; 969 suffix[i] = i;
968 suffixLength[i] = 1; 970 suffixLength[i] = 1;
969 } 971 }
970 return true; 972 return true;
971 } 973 }
972 974
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698