Bug 1289650 - Allow main process to create PAPZ, PAPZCTreeManager. r?kats draft
authorRyan Hunt <rhunt@mozilla.com>
Sun, 21 Aug 2016 23:48:08 -0700
changeset 403815 80c1369f10404547771405b10478b67d9aea39f2
parent 403814 6c44d99e7df2aa8972cee53b6dd57a099e2eb841
child 529007 33a187bcc7c934a7cb50a6bbd9bf6a0e3ecb7060
push id27018
push userbmo:rhunt@mozilla.com
push dateMon, 22 Aug 2016 08:19:27 +0000
reviewerskats
bugs1289650
milestone51.0a1
Bug 1289650 - Allow main process to create PAPZ, PAPZCTreeManager. r?kats MozReview-Commit-ID: 2Ujw28K2COJ
gfx/ipc/RemoteCompositorSession.cpp
gfx/layers/ipc/CompositorBridgeParent.cpp
--- a/gfx/ipc/RemoteCompositorSession.cpp
+++ b/gfx/ipc/RemoteCompositorSession.cpp
@@ -1,15 +1,19 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=99: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
 #include "RemoteCompositorSession.h"
 
+#include "mozilla/layers/APZChild.h"
+#include "mozilla/layers/APZCTreeManagerChild.h"
+
 namespace mozilla {
 namespace layers {
 
 using namespace gfx;
 using namespace widget;
 
 RemoteCompositorSession::RemoteCompositorSession(CompositorBridgeChild* aChild,
                                                  CompositorWidgetDelegate* aWidgetDelegate,
@@ -22,23 +26,25 @@ CompositorBridgeParent*
 RemoteCompositorSession::GetInProcessBridge() const
 {
   return nullptr;
 }
 
 void
 RemoteCompositorSession::SetContentController(GeckoContentController* aController)
 {
-  MOZ_CRASH("NYI");
+  APZChild* apz = new APZChild();
+  apz->SetController(aController);
+  mCompositorBridgeChild->SendPAPZConstructor(apz, mRootLayerTreeId);
 }
 
 already_AddRefed<IAPZCTreeManager>
 RemoteCompositorSession::GetAPZCTreeManager() const
 {
-  return nullptr;
+  return mCompositorBridgeChild->GetAPZCTreeManager(mRootLayerTreeId).forget();
 }
 
 void
 RemoteCompositorSession::Shutdown()
 {
   mCompositorBridgeChild->Destroy();
   mCompositorBridgeChild = nullptr;
   mCompositorWidgetDelegate = nullptr;
--- a/gfx/layers/ipc/CompositorBridgeParent.cpp
+++ b/gfx/layers/ipc/CompositorBridgeParent.cpp
@@ -655,16 +655,17 @@ CompositorBridgeParent::Bind(Endpoint<PC
   mSelfRef = this;
   return true;
 }
 
 bool
 CompositorBridgeParent::RecvInitialize(const uint64_t& aRootLayerTreeId)
 {
   mRootLayerTreeID = aRootLayerTreeId;
+  mApzcTreeManager = new APZCTreeManager();
 
   Initialize();
   return true;
 }
 
 void
 CompositorBridgeParent::Initialize()
 {
@@ -1342,41 +1343,62 @@ CompositorBridgeParent::ForceComposeToTa
   AutoRestore<bool> override(mOverrideComposeReadiness);
   mOverrideComposeReadiness = true;
   mCompositorScheduler->ForceComposeToTarget(aTarget, aRect);
 }
 
 PAPZCTreeManagerParent*
 CompositorBridgeParent::AllocPAPZCTreeManagerParent(const uint64_t& aLayersId)
 {
-  return nullptr;
+  // The main process should only be using the mRootLayerTreeID.
+  MOZ_ASSERT(aLayersId == mRootLayerTreeID);
+
+  return new APZCTreeManagerParent(mRootLayerTreeID, GetAPZCTreeManager());
 }
 
 bool
 CompositorBridgeParent::DeallocPAPZCTreeManagerParent(PAPZCTreeManagerParent* aActor)
 {
-  return false;
+  delete aActor;
+  return true;
 }
 
 PAPZParent*
 CompositorBridgeParent::AllocPAPZParent(const uint64_t& aLayersId)
 {
-  return nullptr;
+  // The main process should only be using the mRootLayerTreeID.
+  MOZ_ASSERT(aLayersId == mRootLayerTreeID);
+
+  RemoteContentController* controller = new RemoteContentController();
+
+  // Increment the controller's refcount before we return it. This will keep the
+  // controller alive until it is released by IPDL in DeallocPAPZParent.
+  controller->AddRef();
+
+  MonitorAutoLock lock(*sIndirectLayerTreesLock);
+  CompositorBridgeParent::LayerTreeState& state = sIndirectLayerTrees[aLayersId];
+  state.mController = controller;
+
+  return controller;
 }
 
 bool
 CompositorBridgeParent::DeallocPAPZParent(PAPZParent* aActor)
 {
-  return false;
+  RemoteContentController* controller = static_cast<RemoteContentController*>(aActor);
+  controller->Release();
+  return true;
 }
 
 bool
 CompositorBridgeParent::RecvAsyncPanZoomEnabled(const uint64_t& aLayersId, bool* aHasAPZ)
 {
-  return false;
+  MOZ_ASSERT(aLayersId == mRootLayerTreeID);
+  *aHasAPZ = AsyncPanZoomEnabled();
+  return true;
 }
 
 RefPtr<APZCTreeManager>
 CompositorBridgeParent::GetAPZCTreeManager()
 {
   return mApzcTreeManager;
 }