| 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 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 380 | 380 |
| 381 bool frameDecoded = false; | 381 bool frameDecoded = false; |
| 382 GIFFrameContext* currentFrame = m_frames[frameIndex].get(); | 382 GIFFrameContext* currentFrame = m_frames[frameIndex].get(); |
| 383 | 383 |
| 384 return currentFrame->decode(&reader, m_client, &frameDecoded) | 384 return currentFrame->decode(&reader, m_client, &frameDecoded) |
| 385 && (!frameDecoded || m_client->frameComplete(frameIndex)); | 385 && (!frameDecoded || m_client->frameComplete(frameIndex)); |
| 386 } | 386 } |
| 387 | 387 |
| 388 bool GIFImageReader::parse(GIFImageDecoder::GIFParseQuery query) | 388 bool GIFImageReader::parse(GIFImageDecoder::GIFParseQuery query) |
| 389 { | 389 { |
| 390 ASSERT(m_bytesRead <= m_data->size()); | 390 if (m_bytesRead >= m_data->size()) { |
| 391 // This data has already been parsed. For example, in deferred |
| 392 // decoding, a DecodingImageGenerator with more data may have already |
| 393 // used this same ImageDecoder to decode. This can happen if two |
| 394 // SkImages created by a DeferredImageDecoder are drawn/prerolled |
| 395 // out of order (with respect to how much data they had at creation |
| 396 // time). |
| 397 return !m_client->failed(); |
| 398 } |
| 391 | 399 |
| 392 return parseData(m_bytesRead, m_data->size() - m_bytesRead, query); | 400 return parseData(m_bytesRead, m_data->size() - m_bytesRead, query); |
| 393 } | 401 } |
| 394 | 402 |
| 395 // Parse incoming GIF data stream into internal data structures. | 403 // Parse incoming GIF data stream into internal data structures. |
| 396 // Return true if parsing has progressed or there is not enough data. | 404 // Return true if parsing has progressed or there is not enough data. |
| 397 // Return false if a fatal error is encountered. | 405 // Return false if a fatal error is encountered. |
| 398 bool GIFImageReader::parseData(size_t dataPosition, size_t len, GIFImageDecoder:
:GIFParseQuery query) | 406 bool GIFImageReader::parseData(size_t dataPosition, size_t len, GIFImageDecoder:
:GIFParseQuery query) |
| 399 { | 407 { |
| 400 if (!len) { | 408 if (!len) { |
| (...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 840 rowIter = rowBuffer.begin(); | 848 rowIter = rowBuffer.begin(); |
| 841 rowsRemaining = m_frameContext->height(); | 849 rowsRemaining = m_frameContext->height(); |
| 842 | 850 |
| 843 // Clearing the whole suffix table lets us be more tolerant of bad data. | 851 // Clearing the whole suffix table lets us be more tolerant of bad data. |
| 844 for (int i = 0; i < clearCode; ++i) { | 852 for (int i = 0; i < clearCode; ++i) { |
| 845 suffix[i] = i; | 853 suffix[i] = i; |
| 846 suffixLength[i] = 1; | 854 suffixLength[i] = 1; |
| 847 } | 855 } |
| 848 return true; | 856 return true; |
| 849 } | 857 } |
| OLD | NEW |