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

Unified Diff: third_party/WebKit/Source/platform/image-decoders/webp/WEBPImageDecoder.cpp

Issue 2495183002: Pull up initFrameBuffer to ImageDecoder. (Closed)
Patch Set: Solved merge conflict with crrev.com/2494363002 Created 4 years, 1 month 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/webp/WEBPImageDecoder.h ('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 87a96775dd8241bed19a5b52552824045521bd37..649c231ae6e0f289a2dccd367c0336f2a07775e4 100644
--- a/third_party/WebKit/Source/platform/image-decoders/webp/WEBPImageDecoder.cpp
+++ b/third_party/WebKit/Source/platform/image-decoders/webp/WEBPImageDecoder.cpp
@@ -237,51 +237,32 @@ bool WEBPImageDecoder::updateDemuxer() {
return true;
}
-bool WEBPImageDecoder::initFrameBuffer(size_t frameIndex) {
+void WEBPImageDecoder::onInitFrameBuffer(size_t frameIndex) {
+ // ImageDecoder::initFrameBuffer does a DCHECK if |frameIndex| exists.
ImageFrame& buffer = m_frameBufferCache[frameIndex];
- if (buffer.getStatus() != ImageFrame::FrameEmpty) // Already initialized.
- return true;
const size_t requiredPreviousFrameIndex = buffer.requiredPreviousFrameIndex();
if (requiredPreviousFrameIndex == kNotFound) {
- // This frame doesn't rely on any previous data.
- if (!buffer.setSizeAndColorSpace(size().width(), size().height(),
- colorSpace()))
- return setFailed();
m_frameBackgroundHasAlpha =
!buffer.originalFrameRect().contains(IntRect(IntPoint(), size()));
} else {
- ImageFrame& prevBuffer = m_frameBufferCache[requiredPreviousFrameIndex];
- ASSERT(prevBuffer.getStatus() == ImageFrame::FrameComplete);
-
- // 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) {
- // We want to clear the previous frame to transparent, without
- // affecting pixels in the image outside of the frame.
- const IntRect& prevRect = prevBuffer.originalFrameRect();
- ASSERT(!prevRect.contains(IntRect(IntPoint(), size())));
- buffer.zeroFillFrameRect(prevRect);
- }
-
+ const ImageFrame& prevBuffer =
+ m_frameBufferCache[requiredPreviousFrameIndex];
m_frameBackgroundHasAlpha =
prevBuffer.hasAlpha() ||
(prevBuffer.getDisposalMethod() == ImageFrame::DisposeOverwriteBgcolor);
}
- buffer.setStatus(ImageFrame::FramePartial);
// The buffer is transparent outside the decoded area while the image is
// loading. The correct alpha value for the frame will be set when it is fully
// decoded.
buffer.setHasAlpha(true);
- return true;
+}
+
+bool WEBPImageDecoder::canReusePreviousFrameBuffer(size_t frameIndex) const {
+ DCHECK(frameIndex < m_frameBufferCache.size());
+ return m_frameBufferCache[frameIndex].getAlphaBlendSource() !=
+ ImageFrame::BlendAtopPreviousFrame;
}
size_t WEBPImageDecoder::clearCacheExceptFrame(size_t clearExceptFrame) {
« no previous file with comments | « third_party/WebKit/Source/platform/image-decoders/webp/WEBPImageDecoder.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698