Bug 1343341. Only set the animation state as discarded if we discarded the animated frames (and not a static frame from a first-frame-only decode). r=aosmond
☠☠ backed out by 0394f4a6e9e9 ☠ ☠
authorTimothy Nikkel <tnikkel@gmail.com>
Wed, 15 Mar 2017 02:47:40 -0500
changeset 347673 29e2e6dd82d298a1febed9c03ca0d5d6757d9607
parent 347672 a23edcf5b82aad48a36e15d72c4c0a4b9cbbea1b
child 347674 83eb15651f24e14962ef4033a8544092bc3fa580
push id88070
push usertnikkel@gmail.com
push dateWed, 15 Mar 2017 07:48:02 +0000
treeherdermozilla-inbound@29e2e6dd82d2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersaosmond
bugs1343341
milestone55.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 1343341. Only set the animation state as discarded if we discarded the animated frames (and not a static frame from a first-frame-only decode). r=aosmond The SurfaceCache can hold the first frame of a "static" decode as well as the animated frames in two seperate entries. We only care about what happens to the animated frames, so ignore OnSurfaceDiscarded for anything else. To accomplish this we must pass the SurfaceKey to OnSurfaceDiscarded.
image/DynamicImage.cpp
image/DynamicImage.h
image/Image.h
image/ImageWrapper.cpp
image/ImageWrapper.h
image/RasterImage.cpp
image/RasterImage.h
image/SurfaceCache.cpp
image/VectorImage.cpp
image/VectorImage.h
--- a/image/DynamicImage.cpp
+++ b/image/DynamicImage.cpp
@@ -75,17 +75,17 @@ DynamicImage::OnImageDataComplete(nsIReq
                                   nsISupports* aContext,
                                   nsresult aStatus,
                                   bool aLastPart)
 {
   return NS_OK;
 }
 
 void
-DynamicImage::OnSurfaceDiscarded()
+DynamicImage::OnSurfaceDiscarded(SurfaceKey aSurfaceKey)
 { }
 
 void
 DynamicImage::SetInnerWindowID(uint64_t aInnerWindowId)
 { }
 
 uint64_t
 DynamicImage::InnerWindowID() const
--- a/image/DynamicImage.h
+++ b/image/DynamicImage.h
@@ -48,17 +48,17 @@ public:
                                         nsIInputStream* aInStr,
                                         uint64_t aSourceOffset,
                                         uint32_t aCount) override;
   virtual nsresult OnImageDataComplete(nsIRequest* aRequest,
                                        nsISupports* aContext,
                                        nsresult aStatus,
                                        bool aLastPart) override;
 
-  virtual void OnSurfaceDiscarded() override;
+  virtual void OnSurfaceDiscarded(SurfaceKey aSurfaceKey) override;
 
   virtual void SetInnerWindowID(uint64_t aInnerWindowId) override;
   virtual uint64_t InnerWindowID() const override;
 
   virtual bool HasError() override;
   virtual void SetHasError() override;
 
   virtual ImageURL* GetURI() override;
--- a/image/Image.h
+++ b/image/Image.h
@@ -211,17 +211,17 @@ public:
   virtual nsresult OnImageDataComplete(nsIRequest* aRequest,
                                        nsISupports* aContext,
                                        nsresult aStatus,
                                        bool aLastPart) = 0;
 
   /**
    * Called when the SurfaceCache discards a surface belonging to this image.
    */
-  virtual void OnSurfaceDiscarded() = 0;
+  virtual void OnSurfaceDiscarded(SurfaceKey aSurfaceKey) = 0;
 
   virtual void SetInnerWindowID(uint64_t aInnerWindowId) = 0;
   virtual uint64_t InnerWindowID() const = 0;
 
   virtual bool HasError() = 0;
   virtual void SetHasError() = 0;
 
   virtual ImageURL* GetURI() = 0;
@@ -251,17 +251,17 @@ public:
   virtual void DecrementAnimationConsumers() override;
 #ifdef DEBUG
   virtual uint32_t GetAnimationConsumers() override
   {
     return mAnimationConsumers;
   }
 #endif
 
-  virtual void OnSurfaceDiscarded() override { }
+  virtual void OnSurfaceDiscarded(SurfaceKey aSurfaceKey) override { }
 
   virtual void SetInnerWindowID(uint64_t aInnerWindowId) override
   {
     mInnerWindowId = aInnerWindowId;
   }
   virtual uint64_t InnerWindowID() const override { return mInnerWindowId; }
 
   virtual bool HasError() override    { return mError; }
--- a/image/ImageWrapper.cpp
+++ b/image/ImageWrapper.cpp
@@ -83,19 +83,19 @@ ImageWrapper::OnImageDataComplete(nsIReq
                                   nsresult aStatus,
                                   bool aLastPart)
 {
   return mInnerImage->OnImageDataComplete(aRequest, aContext, aStatus,
                                           aLastPart);
 }
 
 void
-ImageWrapper::OnSurfaceDiscarded()
+ImageWrapper::OnSurfaceDiscarded(SurfaceKey aSurfaceKey)
 {
-  return mInnerImage->OnSurfaceDiscarded();
+  return mInnerImage->OnSurfaceDiscarded(aSurfaceKey);
 }
 
 void
 ImageWrapper::SetInnerWindowID(uint64_t aInnerWindowId)
 {
   mInnerImage->SetInnerWindowID(aInnerWindowId);
 }
 
