Bug 1288040 (Part 7) - Make FrameAnimator::GetTimeoutForFrame() a private method that doesn't rely on AnimationState. r=edwin
authorSeth Fowler <mark.seth.fowler@gmail.com>
Tue, 19 Jul 2016 14:00:43 -0700
changeset 305961 76ad9c12237689a490d756def046bd6e4b8901ac
parent 305960 725304d2b48bcdd9924c0b0300e77d99f913f84d
child 305962 b6b8a4bc9168e7f0422c6bf612776a875ea32dc6
push id30474
push usercbook@mozilla.com
push dateThu, 21 Jul 2016 14:25:10 +0000
treeherdermozilla-central@6b180266ac16 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersedwin
bugs1288040
milestone50.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 1288040 (Part 7) - Make FrameAnimator::GetTimeoutForFrame() a private method that doesn't rely on AnimationState. r=edwin
image/FrameAnimator.cpp
image/FrameAnimator.h
--- a/image/FrameAnimator.cpp
+++ b/image/FrameAnimator.cpp
@@ -89,17 +89,17 @@ FrameAnimator::GetSingleLoopTime(Animati
 
   // If we're not looping, a single loop time has no meaning
   if (aState.mAnimationMode != imgIContainer::kNormalAnimMode) {
     return -1;
   }
 
   int32_t looptime = 0;
   for (uint32_t i = 0; i < mImage->GetNumFrames(); ++i) {
-    FrameTimeout timeout = GetTimeoutForFrame(aState, i);
+    FrameTimeout timeout = GetTimeoutForFrame(i);
     if (timeout == FrameTimeout::Forever()) {
       // If we have a frame that never times out, we're probably in an error
       // case, but let's handle it more gracefully.
       NS_WARNING("Infinite frame timeout - how did this happen?");
       return -1;
     }
 
     looptime += timeout.AsMilliseconds();
@@ -107,18 +107,17 @@ FrameAnimator::GetSingleLoopTime(Animati
 
   return looptime;
 }
 
 TimeStamp
 FrameAnimator::GetCurrentImgFrameEndTime(AnimationState& aState) const
 {
   TimeStamp currentFrameTime = aState.mCurrentAnimationFrameTime;
-  FrameTimeout timeout =
-    GetTimeoutForFrame(aState, aState.mCurrentAnimationFrameIndex);
+  FrameTimeout timeout = GetTimeoutForFrame(aState.mCurrentAnimationFrameIndex);
 
   if (timeout == FrameTimeout::Forever()) {
     // We need to return a sentinel value in this case, because our logic
     // doesn't work correctly if we have an infinitely long timeout. We use one
     // year in the future as the sentinel because it works with the loop in
     // RequestRefresh() below.
     // XXX(seth): It'd be preferable to make our logic work correctly with
     // infinitely long timeouts.
@@ -205,17 +204,17 @@ FrameAnimator::AdvanceFrame(AnimationSta
                     (nextFrame && nextFrame->IsFinished());
 
   if (!canDisplay) {
     // Uh oh, the frame we want to show is currently being decoded (partial)
     // Wait until the next refresh driver tick and try again
     return ret;
   }
 
-  if (GetTimeoutForFrame(aState, nextFrameIndex) == FrameTimeout::Forever()) {
+  if (GetTimeoutForFrame(nextFrameIndex) == FrameTimeout::Forever()) {
     ret.animationFinished = true;
   }
 
   if (nextFrameIndex == 0) {
     ret.dirtyRect = aState.mFirstFrameRefreshArea;
   } else {
     MOZ_ASSERT(nextFrameIndex == currentFrameIndex + 1);
 
@@ -312,28 +311,24 @@ FrameAnimator::GetCompositedFrame(uint32
                                           DefaultSurfaceFlags(),
                                           aFrameNum));
   MOZ_ASSERT(!result || !result.DrawableRef()->GetIsPaletted(),
              "About to return a paletted frame");
   return result;
 }
 
 FrameTimeout
-FrameAnimator::GetTimeoutForFrame(AnimationState& aState, uint32_t aFrameNum) const
+FrameAnimator::GetTimeoutForFrame(uint32_t aFrameNum) const
 {
   RawAccessFrameRef frame = GetRawFrame(aFrameNum);
   if (frame) {
     AnimationData data = frame->GetAnimationData();
     return data.mTimeout;
   }
 
-  if (aFrameNum == 0) {
-    return aState.mFirstFrameTimeout;
-  }
-
   NS_WARNING("No frame; called GetTimeoutForFrame too early?");
   return FrameTimeout::FromRawMilliseconds(100);
 }
 
 static void
 DoCollectSizeOfCompositingSurfaces(const RawAccessFrameRef& aSurface,
                                    SurfaceMemoryCounterType aType,
                                    nsTArray<SurfaceMemoryCounter>& aCounters,
--- a/image/FrameAnimator.h
+++ b/image/FrameAnimator.h
@@ -177,19 +177,16 @@ public:
 
   /**
    * If we have a composited frame for @aFrameNum, returns it. Otherwise,
    * returns an empty LookupResult. It is an error to call this method with
    * aFrameNum == 0, because the first frame is never composited.
    */
   LookupResult GetCompositedFrame(uint32_t aFrameNum);
 
-  /// @return the given frame's timeout.
-  FrameTimeout GetTimeoutForFrame(AnimationState& aState, uint32_t aFrameNum) const;
-
   /**
    * Collect an accounting of the memory occupied by the compositing surfaces we
    * use during animation playback. All of the actual animation frames are
    * stored in the SurfaceCache, so we don't need to report them here.
    */
   void CollectSizeOfCompositingSurfaces(nsTArray<SurfaceMemoryCounter>& aCounters,
                                         MallocSizeOf aMallocSizeOf) const;
 
@@ -217,16 +214,19 @@ private: // methods
    * Gets the length of a single loop of this image, in milliseconds.
    *
    * If this image is not finished decoding, is not animated, or it is animated
    * but does not loop, returns -1. Can return 0 in the case of an animated
    * image that has a 0ms delay between its frames and does not loop.
    */
   int32_t GetSingleLoopTime(AnimationState& aState) const;
 
+  /// @return the given frame's timeout.
+  FrameTimeout GetTimeoutForFrame(uint32_t aFrameNum) const;
+
   /**
    * Get the time the frame we're currently displaying is supposed to end.
    *
    * In the error case, returns an "infinity" timestamp.
    */
   TimeStamp GetCurrentImgFrameEndTime(AnimationState& aState) const;
 
   bool DoBlend(nsIntRect* aDirtyRect,