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

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: +webp. fix test failures. Created 4 years, 4 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..4bce6ba97fca0811b9e952ec6eafd03677c65e61 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,17 @@ 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))
- return setFailed();
+ // We try to reuse |prevBuffer| as starting state and avoid copy.
Peter Kasting 2016/08/26 19:04:04 See comments in WebP decoder, they also apply to t
aleksandar.stojiljkovic 2016/08/26 21:53:51 Done.
+ // 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)) {
+ if (!buffer->copyBitmapData(*prevBuffer))
+ return setFailed();
+ }
if (prevBuffer->getDisposalMethod() == ImageFrame::DisposeOverwriteBgcolor) {
// We want to clear the previous frame to transparent, without

Powered by Google App Engine
This is Rietveld 408576698