Bug 1298245 - Hook up creation of OOP APZ for main process. r=dvander

MozReview-Commit-ID: 2Ujw28K2COJ
This commit is contained in:
Ryan Hunt 2016-08-29 09:18:00 -04:00
Родитель 76c800fd89
Коммит 2857345325
8 изменённых файлов: 67 добавлений и 13 удалений

Просмотреть файл

@ -51,7 +51,7 @@ public:
virtual void SetContentController(GeckoContentController* aController) = 0;
// Return the Async Pan/Zoom Tree Manager for this compositor.
virtual already_AddRefed<IAPZCTreeManager> GetAPZCTreeManager() const = 0;
virtual RefPtr<IAPZCTreeManager> GetAPZCTreeManager() const = 0;
// Return the child end of the compositor IPC bridge.
CompositorBridgeChild* GetCompositorBridgeChild();

Просмотреть файл

@ -11,6 +11,7 @@
#include "mozilla/Assertions.h"
#include "mozilla/gfx/gfxVars.h"
#include "mozilla/ipc/ProcessChild.h"
#include "mozilla/layers/APZThreadUtils.h"
#include "mozilla/layers/CompositorBridgeParent.h"
#include "mozilla/layers/CompositorThread.h"
#include "mozilla/layers/ImageBridgeParent.h"
@ -63,6 +64,7 @@ GPUParent::Init(base::ProcessId aParentPid,
return false;
}
CompositorThreadHolder::Start();
APZThreadUtils::SetControllerThread(CompositorThreadHolder::Loop());
VRManager::ManagerInit();
LayerTreeOwnerTracker::Initialize();
mozilla::ipc::SetThisProcessName("GPU Process");

Просмотреть файл

@ -8,6 +8,7 @@
#include "mozilla/StaticPtr.h"
#include "mozilla/dom/ContentParent.h"
#include "mozilla/layers/APZCTreeManager.h"
#include "mozilla/layers/APZCTreeManagerChild.h"
#include "mozilla/layers/CompositorBridgeParent.h"
#include "mozilla/layers/ImageBridgeChild.h"
#include "mozilla/layers/ImageBridgeParent.h"
@ -394,8 +395,17 @@ GPUProcessManager::CreateRemoteSession(nsBaseWidget* aWidget,
return nullptr;
}
RefPtr<APZCTreeManagerChild> apz = nullptr;
if (aUseAPZ) {
PAPZCTreeManagerChild* papz = child->SendPAPZCTreeManagerConstructor(0);
if (!papz) {
return nullptr;
}
apz = static_cast<APZCTreeManagerChild*>(papz);
}
RefPtr<RemoteCompositorSession> session =
new RemoteCompositorSession(child, widget, aRootLayerTreeId);
new RemoteCompositorSession(child, widget, apz, aRootLayerTreeId);
return session.forget();
#else
gfxCriticalNote << "Platform does not support out-of-process compositing";

Просмотреть файл

@ -54,7 +54,7 @@ InProcessCompositorSession::SetContentController(GeckoContentController* aContro
mCompositorBridgeParent->SetControllerForLayerTree(mRootLayerTreeId, aController);
}
already_AddRefed<IAPZCTreeManager>
RefPtr<IAPZCTreeManager>
InProcessCompositorSession::GetAPZCTreeManager() const
{
return mCompositorBridgeParent->GetAPZCTreeManager(mRootLayerTreeId);

Просмотреть файл

@ -29,7 +29,7 @@ public:
CompositorBridgeParent* GetInProcessBridge() const override;
void SetContentController(GeckoContentController* aController) override;
already_AddRefed<IAPZCTreeManager> GetAPZCTreeManager() const override;
RefPtr<IAPZCTreeManager> GetAPZCTreeManager() const override;
void Shutdown() override;
private:

Просмотреть файл

@ -3,8 +3,12 @@
/* 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 {
@ -13,8 +17,10 @@ using namespace widget;
RemoteCompositorSession::RemoteCompositorSession(CompositorBridgeChild* aChild,
CompositorWidgetDelegate* aWidgetDelegate,
APZCTreeManagerChild* aAPZ,
const uint64_t& aRootLayerTreeId)
: CompositorSession(aWidgetDelegate, aChild, aRootLayerTreeId)
, mAPZ(aAPZ)
{
}
@ -27,13 +33,13 @@ RemoteCompositorSession::GetInProcessBridge() const
void
RemoteCompositorSession::SetContentController(GeckoContentController* aController)
{
MOZ_CRASH("NYI");
mCompositorBridgeChild->SendPAPZConstructor(new APZChild(aController), 0);
}
already_AddRefed<IAPZCTreeManager>
RefPtr<IAPZCTreeManager>
RemoteCompositorSession::GetAPZCTreeManager() const
{
return nullptr;
return mAPZ;
}
void

Просмотреть файл

@ -18,13 +18,16 @@ class RemoteCompositorSession final : public CompositorSession
public:
RemoteCompositorSession(CompositorBridgeChild* aChild,
CompositorWidgetDelegate* aWidgetDelegate,
APZCTreeManagerChild* aAPZ,
const uint64_t& aRootLayerTreeId);
CompositorBridgeParent* GetInProcessBridge() const override;
void SetContentController(GeckoContentController* aController) override;
already_AddRefed<IAPZCTreeManager> GetAPZCTreeManager() const override;
RefPtr<IAPZCTreeManager> GetAPZCTreeManager() const override;
void Shutdown() override;
private:
RefPtr<APZCTreeManagerChild> mAPZ;
};
} // namespace layers

Просмотреть файл

@ -1432,31 +1432,64 @@ CompositorBridgeParent::ForceComposeToTarget(DrawTarget* aTarget, const gfx::Int
PAPZCTreeManagerParent*
CompositorBridgeParent::AllocPAPZCTreeManagerParent(const uint64_t& aLayersId)
{
return nullptr;
// The main process should pass in 0 because we assume mRootLayerTreeID
MOZ_ASSERT(aLayersId == 0);
// This message doubles as initialization
MOZ_ASSERT(!mApzcTreeManager);
mApzcTreeManager = new APZCTreeManager();
MonitorAutoLock lock(*sIndirectLayerTreesLock);
CompositorBridgeParent::LayerTreeState& state = sIndirectLayerTrees[mRootLayerTreeID];
MOZ_ASSERT(state.mParent);
MOZ_ASSERT(!state.mApzcTreeManagerParent);
state.mApzcTreeManagerParent = new APZCTreeManagerParent(mRootLayerTreeID, state.mParent->GetAPZCTreeManager());
return state.mApzcTreeManagerParent;
}
bool
CompositorBridgeParent::DeallocPAPZCTreeManagerParent(PAPZCTreeManagerParent* aActor)
{
return false;
delete aActor;
return true;
}
PAPZParent*
CompositorBridgeParent::AllocPAPZParent(const uint64_t& aLayersId)
{
return nullptr;
// The main process should pass in 0 because we assume mRootLayerTreeID
MOZ_ASSERT(aLayersId == 0);
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[mRootLayerTreeID];
MOZ_ASSERT(!state.mController);
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;
// The main process should pass in 0 because we assume mRootLayerTreeID
MOZ_ASSERT(aLayersId == 0);
*aHasAPZ = AsyncPanZoomEnabled();
return true;
}
RefPtr<APZCTreeManager>