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

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

Issue 2436183002: Write transparent pixels more often (SkGifCodec) (Closed)
Patch Set: Rebase 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 | « third_party/gif/SkGifImageReader.h ('k') | 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 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 drowStart = 0; 139 drowStart = 0;
140 140
141 if ((unsigned)drowEnd >= m_frameContext->height()) 141 if ((unsigned)drowEnd >= m_frameContext->height())
142 drowEnd = m_frameContext->height() - 1; 142 drowEnd = m_frameContext->height() - 1;
143 } 143 }
144 144
145 // Protect against too much image data. 145 // Protect against too much image data.
146 if ((unsigned)drowStart >= m_frameContext->height()) 146 if ((unsigned)drowStart >= m_frameContext->height())
147 return true; 147 return true;
148 148
149 bool writeTransparentPixels = alwaysWriteTransparentPixels ||
150 (m_frameContext->progressiveDisplay() && m_frameContext->interlaced( ) && ipass > 1);
149 // CALLBACK: Let the client know we have decoded a row. 151 // CALLBACK: Let the client know we have decoded a row.
150 if (!m_client->haveDecodedRow(m_frameContext->frameId(), rowBegin, 152 if (!m_client->haveDecodedRow(m_frameContext->frameId(), rowBegin,
151 drowStart, drowEnd - drowStart + 1, m_frameContext->progressiveDisplay() && m_frameContext->interlaced() && ipass > 1)) 153 drowStart, drowEnd - drowStart + 1, writeTransparentPixels))
152 return false; 154 return false;
153 155
154 if (!m_frameContext->interlaced()) 156 if (!m_frameContext->interlaced())
155 irow++; 157 irow++;
156 else { 158 else {
157 do { 159 do {
158 switch (ipass) { 160 switch (ipass) {
159 case 1: 161 case 1:
160 irow += 8; 162 irow += 8;
161 if (irow >= m_frameContext->height()) { 163 if (irow >= m_frameContext->height()) {
(...skipping 735 matching lines...) Expand 10 before | Expand all | Expand 10 after
897 if (m_frameContext->dataSize() >= SK_MAX_DICTIONARY_ENTRY_BITS) 899 if (m_frameContext->dataSize() >= SK_MAX_DICTIONARY_ENTRY_BITS)
898 return false; 900 return false;
899 clearCode = 1 << m_frameContext->dataSize(); 901 clearCode = 1 << m_frameContext->dataSize();
900 avail = clearCode + 2; 902 avail = clearCode + 2;
901 oldcode = -1; 903 oldcode = -1;
902 codesize = m_frameContext->dataSize() + 1; 904 codesize = m_frameContext->dataSize() + 1;
903 codemask = (1 << codesize) - 1; 905 codemask = (1 << codesize) - 1;
904 datum = bits = 0; 906 datum = bits = 0;
905 ipass = m_frameContext->interlaced() ? 1 : 0; 907 ipass = m_frameContext->interlaced() ? 1 : 0;
906 irow = 0; 908 irow = 0;
909 alwaysWriteTransparentPixels = !m_frameContext->interlaced()
910 && m_frameContext->getRequiredFrame() == SkCodec::kNone;
907 911
908 // We want to know the longest sequence encodable by a dictionary with 912 // We want to know the longest sequence encodable by a dictionary with
909 // SK_MAX_DICTIONARY_ENTRIES entries. If we ignore the need to encode the ba se 913 // SK_MAX_DICTIONARY_ENTRIES entries. If we ignore the need to encode the ba se
910 // values themselves at the beginning of the dictionary, as well as the need 914 // values themselves at the beginning of the dictionary, as well as the need
911 // for a clear code or a termination code, we could use every entry to 915 // for a clear code or a termination code, we could use every entry to
912 // encode a series of multiple values. If the input value stream looked 916 // encode a series of multiple values. If the input value stream looked
913 // like "AAAAA..." (a long string of just one value), the first dictionary 917 // like "AAAAA..." (a long string of just one value), the first dictionary
914 // entry would encode AA, the next AAA, the next AAAA, and so forth. Thus 918 // entry would encode AA, the next AAA, the next AAAA, and so forth. Thus
915 // the longest sequence would be SK_MAX_DICTIONARY_ENTRIES + 1 values. 919 // the longest sequence would be SK_MAX_DICTIONARY_ENTRIES + 1 values.
916 // 920 //
(...skipping 15 matching lines...) Expand all
932 rowsRemaining = m_frameContext->height(); 936 rowsRemaining = m_frameContext->height();
933 937
934 // Clearing the whole suffix table lets us be more tolerant of bad data. 938 // Clearing the whole suffix table lets us be more tolerant of bad data.
935 for (int i = 0; i < clearCode; ++i) { 939 for (int i = 0; i < clearCode; ++i) {
936 suffix[i] = i; 940 suffix[i] = i;
937 suffixLength[i] = 1; 941 suffixLength[i] = 1;
938 } 942 }
939 return true; 943 return true;
940 } 944 }
941 945
OLDNEW
« no previous file with comments | « third_party/gif/SkGifImageReader.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698