Index: Source/core/platform/image-decoders/gif/GIFImageReader.cpp |
diff --git a/Source/core/platform/image-decoders/gif/GIFImageReader.cpp b/Source/core/platform/image-decoders/gif/GIFImageReader.cpp |
index 1a7268a19ba20c71a3e76a1bbd410d6ca1fe63cf..c21eafc618bb9cb61e6c11da76b58c5f802cf0c2 100644 |
--- a/Source/core/platform/image-decoders/gif/GIFImageReader.cpp |
+++ b/Source/core/platform/image-decoders/gif/GIFImageReader.cpp |
@@ -351,45 +351,34 @@ bool GIFFrameContext::decode(const unsigned char* data, size_t length, WebCore:: |
return true; |
} |
-// Decode all frames before haltAtFrame. |
-// This method uses GIFFrameContext:decode() to decode each frame; decoding error is reported to client as a critical failure. |
+// Decode a frame. |
+// This method uses GIFFrameContext:decode() to decode the frame; decoding error is reported to client as a critical failure. |
// Return true if decoding has progressed. Return false if an error has occurred. |
-bool GIFImageReader::decode(GIFImageDecoder::GIFQuery query, unsigned haltAtFrame) |
+bool GIFImageReader::decode(size_t frameIndex) |
{ |
- ASSERT(m_bytesRead <= m_data->size()); |
+ bool frameDecoded = false; |
+ GIFFrameContext* currentFrame = m_frames[frameIndex].get(); |
- if (!parse(m_bytesRead, m_data->size() - m_bytesRead, query == GIFImageDecoder::GIFSizeQuery)) |
+ if (!currentFrame->decode(data(0), m_data->size(), m_client, &frameDecoded)) |
Peter Kasting
2013/05/24 03:15:22
Nit: Simpler:
return currentFrame->decode(dat
Xianzhu
2013/05/28 22:54:21
Done.
|
return false; |
- if (query != GIFImageDecoder::GIFFullQuery) |
- return true; |
- |
- while (m_currentDecodingFrame < std::min(m_frames.size(), static_cast<size_t>(haltAtFrame))) { |
- bool frameDecoded = false; |
- GIFFrameContext* currentFrame = m_frames[m_currentDecodingFrame].get(); |
- |
- if (!currentFrame->decode(data(0), m_data->size(), m_client, &frameDecoded)) |
- return false; |
+ if (frameDecoded && !m_client->frameComplete(frameIndex)) |
+ return false; |
- // We need more data to continue decoding. |
- if (!frameDecoded) |
- break; |
+ return true; |
+} |
- if (!m_client->frameComplete(m_currentDecodingFrame, currentFrame->delayTime, currentFrame->disposalMethod)) |
- return false; |
- ++m_currentDecodingFrame; |
- } |
+bool GIFImageReader::parse(GIFImageDecoder::GIFParseQuery query) |
+{ |
+ ASSERT(m_bytesRead <= m_data->size()); |
- // All frames decoded. |
- if (m_currentDecodingFrame == m_frames.size() && m_parseCompleted) |
- m_client->gifComplete(); |
- return true; |
+ return parseData(m_bytesRead, m_data->size() - m_bytesRead, query); |
} |
// Parse incoming GIF data stream into internal data structures. |
// Return true if parsing has progressed or there is not enough data. |
// Return false if a fatal error is encountered. |
-bool GIFImageReader::parse(size_t dataPosition, size_t len, bool parseSizeOnly) |
+bool GIFImageReader::parseData(size_t dataPosition, size_t len, GIFImageDecoder::GIFParseQuery query) |
{ |
if (!len) { |
// No new data has come in since the last call, just ignore this call. |
@@ -676,7 +665,7 @@ bool GIFImageReader::parse(size_t dataPosition, size_t len, bool parseSizeOnly) |
return false; |
} |
- if (parseSizeOnly) { |
+ if (query == GIFImageDecoder::GIFSizeQuery) { |
// The decoder needs to stop. Hand back the number of bytes we consumed from |
// buffer minus 9 (the amount we consumed to read the header). |
setRemainingBytes(len + 9); |