diff options
Diffstat (limited to 'WebCore/platform/graphics/BitmapImage.cpp')
-rw-r--r-- | WebCore/platform/graphics/BitmapImage.cpp | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/WebCore/platform/graphics/BitmapImage.cpp b/WebCore/platform/graphics/BitmapImage.cpp index 0cd3907..e3db752 100644 --- a/WebCore/platform/graphics/BitmapImage.cpp +++ b/WebCore/platform/graphics/BitmapImage.cpp @@ -270,6 +270,11 @@ void BitmapImage::startAnimation(bool catchUpIfNecessary) if (m_frameTimer || !shouldAnimate() || frameCount() <= 1) return; + // If we aren't already animating, set now as the animation start time. + const double time = currentTime(); + if (!m_desiredFrameStartTime) + m_desiredFrameStartTime = time; + // Don't advance the animation to an incomplete frame. size_t nextFrame = (m_currentFrame + 1) % frameCount(); if (!m_allDataReceived && !frameIsCompleteAtIndex(nextFrame)) @@ -286,19 +291,14 @@ void BitmapImage::startAnimation(bool catchUpIfNecessary) // in this calculation, we make the animation appear to run at its desired // rate regardless of how fast it's being repainted. const double currentDuration = frameDurationAtIndex(m_currentFrame); - const double time = currentTime(); - if (m_desiredFrameStartTime == 0) { + m_desiredFrameStartTime += currentDuration; + + // When an animated image is more than five minutes out of date, the + // user probably doesn't care about resyncing and we could burn a lot of + // time looping through frames below. Just reset the timings. + const double cAnimationResyncCutoff = 5 * 60; + if ((time - m_desiredFrameStartTime) > cAnimationResyncCutoff) m_desiredFrameStartTime = time + currentDuration; - } else { - m_desiredFrameStartTime += currentDuration; - - // When an animated image is more than five minutes out of date, the - // user probably doesn't care about resyncing and we could burn a lot of - // time looping through frames below. Just reset the timings. - const double cAnimationResyncCutoff = 5 * 60; - if ((time - m_desiredFrameStartTime) > cAnimationResyncCutoff) - m_desiredFrameStartTime = time + currentDuration; - } // The image may load more slowly than it's supposed to animate, so that by // the time we reach the end of the first repetition, we're well behind. @@ -311,7 +311,7 @@ void BitmapImage::startAnimation(bool catchUpIfNecessary) // switch tabs (and thus stop drawing the animation, which will pause it) // during that initial loop, then switch back later. if (nextFrame == 0 && m_repetitionsComplete == 0 && m_desiredFrameStartTime < time) - m_desiredFrameStartTime = time; + m_desiredFrameStartTime = time; if (!catchUpIfNecessary || time < m_desiredFrameStartTime) { // Haven't yet reached time for next frame to start; delay until then. |