Bug 1368776 - Part 0. Move RasterImage's NotifyDrawingObservers to ImageResource. r=tnikkel
authorAndrew Osmond <aosmond@mozilla.com>
Fri, 17 Nov 2017 06:45:23 -0500
changeset 392461 6dfe9e9f880079c77f54ae7d6501a7815ec4e772
parent 392460 3b1d7a28d1a522570825ec47fbcf831726ce6e99
child 392462 ef34a21c32b7847db008a9a261e2c799e6018fc0
push id32921
push usernerli@mozilla.com
push dateFri, 17 Nov 2017 22:02:18 +0000
treeherdermozilla-central@daa0dcd1616c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstnikkel
bugs1368776
milestone59.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 1368776 - Part 0. Move RasterImage's NotifyDrawingObservers to ImageResource. r=tnikkel
image/Image.cpp
image/Image.h
image/RasterImage.cpp
image/RasterImage.h
--- a/image/Image.cpp
+++ b/image/Image.cpp
@@ -164,10 +164,36 @@ ImageResource::SendOnUnlockedDraw(uint32
         if (tracker) {
           tracker->OnUnlockedDraw();
         }
       });
     eventTarget->Dispatch(ev.forget(), NS_DISPATCH_NORMAL);
   }
 }
 
+#ifdef DEBUG
+void
+ImageResource::NotifyDrawingObservers()
+{
+  if (!mURI || !NS_IsMainThread()) {
+    return;
+  }
+
+  bool match = false;
+  if ((NS_FAILED(mURI->SchemeIs("resource", &match)) || !match) &&
+      (NS_FAILED(mURI->SchemeIs("chrome", &match)) || !match)) {
+    return;
+  }
+
+  // Record the image drawing for startup performance testing.
+  nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
+  NS_WARNING_ASSERTION(obs, "Can't get an observer service handle");
+  if (obs) {
+    nsCOMPtr<nsIURI> imageURI = mURI->ToIURI();
+    nsAutoCString spec;
+    imageURI->GetSpec(spec);
+    obs->NotifyObservers(nullptr, "image-drawing", NS_ConvertUTF8toUTF16(spec).get());
+  }
+}
+#endif
+
 } // namespace image
 } // namespace mozilla
--- a/image/Image.h
+++ b/image/Image.h
@@ -313,16 +313,21 @@ protected:
     return mAnimationConsumers > 0 && mAnimationMode != kDontAnimMode;
   }
 
   virtual nsresult StartAnimation() = 0;
   virtual nsresult StopAnimation() = 0;
 
   void SendOnUnlockedDraw(uint32_t aFlags);
 
+#ifdef DEBUG
+  // Records the image drawing for startup performance testing.
+  void NotifyDrawingObservers();
+#endif
+
   // Member data shared by all implementations of this abstract class
   RefPtr<ProgressTracker>     mProgressTracker;
   RefPtr<ImageURL>            mURI;
   TimeStamp                     mLastRefreshTime;
   uint64_t                      mInnerWindowId;
   uint32_t                      mAnimationConsumers;
   uint16_t                      mAnimationMode; // Enum values in imgIContainer
   bool                          mInitialized:1; // Have we been initalized?
--- a/image/RasterImage.cpp
+++ b/image/RasterImage.cpp
@@ -1686,42 +1686,16 @@ RasterImage::GetFramesNotified(uint32_t*
   NS_ENSURE_ARG_POINTER(aFramesNotified);
 
   *aFramesNotified = mFramesNotified;
 
   return NS_OK;
 }
 #endif
 
-#ifdef DEBUG
-void
-RasterImage::NotifyDrawingObservers()
-{
-  if (!mURI || !NS_IsMainThread()) {
-    return;
-  }
-
-  bool match = false;
-  if ((NS_FAILED(mURI->SchemeIs("resource", &match)) || !match) &&
-      (NS_FAILED(mURI->SchemeIs("chrome", &match)) || !match)) {
-    return;
-  }
-
-  // Record the image drawing for startup performance testing.
-  nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
-  NS_WARNING_ASSERTION(obs, "Can't get an observer service handle");
-  if (obs) {
-    nsCOMPtr<nsIURI> imageURI = mURI->ToIURI();
-    nsAutoCString spec;
-    imageURI->GetSpec(spec);
-    obs->NotifyObservers(nullptr, "image-drawing", NS_ConvertUTF8toUTF16(spec).get());
-  }
-}
-#endif
-
 void
 RasterImage::NotifyProgress(Progress aProgress,
                             const IntRect& aInvalidRect /* = IntRect() */,
                             const Maybe<uint32_t>& aFrameCount /* = Nothing() */,
                             DecoderFlags aDecoderFlags
                               /* = DefaultDecoderFlags() */,
                             SurfaceFlags aSurfaceFlags
                               /* = DefaultSurfaceFlags() */)
--- a/image/RasterImage.h
+++ b/image/RasterImage.h
@@ -312,21 +312,16 @@ private:
                      uint32_t aWhichFrame,
                      uint32_t aFlags);
 
   Pair<DrawResult, RefPtr<layers::Image>>
     GetCurrentImage(layers::ImageContainer* aContainer, uint32_t aFlags);
 
   void UpdateImageContainer();
 
-#ifdef DEBUG
-  // Records the image drawing for startup performance testing.
-  void NotifyDrawingObservers();
-#endif
-
   //////////////////////////////////////////////////////////////////////////////
   // Decoding.
   //////////////////////////////////////////////////////////////////////////////
 
   /**
    * Creates and runs a decoder, either synchronously or asynchronously
    * according to @aFlags. Decodes at the provided target size @aSize, using
    * decode flags @aFlags. Performs a single-frame decode of this image unless