| 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 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 408 | 408 |
| 409 // Parse incoming GIF data stream into internal data structures. | 409 // Parse incoming GIF data stream into internal data structures. |
| 410 // Return true if parsing has progressed or there is not enough data. | 410 // Return true if parsing has progressed or there is not enough data. |
| 411 // Return false if a fatal error is encountered. | 411 // Return false if a fatal error is encountered. |
| 412 bool SkGifImageReader::parse(SkGifImageReader::SkGIFParseQuery query) | 412 bool SkGifImageReader::parse(SkGifImageReader::SkGIFParseQuery query) |
| 413 { | 413 { |
| 414 if (m_parseCompleted) { | 414 if (m_parseCompleted) { |
| 415 return true; | 415 return true; |
| 416 } | 416 } |
| 417 | 417 |
| 418 if (SkGIFLoopCountQuery == query && m_loopCount != cLoopCountNotSeen) { |
| 419 // Loop count has already been parsed. |
| 420 return true; |
| 421 } |
| 422 |
| 418 // SkGIFSizeQuery and SkGIFFrameCountQuery are negative, so this is only mea
ningful when >= 0. | 423 // SkGIFSizeQuery and SkGIFFrameCountQuery are negative, so this is only mea
ningful when >= 0. |
| 419 const int lastFrameToParse = (int) query; | 424 const int lastFrameToParse = (int) query; |
| 420 if (lastFrameToParse >= 0 && (int) m_frames.size() > lastFrameToParse | 425 if (lastFrameToParse >= 0 && (int) m_frames.size() > lastFrameToParse |
| 421 && m_frames[lastFrameToParse]->isComplete()) { | 426 && m_frames[lastFrameToParse]->isComplete()) { |
| 422 // We have already parsed this frame. | 427 // We have already parsed this frame. |
| 423 return true; | 428 return true; |
| 424 } | 429 } |
| 425 | 430 |
| 426 while (true) { | 431 while (true) { |
| 427 const size_t bytesBuffered = m_streamBuffer.buffer(m_bytesToConsume); | 432 const size_t bytesBuffered = m_streamBuffer.buffer(m_bytesToConsume); |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 657 reinterpret_cast<const unsigned char*>(m_streamBuffer.get()); | 662 reinterpret_cast<const unsigned char*>(m_streamBuffer.get()); |
| 658 | 663 |
| 659 int netscapeExtension = currentComponent[0] & 7; | 664 int netscapeExtension = currentComponent[0] & 7; |
| 660 | 665 |
| 661 // Loop entire animation specified # of times. Only read the loop co
unt during the first iteration. | 666 // Loop entire animation specified # of times. Only read the loop co
unt during the first iteration. |
| 662 if (netscapeExtension == 1) { | 667 if (netscapeExtension == 1) { |
| 663 m_loopCount = GETINT16(currentComponent + 1); | 668 m_loopCount = GETINT16(currentComponent + 1); |
| 664 | 669 |
| 665 // Zero loop count is infinite animation loop request. | 670 // Zero loop count is infinite animation loop request. |
| 666 if (!m_loopCount) | 671 if (!m_loopCount) |
| 667 m_loopCount = SkCodecAnimation::kAnimationLoopInfinite; | 672 m_loopCount = SkCodec::kRepetitionCountInfinite; |
| 668 | 673 |
| 669 GETN(1, SkGIFNetscapeExtensionBlock); | 674 GETN(1, SkGIFNetscapeExtensionBlock); |
| 675 |
| 676 if (SkGIFLoopCountQuery == query) { |
| 677 m_streamBuffer.flush(); |
| 678 return true; |
| 679 } |
| 670 } else if (netscapeExtension == 2) { | 680 } else if (netscapeExtension == 2) { |
| 671 // Wait for specified # of bytes to enter buffer. | 681 // Wait for specified # of bytes to enter buffer. |
| 672 | 682 |
| 673 // Don't do this, this extension doesn't exist (isn't used at al
l) | 683 // Don't do this, this extension doesn't exist (isn't used at al
l) |
| 674 // and doesn't do anything, as our streaming/buffering takes car
e of it all... | 684 // and doesn't do anything, as our streaming/buffering takes car
e of it all... |
| 675 // See: http://semmix.pl/color/exgraf/eeg24.htm | 685 // See: http://semmix.pl/color/exgraf/eeg24.htm |
| 676 GETN(1, SkGIFNetscapeExtensionBlock); | 686 GETN(1, SkGIFNetscapeExtensionBlock); |
| 677 } else { | 687 } else { |
| 678 // 0,3-7 are yet to be defined netscape extension codes | 688 // 0,3-7 are yet to be defined netscape extension codes |
| 679 // This prevents attempting to continue reading this invalid str
eam. | 689 // This prevents attempting to continue reading this invalid str
eam. |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 965 rowsRemaining = m_frameContext->height(); | 975 rowsRemaining = m_frameContext->height(); |
| 966 | 976 |
| 967 // Clearing the whole suffix table lets us be more tolerant of bad data. | 977 // Clearing the whole suffix table lets us be more tolerant of bad data. |
| 968 for (int i = 0; i < clearCode; ++i) { | 978 for (int i = 0; i < clearCode; ++i) { |
| 969 suffix[i] = i; | 979 suffix[i] = i; |
| 970 suffixLength[i] = 1; | 980 suffixLength[i] = 1; |
| 971 } | 981 } |
| 972 return true; | 982 return true; |
| 973 } | 983 } |
| 974 | 984 |
| OLD | NEW |