Bug 926048. Part 4. Update the current animation frame time if we hit the end of decoded frames before all frames are decoded. r=edwin
authorTimothy Nikkel <tnikkel@gmail.com>
Tue, 01 Mar 2016 22:34:40 -0600
changeset 322734 bddda82562e9007b8f76f887628a4a02d4b225f8
parent 322733 68dd453ec527500a44e25164d4f433526610c8ab
child 322735 33087bab1346dbbfaff79478b7c90e5a978e6ff2
push id5913
push userjlund@mozilla.com
push dateMon, 25 Apr 2016 16:57:49 +0000
treeherdermozilla-beta@dcaf0a6fa115 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersedwin
bugs926048
milestone47.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 926048. Part 4. Update the current animation frame time if we hit the end of decoded frames before all frames are decoded. r=edwin Before the previous patch we would (wrongly) loop through the decoded frames even though we didn't have all of the frames of the animation. This had the beneficial side effect of advancing mCurrentAnimationFrameTime to aTime (the current time). With the previous patch we stop at the last decoded frame and don't advance mCurrentAnimationFrameTime, so it can lag behind. The problem with this is that when we have finished decoding we will then try to catch mCurrentAnimationFrameTime up, and this will jump us to a random point in the animation. So we need to advance mCurrentAnimationFrameTime ourselves. If we were blocked on network/decoding then displaying the last available decoded frame is the correct frame to be displaying. So we are up to date. So we advance mCurrentAnimationFrameTime to the current time.
image/FrameAnimator.cpp
--- a/image/FrameAnimator.cpp
+++ b/image/FrameAnimator.cpp
@@ -101,16 +101,26 @@ FrameAnimator::AdvanceFrame(TimeStamp aT
 
   // If we're done decoding the next frame, go ahead and display it now and
   // reinit with the next frame's delay time.
   if (mImage->GetNumFrames() == nextFrameIndex) {
     // We can only accurately determine if we are at the end of the loop if we are
     // done decoding, otherwise we don't know how many frames there will be.
     if (!mDoneDecoding) {
       // We've already advanced to the last decoded frame, nothing more we can do.
+      // We're blocked by network/decoding from displaying the animation at the
+      // rate specified, so that means the frame we are displaying (the latest
+      // available) is the frame we want to be displaying at this time. So we
+      // update the current animation time. If we didn't update the current
+      // animation time then it could lag behind, which would indicate that we
+      // are behind in the animation and should try to catch up. When we are
+      // done decoding (and thus can loop around back to the start of the
+      // animation) we would then jump to a random point in the animation to
+      // try to catch up. But we were never behind in the animation.
+      mCurrentAnimationFrameTime = aTime;
       return ret;
     }
 
     // End of an animation loop...
 
     // If we are not looping forever, initialize the loop counter
     if (mLoopRemainingCount < 0 && LoopCount() >= 0) {
       mLoopRemainingCount = LoopCount();