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

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: +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/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..176f482a60bfe5b89528b9ebfe7489b8ac43e1de 100644
--- a/third_party/WebKit/Source/platform/image-decoders/webp/WEBPImageDecoder.cpp
+++ b/third_party/WebKit/Source/platform/image-decoders/webp/WEBPImageDecoder.cpp
@@ -252,12 +252,17 @@ 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))
- return setFailed();
+ // Preserve the last frame as the starting state for this frame. We try
+ // to reuse |prevBuffer| as starting state and avoid copy.
Peter Kasting 2016/08/26 19:04:04 Nit: and avoid copy -> to avoid copying
aleksandar.stojiljkovic 2016/08/26 21:53:51 Done.
+ // 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)) {
+ if (!buffer.copyBitmapData(prevBuffer))
Peter Kasting 2016/08/26 19:04:04 Nit: I'd just combine these two conditionals
aleksandar.stojiljkovic 2016/08/26 21:53:51 Done.
+ 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