Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(185)

Unified Diff: third_party/WebKit/Source/platform/image-decoders/gif/GIFImageDecoder.cpp

Issue 2155973002: Save a bitmap copy when advancing to dependent GIF and WebP animation frames (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: DCHECK m_status in ImageFrame. Shortened commit message. Thanks kbr@. Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/platform/image-decoders/gif/GIFImageDecoder.cpp
diff --git a/third_party/WebKit/Source/platform/image-decoders/gif/GIFImageDecoder.cpp b/third_party/WebKit/Source/platform/image-decoders/gif/GIFImageDecoder.cpp
index a769b6d09bb28180c851a3f3e7128ba6077dbcf1..ba4cca2bb13c8da2bcc7cbc66cdad6fd869999b3 100644
--- a/third_party/WebKit/Source/platform/image-decoders/gif/GIFImageDecoder.cpp
+++ b/third_party/WebKit/Source/platform/image-decoders/gif/GIFImageDecoder.cpp
@@ -356,11 +356,14 @@ bool GIFImageDecoder::initFrameBuffer(size_t frameIndex)
if (!buffer->setSizeAndColorProfile(size().width(), size().height(), ImageFrame::ICCProfile()))
return setFailed();
} else {
- const ImageFrame* prevBuffer = &m_frameBufferCache[requiredPreviousFrameIndex];
+ ImageFrame* prevBuffer = &m_frameBufferCache[requiredPreviousFrameIndex];
ASSERT(prevBuffer->getStatus() == ImageFrame::FrameComplete);
- // Preserve the last frame as the starting state for this frame.
- if (!buffer->copyBitmapData(*prevBuffer))
+ // We try to reuse |prevBuffer| as starting state to avoid copying.
+ // For DisposeOverwritePrevious, the next frame will also use
+ // |prevBuffer| as its starting state, so we can't take over its image
+ // data using takeBitmapDataIfWritable. Copy the data instead.
+ if ((buffer->getDisposalMethod() == ImageFrame::DisposeOverwritePrevious || !buffer->takeBitmapDataIfWritable(prevBuffer)) && !buffer->copyBitmapData(*prevBuffer))
return setFailed();
if (prevBuffer->getDisposalMethod() == ImageFrame::DisposeOverwriteBgcolor) {

Powered by Google App Engine
This is Rietveld 408576698