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

Unified Diff: Source/platform/graphics/BitmapImage.cpp

Issue 754813002: Expose setting API to set ImageAnimationPolicy(Allowed, Once, None) (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Update Code Created 6 years 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 | « Source/platform/graphics/BitmapImage.h ('k') | Source/platform/graphics/BitmapImageTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/graphics/BitmapImage.cpp
diff --git a/Source/platform/graphics/BitmapImage.cpp b/Source/platform/graphics/BitmapImage.cpp
index 4db08d2ed6c632d5c5b1e9a03184e67758b00fb6..e80ebe3106ad8ba91036a34e0dc1a81278c77e95 100644
--- a/Source/platform/graphics/BitmapImage.cpp
+++ b/Source/platform/graphics/BitmapImage.cpp
@@ -58,6 +58,7 @@ BitmapImage::BitmapImage(ImageObserver* observer)
, m_repetitionsComplete(0)
, m_desiredFrameStartTime(0)
, m_frameCount(0)
+ , m_animationPolicy(ImageAnimationPolicyAllowed)
, m_isSolidColor(false)
, m_checkedForSolidColor(false)
, m_animationFinished(false)
@@ -79,6 +80,7 @@ BitmapImage::BitmapImage(PassRefPtr<NativeImageSkia> nativeImage, ImageObserver*
, m_repetitionCountStatus(Unknown)
, m_repetitionsComplete(0)
, m_frameCount(1)
+ , m_animationPolicy(ImageAnimationPolicyAllowed)
, m_isSolidColor(false)
, m_checkedForSolidColor(false)
, m_animationFinished(true)
@@ -439,7 +441,13 @@ int BitmapImage::repetitionCount(bool imageKnownToBeComplete)
bool BitmapImage::shouldAnimate()
{
- return (repetitionCount(false) != cAnimationNone && !m_animationFinished && imageObserver());
+ bool animated = repetitionCount(false) != cAnimationNone && !m_animationFinished && imageObserver();
+ if (imageObserver()) {
+ imageObserver()->imageAnimationPolicy(this, m_animationPolicy);
+ if (animated && m_animationPolicy == ImageAnimationPolicyNoAnimation)
+ animated = false;
+ }
+ return animated;
}
void BitmapImage::startAnimation(CatchUpAnimation catchUpIfNecessary)
@@ -461,7 +469,9 @@ void BitmapImage::startAnimation(CatchUpAnimation catchUpIfNecessary)
// yet and our repetition count is potentially unset. The repetition count
// in a GIF can potentially come after all the rest of the image data, so
// wait on it.
- if (!m_allDataReceived && repetitionCount(false) == cAnimationLoopOnce && m_currentFrame >= (frameCount() - 1))
+ if (!m_allDataReceived
+ && (repetitionCount(false) == cAnimationLoopOnce || m_animationPolicy == ImageAnimationPolicyAnimateOnce)
+ && m_currentFrame >= (frameCount() - 1))
return;
// Determine time for next frame to start. By ignoring paint and timer lag
@@ -596,7 +606,8 @@ bool BitmapImage::internalAdvanceAnimation(bool skippingFrames)
// now, so it should now be available.
// Note that we don't need to special-case cAnimationLoopOnce here
// because it is 0 (see comments on its declaration in ImageSource.h).
- if (repetitionCount(true) != cAnimationLoopInfinite && m_repetitionsComplete > m_repetitionCount) {
+ if ((repetitionCount(true) != cAnimationLoopInfinite && m_repetitionsComplete > m_repetitionCount)
+ || (m_animationPolicy == ImageAnimationPolicyAnimateOnce && m_repetitionsComplete > 0)) {
m_animationFinished = true;
m_desiredFrameStartTime = 0;
--m_currentFrame;
« no previous file with comments | « Source/platform/graphics/BitmapImage.h ('k') | Source/platform/graphics/BitmapImageTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698