Bug 1536487 - Use a RenderRootSet instead of nsTArray<RenderRoot>. r=dthayer
authorKartikaya Gupta <kgupta@mozilla.com>
Wed, 17 Apr 2019 15:12:10 +0000
changeset 528706 2405024a9a22ae1f10ef7f825bf1b840201fccd1
parent 528705 3f0ddb7c06a5e75a0e0d418c6e231a2986e04da9
child 528707 65f9115900b0a9684655699858f5c9629d802a50
push id11265
push userffxbld-merge
push dateMon, 13 May 2019 10:53:39 +0000
treeherdermozilla-beta@77e0fe8dbdd3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdthayer
bugs1536487
milestone68.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 1536487 - Use a RenderRootSet instead of nsTArray<RenderRoot>. r=dthayer The array takes up more space than a bitset, and we don't need to keep duplicates anyway, so the set doesn't lose us anything. Differential Revision: https://phabricator.services.mozilla.com/D27900
gfx/layers/apz/public/CompositorController.h
gfx/layers/ipc/CompositorBridgeParent.cpp
gfx/layers/ipc/CompositorBridgeParent.h
gfx/layers/wr/WebRenderBridgeParent.cpp
gfx/layers/wr/WebRenderBridgeParent.h
gfx/webrender_bindings/RenderThread.cpp
--- a/gfx/layers/apz/public/CompositorController.h
+++ b/gfx/layers/apz/public/CompositorController.h
@@ -14,18 +14,17 @@
 namespace mozilla {
 namespace layers {
 
 class CompositorController {
  public:
   NS_INLINE_DECL_PURE_VIRTUAL_REFCOUNTING
 
   virtual void ScheduleRenderOnCompositorThread(
-      const nsTArray<wr::RenderRoot>& aRenderRoots =
-          nsTArray<wr::RenderRoot>()) = 0;
+      const wr::RenderRootSet& aRenderRoots = wr::RenderRootSet()) = 0;
   virtual void ScheduleHideAllPluginWindows() = 0;
   virtual void ScheduleShowAllPluginWindows() = 0;
 
  protected:
   virtual ~CompositorController() = default;
 };
 
 }  // namespace layers
