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

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: nits Created 4 years, 5 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
« no previous file with comments | « third_party/WebKit/Source/platform/image-decoders/ImageFrame.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 72f2c834ae95c11df7e2e03cee1975a0e5591c08..7b4f71f0a7fa3aa837fba4315afc042910cd12a0 100644
--- a/third_party/WebKit/Source/platform/image-decoders/gif/GIFImageDecoder.cpp
+++ b/third_party/WebKit/Source/platform/image-decoders/gif/GIFImageDecoder.cpp
@@ -356,12 +356,21 @@ bool GIFImageDecoder::initFrameBuffer(size_t frameIndex)
if (!buffer->setSize(size().width(), size().height()))
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))
- return setFailed();
+ if (buffer->getDisposalMethod() == ImageFrame::DisposeOverwritePrevious) {
+ // The next frame will also use |prevBuffer| as its starting state,
+ // so we can't take over its image data as we do below. Copy the
+ // data instead.
+ if (!buffer->copyBitmapData(*prevBuffer))
+ return setFailed();
+ } else {
+ // This is the only frame to use |prevBuffer| as its starting state,
+ // and we'll always clear the old frame data after initializing this
+ // frame anyway, so we can save time by just moving its data over.
Peter Kasting 2016/07/20 01:00:28 Nit: I still think you should explicitly say what
+ buffer->takeBitmapData(prevBuffer);
+ }
if (prevBuffer->getDisposalMethod() == ImageFrame::DisposeOverwriteBgcolor) {
// We want to clear the previous frame to transparent, without
« no previous file with comments | « third_party/WebKit/Source/platform/image-decoders/ImageFrame.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698