Bug 1391262 - Create TabChild::CreateRemoteLayerManager() r=dvander
authorsotaro <sotaro.ikeda.g@gmail.com>
Fri, 13 Oct 2017 23:32:52 +0900
changeset 436908 e0c53e24ab2a59ea1fb21d482404e54641107658
parent 436907 38330dd0d9e5e297b396e760c2997c86a1e64a59
child 436909 febed94fa5926a5abebd4dcb7c3cd9595410ea73
push id8114
push userjlorenzo@mozilla.com
push dateThu, 02 Nov 2017 16:33:21 +0000
treeherdermozilla-beta@73e0d89a540f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdvander
bugs1391262
milestone58.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 1391262 - Create TabChild::CreateRemoteLayerManager() r=dvander
dom/ipc/TabChild.cpp
dom/ipc/TabChild.h
--- a/dom/ipc/TabChild.cpp
+++ b/dom/ipc/TabChild.cpp
@@ -2827,42 +2827,18 @@ TabChild::InitRenderingState(const Textu
       }
       MOZ_ASSERT(!sTabChildren->Get(aLayersId));
       sTabChildren->Put(aLayersId, this);
       mLayersId = aLayersId;
     }
 
     MOZ_ASSERT(!mPuppetWidget->HasLayerManager());
     bool success = false;