--- a/gfx/layers/ipc/CompositorBridgeParent.cpp
+++ b/gfx/layers/ipc/CompositorBridgeParent.cpp
@@ -645,19 +645,19 @@ void CompositorBridgeParent::ActorDestro
   // handling message reception is finished on this thread.
   mSelfRef = this;
   MessageLoop::current()->PostTask(
       NewRunnableMethod("layers::CompositorBridgeParent::DeferredDestroy", this,
                         &CompositorBridgeParent::DeferredDestroy));
 }
 
 void CompositorBridgeParent::ScheduleRenderOnCompositorThread(
-    const nsTArray<wr::RenderRoot>& aRenderRoots) {
+    const wr::RenderRootSet& aRenderRoots) {
   MOZ_ASSERT(CompositorLoop());
-  CompositorLoop()->PostTask(NewRunnableMethod<nsTArray<wr::RenderRoot>>(
+  CompositorLoop()->PostTask(NewRunnableMethod<wr::RenderRootSet>(
       "layers::CompositorBridgeParent::ScheduleComposition", this,
       &CompositorBridgeParent::ScheduleComposition, aRenderRoots));
 }
 
 void CompositorBridgeParent::InvalidateOnCompositorThread() {
   MOZ_ASSERT(CompositorLoop());
   CompositorLoop()->PostTask(
       NewRunnableMethod("layers::CompositorBridgeParent::Invalidate", this,
@@ -859,17 +859,17 @@ void CompositorBridgeParent::NotifyShado
     mLayerManager->NotifyShadowTreeTransaction();
   }
   if (aScheduleComposite) {
     ScheduleComposition();
   }
 }
 
 void CompositorBridgeParent::ScheduleComposition(
-    const nsTArray<wr::RenderRoot>& aRenderRoots) {
+    const wr::RenderRootSet& aRenderRoots) {
   MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread());
   if (mPaused) {
     return;
   }
 
   if (mWrBridge) {
     mWrBridge->ScheduleGenerateFrame(aRenderRoots);
   } else {
--- a/gfx/layers/ipc/CompositorBridgeParent.h
+++ b/gfx/layers/ipc/CompositorBridgeParent.h
@@ -421,29 +421,28 @@ class CompositorBridgeParent final : pub
   static void SetShadowProperties(Layer* aLayer);
 
   void NotifyChildCreated(LayersId aChild);
 
   void AsyncRender();
 
   // Can be called from any thread
   void ScheduleRenderOnCompositorThread(
-      const nsTArray<wr::RenderRoot>& aRenderRoots =
-          nsTArray<wr::RenderRoot>()) override;
+      const wr::RenderRootSet& aRenderRoots = wr::RenderRootSet()) override;
   void SchedulePauseOnCompositorThread();
   void InvalidateOnCompositorThread();
   /**
    * Returns true if a surface was obtained and the resume succeeded; false
    * otherwise.
    */
   bool ScheduleResumeOnCompositorThread();
   bool ScheduleResumeOnCompositorThread(int x, int y, int width, int height);
 
-  void ScheduleComposition(const nsTArray<wr::RenderRoot>& aRenderRoots =
-                               nsTArray<wr::RenderRoot>());
+  void ScheduleComposition(const wr::RenderRootSet& aRenderRoots =
+                               wr::RenderRootSet());
 
   void NotifyShadowTreeTransaction(LayersId aId, bool aIsFirstPaint,
                                    const FocusTarget& aFocusTarget,
                                    bool aScheduleComposite,
                                    uint32_t aPaintSequenceNumber,
                                    bool aIsRepeatTransaction,
                                    bool aHitTestUpdate);
 
--- a/gfx/layers/wr/WebRenderBridgeParent.cpp
+++ b/gfx/layers/wr/WebRenderBridgeParent.cpp
@@ -2198,23 +2198,23 @@ void WebRenderBridgeParent::ScheduleGene
     if (aRenderRoot.isSome()) {
       mAsyncImageManager->SetWillGenerateFrame(*aRenderRoot);
     }
     mCompositorScheduler->ScheduleComposition();
   }
 }
 
 void WebRenderBridgeParent::ScheduleGenerateFrame(
-    const nsTArray<wr::RenderRoot>& aRenderRoots) {
+    const wr::RenderRootSet& aRenderRoots) {
   if (mCompositorScheduler) {
-    if (aRenderRoots.IsEmpty()) {
+    if (aRenderRoots.isEmpty()) {
       mAsyncImageManager->SetWillGenerateFrameAllRenderRoots();
     }
-    for (auto renderRoot : aRenderRoots) {
-      mAsyncImageManager->SetWillGenerateFrame(renderRoot);
+    for (auto it = aRenderRoots.begin(); it != aRenderRoots.end(); ++it) {
+      mAsyncImageManager->SetWillGenerateFrame(*it);
     }
     mCompositorScheduler->ScheduleComposition();
   }
 }
 
 void WebRenderBridgeParent::FlushRendering(bool aWaitForPresent) {
   if (mDestroyed) {
     return;
--- a/gfx/layers/wr/WebRenderBridgeParent.h
+++ b/gfx/layers/wr/WebRenderBridgeParent.h
@@ -226,17 +226,17 @@ class WebRenderBridgeParent final
    * to AsyncImagePipelines. If there is no update, WebRenderBridgeParent skips
    * to generate frame. If we need to generate new frame at next composite
    * timing, call this method.
    *
    * Call CompositorVsyncScheduler::ScheduleComposition() directly, if we just
    * want to trigger AsyncImagePipelines update checks.
    */
   void ScheduleGenerateFrame(const Maybe<wr::RenderRoot>& aRenderRoot);
-  void ScheduleGenerateFrame(const nsTArray<wr::RenderRoot>& aRenderRoots);
+  void ScheduleGenerateFrame(const wr::RenderRootSet& aRenderRoots);
   void ScheduleGenerateFrameAllRenderRoots();
 
   /**
    * Schedule forced frame rendering at next composite timing.
    *
    * WebRender could skip frame rendering if there is no update.
    * This function is used to force rendering even when there is not update.
    */
--- a/gfx/webrender_bindings/RenderThread.cpp
+++ b/gfx/webrender_bindings/RenderThread.cpp
@@ -941,20 +941,19 @@ void wr_notifier_external_event(mozilla:
 }
 
 void wr_schedule_render(mozilla::wr::WrWindowId aWindowId,
                         const mozilla::wr::WrDocumentId* aDocumentIds,
                         size_t aDocumentIdsCount) {
   RefPtr<mozilla::layers::CompositorBridgeParent> cbp = mozilla::layers::
       CompositorBridgeParent::GetCompositorBridgeParentFromWindowId(aWindowId);
   if (cbp) {
-    InfallibleTArray<wr::RenderRoot> renderRoots;
-    renderRoots.SetLength(aDocumentIdsCount);
+    wr::RenderRootSet renderRoots;
     for (size_t i = 0; i < aDocumentIdsCount; ++i) {
-      renderRoots[i] = wr::RenderRootFromId(aDocumentIds[i]);
+      renderRoots += wr::RenderRootFromId(aDocumentIds[i]);
     }
     cbp->ScheduleRenderOnCompositorThread(renderRoots);
   }
 }
 
 static void NotifyDidSceneBuild(RefPtr<layers::CompositorBridgeParent> aBridge,
                                 const nsTArray<wr::RenderRoot>& aRenderRoots,
                                 RefPtr<wr::WebRenderPipelineInfo> aInfo) {