Bug 867758 - Don't start images' animation until they've been explicitly RequestRefreshed by the refresh driver. r=seth a=lsblakk
authorJoe Drew <joe@drew.ca>
Tue, 18 Jun 2013 18:15:51 -0400
changeset 142948 c569195c2993d81be6aceb6be81bbcc360094a86
parent 142947 1f5795c8cefd4ea1d162baa744222796400fe14c
child 142949 104a6f247a404d5bf493807fe1416aab1c5d027e
push id2579
push userakeybl@mozilla.com
push dateMon, 24 Jun 2013 18:52:47 +0000
treeherdermozilla-beta@b69b7de8a05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersseth, lsblakk
bugs867758
milestone23.0a2
Bug 867758 - Don't start images' animation until they've been explicitly RequestRefreshed by the refresh driver. r=seth a=lsblakk
image/src/Image.cpp
image/src/RasterImage.cpp
image/src/VectorImage.cpp
--- a/image/src/Image.cpp
+++ b/image/src/Image.cpp
@@ -94,25 +94,23 @@ Image::GetDecoderType(const char *aMimeT
 
   return rv;
 }
 
 void
 ImageResource::IncrementAnimationConsumers()
 {
   mAnimationConsumers++;
-  EvaluateAnimation();
 }
 
 void
 ImageResource::DecrementAnimationConsumers()
 {
   NS_ABORT_IF_FALSE(mAnimationConsumers >= 1, "Invalid no. of animation consumers!");
   mAnimationConsumers--;
-  EvaluateAnimation();
 }
 
 nsresult
 ImageResource::GetAnimationModeInternal(uint16_t* aAnimationMode)
 {
   if (mError)
     return NS_ERROR_FAILURE;
 
@@ -130,18 +128,16 @@ ImageResource::SetAnimationModeInternal(
 
   NS_ASSERTION(aAnimationMode == kNormalAnimMode ||
                aAnimationMode == kDontAnimMode ||
                aAnimationMode == kLoopOnceAnimMode,
                "Wrong Animation Mode is being set!");
 
   mAnimationMode = aAnimationMode;
 
-  EvaluateAnimation();
-
   return NS_OK;
 }
 
 void
 ImageResource::EvaluateAnimation()
 {
   if (!mAnimating && ShouldAnimate()) {
     nsresult rv = StartAnimation();
--- a/image/src/RasterImage.cpp
+++ b/image/src/RasterImage.cpp
@@ -631,21 +631,22 @@ RasterImage::AdvanceFrame(TimeStamp aTim
   return true;
 }
 
 //******************************************************************************
 // [notxpcom] void requestRefresh ([const] in TimeStamp aTime);
 NS_IMETHODIMP_(void)
 RasterImage::RequestRefresh(const mozilla::TimeStamp& aTime)
 {
-  if (!mAnimating || !ShouldAnimate()) {
+  if (!ShouldAnimate()) {
     return;
   }
 
   EnsureAnimExists();
+  EvaluateAnimation();
 
   // only advance the frame if the current time is greater than or
   // equal to the current frame's end time.
   TimeStamp currentFrameEndTime = GetCurrentImgFrameEndTime();
   bool frameAdvanced = false;
 
   // The dirtyRect variable will contain an accumulation of the sub-rectangles
   // that are dirty for each frame we advance in AdvanceFrame().
@@ -1289,19 +1290,16 @@ RasterImage::InternalAddFrame(uint32_t f
   // We only need to refresh that small area when Frame 0 comes around again
   nsIntRect frameRect = frame->GetRect();
   mAnim->firstFrameRefreshArea.UnionRect(mAnim->firstFrameRefreshArea,
                                          frameRect);
 
   rv = InternalAddFrameHelper(framenum, frame.forget(), imageData, imageLength,
                               paletteData, paletteLength, aRetFrame);
 
-  // We may be able to start animating, if we now have enough frames
-  EvaluateAnimation();
-
   return rv;
 }
 
 bool
 RasterImage::ApplyDecodeFlags(uint32_t aNewFlags)
 {
   if (mFrameDecodeFlags == (aNewFlags & DECODE_FLAGS_MASK))
     return true; // Not asking very much of us here.
--- a/image/src/VectorImage.cpp
+++ b/image/src/VectorImage.cpp
@@ -461,16 +461,17 @@ VectorImage::GetWidth(int32_t* aWidth)
 }
 
 //******************************************************************************
 /* [notxpcom] void requestRefresh ([const] in TimeStamp aTime); */
 NS_IMETHODIMP_(void)
 VectorImage::RequestRefresh(const mozilla::TimeStamp& aTime)
 {
   // TODO: Implement for b666446.
+  EvaluateAnimation();
 }
 
 //******************************************************************************
 /* readonly attribute int32_t height; */
 NS_IMETHODIMP
 VectorImage::GetHeight(int32_t* aHeight)
 {
   if (mError || !mIsFullyLoaded) {