Chromium Code Reviews| Index: Source/platform/graphics/ImageFrameGenerator.cpp |
| diff --git a/Source/platform/graphics/ImageFrameGenerator.cpp b/Source/platform/graphics/ImageFrameGenerator.cpp |
| index 46e281b4f5ad6ca3dbc0987c93883a982d2a18fb..dc398375c233718af9fed41d54f848ea78770b33 100644 |
| --- a/Source/platform/graphics/ImageFrameGenerator.cpp |
| +++ b/Source/platform/graphics/ImageFrameGenerator.cpp |
| @@ -90,6 +90,7 @@ ImageFrameGenerator::ImageFrameGenerator(const SkISize& fullSize, PassRefPtr<Sha |
| , m_isMultiFrame(isMultiFrame) |
| , m_decodeFailedAndEmpty(false) |
| , m_decodeCount(0) |
| + , m_framesCount(0) |
| { |
| setData(data.get(), allDataReceived); |
| } |
| @@ -204,6 +205,9 @@ SkBitmap ImageFrameGenerator::tryToResumeDecode(const SkISize& scaledSize, size_ |
| if (!decoder) |
| return SkBitmap(); |
| + if (index >= m_frameComplete.size()) |
| + m_frameComplete.resize(index + 1); |
| + m_frameComplete[index] = complete; |
| // If we are not resuming decoding that means the decoder is freshly |
| // created and we have ownership. If we are resuming decoding then |
| @@ -225,11 +229,24 @@ SkBitmap ImageFrameGenerator::tryToResumeDecode(const SkISize& scaledSize, size_ |
| // If the image generated is complete then there is no need to keep |
| // the decoder. The exception is multi-frame decoder which can generate |
|
Alpha Left Google
2014/11/05 00:31:00
This comment needs to be updated. Please doucment
Zhenyu Shan
2014/11/05 06:49:09
Done.
|
| // multiple complete frames. |
| - const bool removeDecoder = complete && !m_isMultiFrame; |
| + bool removeDecoder; |
| + |
| + if (m_isMultiFrame) { |
| + size_t decodedFrameCount = 0; |
| + for (Vector<bool>::iterator it = m_frameComplete.begin(); it != m_frameComplete.end(); ++it) { |
| + if (*it) |
| + decodedFrameCount++; |
| + } |
| + removeDecoder = m_framesCount && (decodedFrameCount == m_framesCount); |
| + } else { |
| + removeDecoder = complete; |
| + } |
| if (resumeDecoding) { |
| - if (removeDecoder) |
| + if (removeDecoder) { |
| ImageDecodingStore::instance()->removeDecoder(this, decoder); |
| + m_frameComplete.clear(); |
| + } |
| else |
| ImageDecodingStore::instance()->unlockDecoder(this, decoder); |
| } else if (!removeDecoder) { |
| @@ -282,6 +299,11 @@ bool ImageFrameGenerator::decode(size_t index, ImageDecoder** decoder, SkBitmap* |
| (*decoder)->setData(data, allDataReceived); |
| ImageFrame* frame = (*decoder)->frameBufferAtIndex(index); |
| + if (allDataReceived) { |
| + m_framesCount = (*decoder)->frameCount(); |
|
Alpha Left Google
2014/11/05 00:31:00
Please add a comment to explain why. The reason of
Zhenyu Shan
2014/11/05 06:49:09
Done.
|
| + m_frameComplete.resize(m_framesCount); |
|
Alpha Left Google
2014/11/05 00:31:00
Don't do this. You already have a resize in tryToR
Zhenyu Shan
2014/11/05 06:49:09
Done.
|
| + } |
| + |
| (*decoder)->setData(0, false); // Unref SharedBuffer from ImageDecoder. |
| (*decoder)->clearCacheExceptFrame(index); |
| (*decoder)->setMemoryAllocator(0); |