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

Unified Diff: Source/core/platform/graphics/ImageSource.cpp

Issue 14317005: Checking if frame is complete and access duration doesn't need a decode (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: done Created 7 years, 7 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: Source/core/platform/graphics/ImageSource.cpp
diff --git a/Source/core/platform/graphics/ImageSource.cpp b/Source/core/platform/graphics/ImageSource.cpp
index c6395a09f0828fd316edda4dbe8f22a2e9d57c88..4a43d3c685f3d648a7d03c64f24a8af8a90be33a 100644
--- a/Source/core/platform/graphics/ImageSource.cpp
+++ b/Source/core/platform/graphics/ImageSource.cpp
@@ -156,20 +156,16 @@ PassNativeImagePtr ImageSource::createFrameAtIndex(size_t index)
return buffer->asNewNativeImage();
}
-float ImageSource::frameDurationAtIndex(size_t index)
+float ImageSource::frameDurationAtIndex(size_t index) const
{
if (!m_decoder)
return 0;
- ImageFrame* buffer = m_decoder->frameBufferAtIndex(index);
- if (!buffer || buffer->status() == ImageFrame::FrameEmpty)
- return 0;
-
// Many annoying ads specify a 0 duration to make an image flash as quickly as possible.
// We follow Firefox's behavior and use a duration of 100 ms for any frames that specify
// a duration of <= 10 ms. See <rdar://problem/7689300> and <http://webkit.org/b/36082>
// for more information.
- const float duration = buffer->duration() / 1000.0f;
+ const float duration = m_decoder->frameDurationAtIndex(index) / 1000.0f;
if (duration < 0.011f)
return 0.100f;
return duration;
@@ -180,20 +176,14 @@ ImageOrientation ImageSource::orientationAtIndex(size_t) const
return m_decoder ? m_decoder->orientation() : DefaultImageOrientation;
}
-bool ImageSource::frameHasAlphaAtIndex(size_t index)
+bool ImageSource::frameHasAlphaAtIndex(size_t index) const
{
- if (!m_decoder)
- return true;
- return m_decoder->frameHasAlphaAtIndex(index);
+ return !m_decoder || m_decoder->frameHasAlphaAtIndex(index);
}
-bool ImageSource::frameIsCompleteAtIndex(size_t index)
+bool ImageSource::frameIsCompleteAtIndex(size_t index) const
{
- if (!m_decoder)
- return false;
-
- ImageFrame* buffer = m_decoder->frameBufferAtIndex(index);
- return buffer && buffer->status() == ImageFrame::FrameComplete;
+ return m_decoder && m_decoder->frameIsCompleteAtIndex(index);
}
unsigned ImageSource::frameBytesAtIndex(size_t index) const
« no previous file with comments | « Source/core/platform/graphics/ImageSource.h ('k') | Source/core/platform/graphics/chromium/DeferredImageDecoder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698