Esempio n. 1
0
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++;
    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.
        if (repetitionCount(true) && m_repetitionsComplete >= m_repetitionCount) {
            m_animationFinished = true;
            m_desiredFrameStartTime = 0;
            m_currentFrame--;
            if (skippingFrames) {
                // Uh oh.  We tried to skip past the end of the animation.  We'd
                // better draw this last frame.
                notifyObserverAndTrimDecodedData();
            }
            return false;
        }
        m_currentFrame = 0;
    }

    if (!skippingFrames)
        notifyObserverAndTrimDecodedData();

    return true;
}
Esempio n. 2
0
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++;
    if (m_currentFrame >= frameCount()) {
        m_repetitionsComplete += 1;
        // 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.
        m_repetitionCount = m_source.repetitionCount();
        if (m_repetitionCount && m_repetitionsComplete >= m_repetitionCount) {
            m_animationFinished = true;
            m_desiredFrameStartTime = 0;
            m_currentFrame--;
            if (skippingFrames) {
                // Uh oh.  We tried to skip past the end of the animation.  We'd
                // better draw this last frame.
                notifyObserverAndTrimDecodedData();
            }
            return false;
        }
        m_currentFrame = 0;
    }

    if (!skippingFrames)
        notifyObserverAndTrimDecodedData();

    // We do not advance the animation explicitly.  We rely on a subsequent draw of the image
    // to force a request for the next frame via startAnimation().  This allows images that move offscreen while
    // scrolling to stop animating (thus saving memory from additional decoded frames and
    // CPU time spent doing the decoding).
    return true;
}