Support compositor bridges from the content process to the GPU process. (bug 1282348 part 8, r=billm)
authorDavid Anderson <danderson@mozilla.com>
Sun, 17 Jul 2016 21:24:28 -0700
changeset 388846 b09494ecac5f068861315f9a160fb70e7544e1f6
parent 388845 39636df7a0fe56efe6e0480df7cbb707d18c70b3
child 388847 2dee8c10e5071a9dd2bc12a713b3e1f099dc0c31
push id23247
push userbmo:jgilbert@mozilla.com
push dateMon, 18 Jul 2016 06:13:58 +0000
reviewersbillm
bugs1282348
milestone50.0a1
Support compositor bridges from the content process to the GPU process. (bug 1282348 part 8, r=billm)
gfx/ipc/GPUParent.cpp
gfx/ipc/GPUParent.h
gfx/ipc/GPUProcessManager.cpp
gfx/ipc/PGPU.ipdl
--- a/gfx/ipc/GPUParent.cpp
+++ b/gfx/ipc/GPUParent.cpp
@@ -78,16 +78,22 @@ GPUParent::RecvNewWidgetCompositor(Endpo
   RefPtr<CompositorBridgeParent> cbp =
     new CompositorBridgeParent(aScale, aUseExternalSurfaceSize, aSurfaceSize);
 
   MessageLoop* loop = CompositorThreadHolder::Loop();
   loop->PostTask(NewRunnableFunction(OpenParent, cbp, Move(aEndpoint)));
   return true;
 }
 
+bool
+GPUParent::RecvNewContentCompositorBridge(Endpoint<PCompositorBridgeParent>&& aEndpoint)
+{
+  return CompositorBridgeParent::CreateForContent(Move(aEndpoint));
+}
+
 void
 GPUParent::ActorDestroy(ActorDestroyReason aWhy)
 {
   if (AbnormalShutdown == aWhy) {
     NS_WARNING("Shutting down GPU process early due to a crash!");
     ProcessChild::QuickExit();
   }
 
--- a/gfx/ipc/GPUParent.h
+++ b/gfx/ipc/GPUParent.h
@@ -23,16 +23,17 @@ public:
 
   bool RecvInit(nsTArray<GfxPrefSetting>&& prefs) override;
   bool RecvUpdatePref(const GfxPrefSetting& pref) override;
   bool RecvNewWidgetCompositor(
     Endpoint<PCompositorBridgeParent>&& aEndpoint,
     const CSSToLayoutDeviceScale& aScale,
     const bool& aUseExternalSurface,
     const IntSize& aSurfaceSize) override;
+  bool RecvNewContentCompositorBridge(Endpoint<PCompositorBridgeParent>&& aEndpoint) override;
 
   void ActorDestroy(ActorDestroyReason aWhy) override;
 };
 
 } // namespace gfx
 } // namespace mozilla
 
 #endif // _include_gfx_ipc_GPUParent_h__
--- a/gfx/ipc/GPUProcessManager.cpp
+++ b/gfx/ipc/GPUProcessManager.cpp
@@ -278,28 +278,36 @@ GPUProcessManager::CreateRemoteSession(n
 
 bool
 GPUProcessManager::CreateContentCompositorBridge(base::ProcessId aOtherProcess,
                                                  ipc::Endpoint<PCompositorBridgeChild>* aOutEndpoint)
 {
   ipc::Endpoint<PCompositorBridgeParent> parentPipe;
   ipc::Endpoint<PCompositorBridgeChild> childPipe;
 
+  base::ProcessId gpuPid = mGPUChild
+                           ? mGPUChild->OtherPid()
+                           : base::GetCurrentProcId();
+
   nsresult rv = PCompositorBridge::CreateEndpoints(
-    base::GetCurrentProcId(),
+    gpuPid,
     aOtherProcess,
     &parentPipe,
     &childPipe);
   if (NS_FAILED(rv)) {
     gfxCriticalNote << "Could not create content compositor bridge: " << hexa(int(rv));
     return false;
   }
 
-  if (!CompositorBridgeParent::CreateForContent(Move(parentPipe)))
-    return false;
+  if (mGPUChild) {
+    mGPUChild->SendNewContentCompositorBridge(Move(parentPipe));
+  } else {
+    if (!CompositorBridgeParent::CreateForContent(Move(parentPipe)))
+      return false;
+  }
 
   *aOutEndpoint = Move(childPipe);
   return true;
 }
 
 already_AddRefed<APZCTreeManager>
 GPUProcessManager::GetAPZCTreeManagerForLayers(uint64_t aLayersId)
 {
--- a/gfx/ipc/PGPU.ipdl
+++ b/gfx/ipc/PGPU.ipdl
@@ -32,12 +32,15 @@ parent:
   // Called to update a gfx preference.
   async UpdatePref(GfxPrefSetting pref);
 
   // Create a new top-level compositor.
   async NewWidgetCompositor(Endpoint<PCompositorBridgeParent> endpoint,
                             CSSToLayoutDeviceScale scale,
                             bool useExternalSurface,
                             IntSize surfaceSize);
+
+  // Create a new content-process compositor bridge.
+  async NewContentCompositorBridge(Endpoint<PCompositorBridgeParent> endpoint);
 };
 
 } // namespace gfx
 } // namespace mozilla