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

Unified Diff: third_party/WebKit/Source/platform/image-decoders/webp/WEBPImageDecoder.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
« no previous file with comments | « third_party/WebKit/Source/platform/image-decoders/gif/GIFImageDecoder.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/webp/WEBPImageDecoder.cpp
diff --git a/third_party/WebKit/Source/platform/image-decoders/webp/WEBPImageDecoder.cpp b/third_party/WebKit/Source/platform/image-decoders/webp/WEBPImageDecoder.cpp
index 1e55c716838dfe0a1dfd4ad611bfa2dad053086c..38045ba73c1c17799c01e3044e5ea702cd666367 100644
--- a/third_party/WebKit/Source/platform/image-decoders/webp/WEBPImageDecoder.cpp
+++ b/third_party/WebKit/Source/platform/image-decoders/webp/WEBPImageDecoder.cpp
@@ -252,11 +252,14 @@ bool WEBPImageDecoder::initFrameBuffer(size_t frameIndex)
return setFailed();
m_frameBackgroundHasAlpha = !buffer.originalFrameRect().contains(IntRect(IntPoint(), size()));
} 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))
+ // Preserve the last frame as the starting state for this frame. We try
+ // to reuse |prevBuffer| as starting state to avoid copying.
+ // For BlendAtopPreviousFrame, both frames are required, so we can't
+ // take over its image data using takeBitmapDataIfWritable.
+ if ((buffer.getAlphaBlendSource() == ImageFrame::BlendAtopPreviousFrame || !buffer.takeBitmapDataIfWritable(&prevBuffer)) && !buffer.copyBitmapData(prevBuffer))
return setFailed();
if (prevBuffer.getDisposalMethod() == ImageFrame::DisposeOverwriteBgcolor) {
« no previous file with comments | « third_party/WebKit/Source/platform/image-decoders/gif/GIFImageDecoder.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698