OLD | NEW |
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 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 blink::GIFImageDecoder* client, | 333 blink::GIFImageDecoder* client, |
334 bool* frameDecoded) { | 334 bool* frameDecoded) { |
335 m_localColorMap.buildTable(reader); | 335 m_localColorMap.buildTable(reader); |
336 | 336 |
337 *frameDecoded = false; | 337 *frameDecoded = false; |
338 if (!m_lzwContext) { | 338 if (!m_lzwContext) { |
339 // Wait for more data to properly initialize GIFLZWContext. | 339 // Wait for more data to properly initialize GIFLZWContext. |
340 if (!isDataSizeDefined() || !isHeaderDefined()) | 340 if (!isDataSizeDefined() || !isHeaderDefined()) |
341 return true; | 341 return true; |
342 | 342 |
343 m_lzwContext = makeUnique<GIFLZWContext>(client, this); | 343 m_lzwContext = WTF::makeUnique<GIFLZWContext>(client, this); |
344 if (!m_lzwContext->prepareToDecode()) { | 344 if (!m_lzwContext->prepareToDecode()) { |
345 m_lzwContext.reset(); | 345 m_lzwContext.reset(); |
346 return false; | 346 return false; |
347 } | 347 } |
348 | 348 |
349 m_currentLzwBlock = 0; | 349 m_currentLzwBlock = 0; |
350 } | 350 } |
351 | 351 |
352 // Some bad GIFs have extra blocks beyond the last row, which we don't want to | 352 // Some bad GIFs have extra blocks beyond the last row, which we don't want to |
353 // decode. | 353 // decode. |
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
827 return true; | 827 return true; |
828 } | 828 } |
829 | 829 |
830 void GIFImageReader::setRemainingBytes(size_t remainingBytes) { | 830 void GIFImageReader::setRemainingBytes(size_t remainingBytes) { |
831 ASSERT(remainingBytes <= m_data->size()); | 831 ASSERT(remainingBytes <= m_data->size()); |
832 m_bytesRead = m_data->size() - remainingBytes; | 832 m_bytesRead = m_data->size() - remainingBytes; |
833 } | 833 } |
834 | 834 |
835 void GIFImageReader::addFrameIfNecessary() { | 835 void GIFImageReader::addFrameIfNecessary() { |
836 if (m_frames.isEmpty() || m_frames.back()->isComplete()) | 836 if (m_frames.isEmpty() || m_frames.back()->isComplete()) |
837 m_frames.append(wrapUnique(new GIFFrameContext(m_frames.size()))); | 837 m_frames.append(WTF::wrapUnique(new GIFFrameContext(m_frames.size()))); |
838 } | 838 } |
839 | 839 |
840 // FIXME: Move this method to close to doLZW(). | 840 // FIXME: Move this method to close to doLZW(). |
841 bool GIFLZWContext::prepareToDecode() { | 841 bool GIFLZWContext::prepareToDecode() { |
842 ASSERT(m_frameContext->isDataSizeDefined() && | 842 ASSERT(m_frameContext->isDataSizeDefined() && |
843 m_frameContext->isHeaderDefined()); | 843 m_frameContext->isHeaderDefined()); |
844 | 844 |
845 // Since we use a codesize of 1 more than the datasize, we need to ensure | 845 // Since we use a codesize of 1 more than the datasize, we need to ensure |
846 // that our datasize is strictly less than the MAX_DICTIONARY_ENTRY_BITS. | 846 // that our datasize is strictly less than the MAX_DICTIONARY_ENTRY_BITS. |
847 if (m_frameContext->dataSize() >= MAX_DICTIONARY_ENTRY_BITS) | 847 if (m_frameContext->dataSize() >= MAX_DICTIONARY_ENTRY_BITS) |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
881 rowIter = rowBuffer.begin(); | 881 rowIter = rowBuffer.begin(); |
882 rowsRemaining = m_frameContext->height(); | 882 rowsRemaining = m_frameContext->height(); |
883 | 883 |
884 // Clearing the whole suffix table lets us be more tolerant of bad data. | 884 // Clearing the whole suffix table lets us be more tolerant of bad data. |
885 for (int i = 0; i < clearCode; ++i) { | 885 for (int i = 0; i < clearCode; ++i) { |
886 suffix[i] = i; | 886 suffix[i] = i; |
887 suffixLength[i] = 1; | 887 suffixLength[i] = 1; |
888 } | 888 } |
889 return true; | 889 return true; |
890 } | 890 } |
OLD | NEW |