-    if (mLayersConnected == Some(true) && gfxVars::UseWebRender()) {
-      success = mPuppetWidget->CreateRemoteLayerManager([&] (LayerManager* aLayerManager) -> bool {
-        MOZ_ASSERT(aLayerManager->AsWebRenderLayerManager());
-        return aLayerManager->AsWebRenderLayerManager()->Initialize(compositorChild,
-                                                                    wr::AsPipelineId(mLayersId),
-                                                                    &mTextureFactoryIdentifier);
-      });
-    } else if (mLayersConnected == Some(true)) {
-      nsTArray<LayersBackend> ignored;
-      PLayerTransactionChild* shadowManager = compositorChild->SendPLayerTransactionConstructor(ignored, LayersId());
-      if (shadowManager &&
-          shadowManager->SendGetTextureFactoryIdentifier(&mTextureFactoryIdentifier) &&
-          mTextureFactoryIdentifier.mParentBackend != LayersBackend::LAYERS_NONE)
-      {
-        success = true;
-      }
-      if (!success) {
-        NS_WARNING("failed to allocate layer transaction");
-      } else {
-        success = mPuppetWidget->CreateRemoteLayerManager([&] (LayerManager* aLayerManager) -> bool {
-          ShadowLayerForwarder* lf = aLayerManager->AsShadowForwarder();
-          lf->SetShadowManager(shadowManager);
-          lf->IdentifyTextureHost(mTextureFactoryIdentifier);
-          return true;
-        });
-      }
+    if (mLayersConnected == Some(true)) {
+      success = CreateRemoteLayerManager(compositorChild);
     }
 
     if (success) {
       MOZ_ASSERT(mLayersConnected == Some(true));
       // Succeeded to create "remote" layer manager
       ImageBridgeChild::IdentifyCompositorTextureHost(mTextureFactoryIdentifier);
       gfx::VRManagerChild::IdentifyTextureHost(mTextureFactoryIdentifier);
       InitAPZState();
@@ -2876,16 +2852,52 @@ TabChild::InitRenderingState(const Textu
 
     if (observerService) {
         observerService->AddObserver(this,
                                      BEFORE_FIRST_PAINT,
                                      false);
     }
 }
 
+bool
+TabChild::CreateRemoteLayerManager(mozilla::layers::PCompositorBridgeChild* aCompositorChild)
+{
+  MOZ_ASSERT(aCompositorChild);
+
+  bool success = false;
+  if (gfxVars::UseWebRender()) {
+    success = mPuppetWidget->CreateRemoteLayerManager([&] (LayerManager* aLayerManager) -> bool {
+      MOZ_ASSERT(aLayerManager->AsWebRenderLayerManager());
+      return aLayerManager->AsWebRenderLayerManager()->Initialize(aCompositorChild,
+                                                                  wr::AsPipelineId(mLayersId),
+                                                                  &mTextureFactoryIdentifier);
+    });
+  } else {
+    nsTArray<LayersBackend> ignored;
+    PLayerTransactionChild* shadowManager = aCompositorChild->SendPLayerTransactionConstructor(ignored, LayersId());
+    if (shadowManager &&
+        shadowManager->SendGetTextureFactoryIdentifier(&mTextureFactoryIdentifier) &&
+        mTextureFactoryIdentifier.mParentBackend != LayersBackend::LAYERS_NONE)
+    {
+      success = true;
+    }
+    if (!success) {
+      NS_WARNING("failed to allocate layer transaction");
+    } else {
+      success = mPuppetWidget->CreateRemoteLayerManager([&] (LayerManager* aLayerManager) -> bool {
+        ShadowLayerForwarder* lf = aLayerManager->AsShadowForwarder();
+        lf->SetShadowManager(shadowManager);
+        lf->IdentifyTextureHost(mTextureFactoryIdentifier);
+        return true;
+      });
+    }
+  }
+  return success;
+}
+
 void
 TabChild::InitAPZState()
 {
   if (!mCompositorOptions->UseAPZ()) {
     return;
   }
   auto cbc = CompositorBridgeChild::Get();
 
@@ -3173,43 +3185,19 @@ TabChild::ReinitRendering()
   // PLayerTransaction constructor message arrives on the cross-process
   // compositor bridge.
   CompositorOptions options;
   SendEnsureLayersConnected(&options);
   mCompositorOptions = Some(options);
 
   bool success = false;
   RefPtr<CompositorBridgeChild> cb = CompositorBridgeChild::Get();
-  if (gfxVars::UseWebRender()) {
-    success = mPuppetWidget->CreateRemoteLayerManager([&] (LayerManager* aLayerManager) -> bool {
-      MOZ_ASSERT(aLayerManager->AsWebRenderLayerManager());
-      return aLayerManager->AsWebRenderLayerManager()->Initialize(cb,
-                                                                  wr::AsPipelineId(mLayersId),
-                                                                  &mTextureFactoryIdentifier);
-    });
-  } else {
-    nsTArray<LayersBackend> ignored;
-    PLayerTransactionChild* shadowManager = cb->SendPLayerTransactionConstructor(ignored, LayersId());
-    if (shadowManager &&
-        shadowManager->SendGetTextureFactoryIdentifier(&mTextureFactoryIdentifier) &&
-        mTextureFactoryIdentifier.mParentBackend != LayersBackend::LAYERS_NONE)
-    {
-      success = true;
-    }
-    if (!success) {
-      NS_WARNING("failed to re-allocate layer transaction");
-      return;
-    }
-
-    success = mPuppetWidget->CreateRemoteLayerManager([&] (LayerManager* aLayerManager) -> bool {
-      ShadowLayerForwarder* lf = aLayerManager->AsShadowForwarder();
-      lf->SetShadowManager(shadowManager);
-      lf->IdentifyTextureHost(mTextureFactoryIdentifier);
-      return true;
-    });
+
+  if (cb) {
+    success = CreateRemoteLayerManager(cb);
   }
 
   if (!success) {
     NS_WARNING("failed to recreate layer manager");
     return;
   }
 
   mLayersConnected = Some(true);
--- a/dom/ipc/TabChild.h
+++ b/dom/ipc/TabChild.h
@@ -58,16 +58,17 @@ class RenderFrameChild;
 } // namespace layout
 
 namespace layers {
 class APZChild;
 class APZEventState;
 class AsyncDragMetrics;
 class IAPZCTreeManager;
 class ImageCompositeNotification;
+class PCompositorBridgeChild;
 } // namespace layers
 
 namespace widget {
 struct AutoCacheNativeKeyCommands;
 } // namespace widget
 
 namespace dom {
 
@@ -879,16 +880,18 @@ private:
 
   void DispatchWheelEvent(const WidgetWheelEvent& aEvent,
                           const ScrollableLayerGuid& aGuid,
                           const uint64_t& aInputBlockId);
 
   void InternalSetDocShellIsActive(bool aIsActive,
                                    bool aPreserveLayers);
 
+  bool CreateRemoteLayerManager(mozilla::layers::PCompositorBridgeChild* aCompositorChild);
+
   class DelayedDeleteRunnable;
 
   TextureFactoryIdentifier mTextureFactoryIdentifier;
   nsCOMPtr<nsIWebNavigation> mWebNav;
   RefPtr<mozilla::dom::TabGroup> mTabGroup;
   RefPtr<PuppetWidget> mPuppetWidget;
   nsCOMPtr<nsIURI> mLastURI;
   RenderFrameChild* mRemoteFrame;