--- a/image/ImageWrapper.h
+++ b/image/ImageWrapper.h
@@ -40,17 +40,17 @@ public:
                                         nsIInputStream* aInStr,
                                         uint64_t aSourceOffset,
                                         uint32_t aCount) override;
   virtual nsresult OnImageDataComplete(nsIRequest* aRequest,
                                        nsISupports* aContext,
                                        nsresult aStatus,
                                        bool aLastPart) override;
 
-  virtual void OnSurfaceDiscarded() override;
+  virtual void OnSurfaceDiscarded(SurfaceKey aSurfaceKey) override;
 
   virtual void SetInnerWindowID(uint64_t aInnerWindowId) override;
   virtual uint64_t InnerWindowID() const override;
 
   virtual bool HasError() override;
   virtual void SetHasError() override;
 
   virtual ImageURL* GetURI() override;
--- a/image/RasterImage.cpp
+++ b/image/RasterImage.cpp
@@ -415,21 +415,21 @@ RasterImage::WillDrawOpaqueNow()
       !result.Surface()->IsFinished()) {
     return false;
   }
 
   return true;
 }
 
 void
-RasterImage::OnSurfaceDiscarded()
+RasterImage::OnSurfaceDiscarded(SurfaceKey aSurfaceKey)
 {
   MOZ_ASSERT(mProgressTracker);
 
-  if (mAnimationState) {
+  if (mAnimationState && aSurfaceKey.Playback() == PlaybackType::eAnimated) {
     MOZ_ASSERT(gfxPrefs::ImageMemAnimatedDiscardable());
     mAnimationState->SetDiscarded(true);
   }
 
   NS_DispatchToMainThread(NewRunnableMethod("ProgressTracker::OnDiscard",
                                             mProgressTracker, &ProgressTracker::OnDiscard));
 }
 
--- a/image/RasterImage.h
+++ b/image/RasterImage.h
@@ -159,17 +159,17 @@ public:
 #ifdef DEBUG
   NS_DECL_IMGICONTAINERDEBUG
 #endif
 
   virtual nsresult StartAnimation() override;
   virtual nsresult StopAnimation() override;
 
   // Methods inherited from Image
-  virtual void OnSurfaceDiscarded() override;
+  virtual void OnSurfaceDiscarded(SurfaceKey aSurfaceKey) override;
 
   virtual size_t SizeOfSourceWithComputedFallback(MallocSizeOf aMallocSizeOf)
     const override;
   virtual void CollectSizeOfSurfaces(nsTArray<SurfaceMemoryCounter>& aCounters,
                                      MallocSizeOf aMallocSizeOf) const override;
 
   /* Triggers discarding. */
   void Discard();
--- a/image/SurfaceCache.cpp
+++ b/image/SurfaceCache.cpp
@@ -497,17 +497,17 @@ public:
   {
     ImageKey imageKey = aSurface->GetImageKey();
 
     RefPtr<ImageSurfaceCache> cache = GetImageCache(imageKey);
     MOZ_ASSERT(cache, "Shouldn't try to remove a surface with no image cache");
 
     // If the surface was not a placeholder, tell its image that we discarded it.
     if (!aSurface->IsPlaceholder()) {
-      static_cast<Image*>(imageKey)->OnSurfaceDiscarded();
+      static_cast<Image*>(imageKey)->OnSurfaceDiscarded(aSurface->GetSurfaceKey());
     }
 
     StopTracking(aSurface);
     cache->Remove(aSurface);
 
     // Remove the per-image cache if it's unneeded now. (Keep it if the image is
     // locked, since the per-image cache is where we store that state.)
     if (cache->IsEmpty() && !cache->IsLocked()) {
--- a/image/VectorImage.cpp
+++ b/image/VectorImage.cpp
@@ -1118,17 +1118,17 @@ VectorImage::RequestDiscard()
     SurfaceCache::RemoveImage(ImageKey(this));
     mProgressTracker->OnDiscard();
   }
 
   return NS_OK;
 }
 
 void
-VectorImage::OnSurfaceDiscarded()
+VectorImage::OnSurfaceDiscarded(SurfaceKey aSurfaceKey)
 {
   MOZ_ASSERT(mProgressTracker);
 
   NS_DispatchToMainThread(NewRunnableMethod(mProgressTracker, &ProgressTracker::OnDiscard));
 }
 
 //******************************************************************************
 NS_IMETHODIMP
--- a/image/VectorImage.h
+++ b/image/VectorImage.h
@@ -44,17 +44,17 @@ public:
                                         nsIInputStream* aInStr,
                                         uint64_t aSourceOffset,
                                         uint32_t aCount) override;
   virtual nsresult OnImageDataComplete(nsIRequest* aRequest,
                                        nsISupports* aContext,
                                        nsresult aResult,
                                        bool aLastPart) override;
 
-  virtual void OnSurfaceDiscarded() override;
+  virtual void OnSurfaceDiscarded(SurfaceKey aSurfaceKey) override;
 
   /**
    * Callback for SVGRootRenderingObserver.
    *
    * This just sets a dirty flag that we check in VectorImage::RequestRefresh,
    * which is called under the ticks of the refresh driver of any observing
    * documents that we may have. Only then (after all animations in this image
    * have been updated) do we send out "frame changed" notifications,