зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1315718 - Replace mGamepadManager raw pointer with RefPtr in VRManagerChild. r=smaug, kip, dmu
MozReview-Commit-ID: HOqQm2F6Dpn --- dom/gamepad/GamepadManager.cpp | 1 - gfx/vr/ipc/VRManagerChild.cpp | 18 ++++++------------ gfx/vr/ipc/VRManagerChild.h | 4 ---- gfx/vr/ipc/VRManagerParent.cpp | 21 +++++++++++++++++---- gfx/vr/ipc/VRManagerParent.h | 4 +++- 5 files changed, 26 insertions(+), 22 deletions(-) --HG-- extra : amend_source : 4a687f8cbe12d88da3c88e0dba859331806fc6ff
This commit is contained in:
Родитель
d5527884b7
Коммит
a766482389
|
@ -684,7 +684,6 @@ GamepadManager::ActorCreated(PBackgroundChild *aActor)
|
|||
// Construct VRManagerChannel and ask adding the connected
|
||||
// VR controllers to GamepadManager
|
||||
mVRChannelChild = gfx::VRManagerChild::Get();
|
||||
mVRChannelChild->SetGamepadManager(this);
|
||||
mVRChannelChild->SendControllerListenerAdded();
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -42,7 +42,6 @@ void ReleaseVRManagerParentSingleton() {
|
|||
VRManagerChild::VRManagerChild()
|
||||
: TextureForwarder()
|
||||
, mDisplaysInitialized(false)
|
||||
, mGamepadManager(nullptr)
|
||||
, mInputFrameID(-1)
|
||||
, mMessageLoop(MessageLoop::current())
|
||||
, mFrameRequestCallbackCounter(0)
|
||||
|
@ -484,10 +483,13 @@ VRManagerChild::RecvGamepadUpdate(const GamepadChangeEvent& aGamepadEvent)
|
|||
{
|
||||
#ifdef MOZ_GAMEPAD
|
||||
// VRManagerChild could be at other processes, but GamepadManager
|
||||
// only exists at the content process or the parent process
|
||||
// only exists at the content process or the same process
|
||||
// in non-e10s mode.
|
||||
if (mGamepadManager) {
|
||||
mGamepadManager->Update(aGamepadEvent);
|
||||
MOZ_ASSERT(XRE_IsContentProcess() || IsSameProcess());
|
||||
|
||||
RefPtr<GamepadManager> gamepadManager(GamepadManager::GetService());
|
||||
if (gamepadManager) {
|
||||
gamepadManager->Update(aGamepadEvent);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -587,13 +589,5 @@ VRManagerChild::HandleFatalError(const char* aName, const char* aMsg) const
|
|||
dom::ContentChild::FatalErrorIfNotUsingGPUProcess(aName, aMsg, OtherPid());
|
||||
}
|
||||
|
||||
void
|
||||
VRManagerChild::SetGamepadManager(dom::GamepadManager* aGamepadManager)
|
||||
{
|
||||
MOZ_ASSERT(aGamepadManager);
|
||||
|
||||
mGamepadManager = aGamepadManager;
|
||||
}
|
||||
|
||||
} // namespace gfx
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -78,9 +78,6 @@ public:
|
|||
int32_t *aHandle);
|
||||
void CancelFrameRequestCallback(int32_t aHandle);
|
||||
void RunFrameRequestCallbacks();
|
||||
// GamepadManager has to be set by the content side to make sure we are using
|
||||
// the same singleton GamepadManager from the same process.
|
||||
void SetGamepadManager(dom::GamepadManager* aGamepadManager);
|
||||
|
||||
void UpdateDisplayInfo(nsTArray<VRDisplayInfo>& aDisplayUpdates);
|
||||
void FireDOMVRDisplayConnectEvent();
|
||||
|
@ -153,7 +150,6 @@ private:
|
|||
nsTArray<RefPtr<VRDisplayClient> > mDisplays;
|
||||
bool mDisplaysInitialized;
|
||||
nsTArray<uint64_t> mNavigatorCallbacks;
|
||||
dom::GamepadManager* mGamepadManager;
|
||||
|
||||
int32_t mInputFrameID;
|
||||
|
||||
|
|
|
@ -19,9 +19,10 @@ namespace mozilla {
|
|||
using namespace layers;
|
||||
namespace gfx {
|
||||
|
||||
VRManagerParent::VRManagerParent(ProcessId aChildProcessId)
|
||||
VRManagerParent::VRManagerParent(ProcessId aChildProcessId, bool aIsContentChild)
|
||||
: HostIPCAllocator()
|
||||
, mHaveEventListener(false)
|
||||
, mIsContentChild(aIsContentChild)
|
||||
{
|
||||
MOZ_COUNT_CTOR(VRManagerParent);
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
@ -156,7 +157,7 @@ VRManagerParent::CreateForContent(Endpoint<PVRManagerParent>&& aEndpoint)
|
|||
{
|
||||
MessageLoop* loop = layers::CompositorThreadHolder::Loop();
|
||||
|
||||
RefPtr<VRManagerParent> vmp = new VRManagerParent(aEndpoint.OtherPid());
|
||||
RefPtr<VRManagerParent> vmp = new VRManagerParent(aEndpoint.OtherPid(), true);
|
||||
loop->PostTask(NewRunnableMethod<Endpoint<PVRManagerParent>&&>(
|
||||
vmp, &VRManagerParent::Bind, Move(aEndpoint)));
|
||||
|
||||
|
@ -184,7 +185,7 @@ VRManagerParent::RegisterVRManagerInCompositorThread(VRManagerParent* aVRManager
|
|||
VRManagerParent::CreateSameProcess()
|
||||
{
|
||||
MessageLoop* loop = mozilla::layers::CompositorThreadHolder::Loop();
|
||||
RefPtr<VRManagerParent> vmp = new VRManagerParent(base::GetCurrentProcId());
|
||||
RefPtr<VRManagerParent> vmp = new VRManagerParent(base::GetCurrentProcId(), false);
|
||||
vmp->mCompositorThreadHolder = layers::CompositorThreadHolder::GetSingleton();
|
||||
vmp->mSelfRef = vmp;
|
||||
loop->PostTask(NewRunnableFunction(RegisterVRManagerInCompositorThread, vmp.get()));
|
||||
|
@ -196,7 +197,7 @@ VRManagerParent::CreateForGPUProcess(Endpoint<PVRManagerParent>&& aEndpoint)
|
|||
{
|
||||
MessageLoop* loop = mozilla::layers::CompositorThreadHolder::Loop();
|
||||
|
||||
RefPtr<VRManagerParent> vmp = new VRManagerParent(aEndpoint.OtherPid());
|
||||
RefPtr<VRManagerParent> vmp = new VRManagerParent(aEndpoint.OtherPid(), false);
|
||||
vmp->mCompositorThreadHolder = layers::CompositorThreadHolder::GetSingleton();
|
||||
loop->PostTask(NewRunnableMethod<Endpoint<PVRManagerParent>&&>(
|
||||
vmp, &VRManagerParent::Bind, Move(aEndpoint)));
|
||||
|
@ -315,5 +316,17 @@ VRManagerParent::RecvGetControllers(nsTArray<VRControllerInfo> *aControllers)
|
|||
return IPC_OK();
|
||||
}
|
||||
|
||||
bool
|
||||
VRManagerParent::SendGamepadUpdate(const GamepadChangeEvent& aGamepadEvent)
|
||||
{
|
||||
// GamepadManager only exists at the content process
|
||||
// or the same process in non-e10s mode.
|
||||
if (mIsContentChild || IsSameProcess()) {
|
||||
return PVRManagerParent::SendGamepadUpdate(aGamepadEvent);
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace gfx
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -27,7 +27,7 @@ class VRManagerParent final : public PVRManagerParent
|
|||
, public ShmemAllocator
|
||||
{
|
||||
public:
|
||||
explicit VRManagerParent(ProcessId aChildProcessId);
|
||||
explicit VRManagerParent(ProcessId aChildProcessId, bool aIsContentChild);
|
||||
|
||||
static VRManagerParent* CreateSameProcess();
|
||||
static bool CreateForGPUProcess(Endpoint<PVRManagerParent>&& aEndpoint);
|
||||
|
@ -54,6 +54,7 @@ public:
|
|||
|
||||
virtual void NotifyNotUsed(PTextureParent* aTexture, uint64_t aTransactionId) override;
|
||||
virtual void SendAsyncMessage(const InfallibleTArray<AsyncParentMessageData>& aMessage) override;
|
||||
bool SendGamepadUpdate(const GamepadChangeEvent& aGamepadEvent);
|
||||
|
||||
protected:
|
||||
~VRManagerParent();
|
||||
|
@ -108,6 +109,7 @@ private:
|
|||
// Keep the VRManager alive, until we have destroyed ourselves.
|
||||
RefPtr<VRManager> mVRManagerHolder;
|
||||
bool mHaveEventListener;
|
||||
bool mIsContentChild;
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
|
Загрузка…
Ссылка в новой задаче