void BitmapImage::resetAnimation() { stopAnimation(); m_currentFrame = 0; m_repetitionsComplete = 0; m_desiredFrameStartTime = 0; m_animationFinished = false; // For extremely large animations, when the animation is reset, we just throw everything away. destroyDecodedDataIfNecessary(true); }
bool BitmapImage::internalAdvanceAnimation(AnimationAdvancement advancement) { clearTimer(); if (m_animationFinishedWhenCatchingUp) { imageObserver()->animationAdvanced(this); m_animationFinishedWhenCatchingUp = false; return false; } ++m_currentFrame; bool advancedAnimation = true; bool destroyAll = false; if (m_currentFrame >= frameCount()) { ++m_repetitionsComplete; // Get the repetition count again. If we weren't able to get a // repetition count before, we should have decoded the whole image by // 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) { m_animationFinished = true; m_desiredFrameStartTime = 0; --m_currentFrame; advancedAnimation = false; } else { m_currentFrame = 0; destroyAll = true; } } destroyDecodedDataIfNecessary(destroyAll); // We need to draw this frame if we advanced to it while not skipping, or if // while trying to skip frames we hit the last frame and thus had to stop. if (advancement == Normal && advancedAnimation) imageObserver()->animationAdvanced(this); return advancedAnimation; }
bool BitmapImage::internalAdvanceAnimation(bool skippingFrames) { // Stop the animation. stopAnimation(); // See if anyone is still paying attention to this animation. If not, we don't // advance and will remain suspended at the current frame until the animation is resumed. if (!skippingFrames && imageObserver()->shouldPauseAnimation(this)) return false; ++m_currentFrame; bool advancedAnimation = true; bool destroyAll = false; if (m_currentFrame >= frameCount()) { ++m_repetitionsComplete; // Get the repetition count again. If we weren't able to get a // repetition count before, we should have decoded the whole image by // 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) { m_animationFinished = true; m_desiredFrameStartTime = 0; --m_currentFrame; advancedAnimation = false; } else { m_currentFrame = 0; destroyAll = true; } } destroyDecodedDataIfNecessary(destroyAll); // We need to draw this frame if we advanced to it while not skipping, or if // while trying to skip frames we hit the last frame and thus had to stop. if (skippingFrames != advancedAnimation) imageObserver()->animationAdvanced(this); return advancedAnimation; }