mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 03:15:11 +00:00
Bug 1481327 - Part 1: Launch VR service in VR process., r=kip,r=mccr8
--HG-- extra : rebase_source : 1de178356f2c4550f01635763e80fbd05b7b0c05
This commit is contained in:
parent
e685fe000f
commit
a642b0a38b
@ -311,9 +311,6 @@ mozilla::ipc::IPCResult
|
||||
GPUParent::RecvInitVR(Endpoint<PVRGPUChild>&& aEndpoint)
|
||||
{
|
||||
gfx::VRGPUChild::InitForGPUProcess(std::move(aEndpoint));
|
||||
|
||||
// TODO:: Bug 1481327: init VR process shared memory handle via VRGPUChild::Get();
|
||||
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,7 @@
|
||||
|
||||
#include "VRManager.h"
|
||||
#include "VRManagerParent.h"
|
||||
#include "VRGPUChild.h"
|
||||
#include "VRThread.h"
|
||||
#include "gfxVR.h"
|
||||
#include "mozilla/ClearOnShutdown.h"
|
||||
@ -61,6 +62,7 @@ VRManager::VRManager()
|
||||
: mInitialized(false)
|
||||
, mVRDisplaysRequested(false)
|
||||
, mVRControllersRequested(false)
|
||||
, mVRServiceStarted(false)
|
||||
{
|
||||
MOZ_COUNT_CTOR(VRManager);
|
||||
MOZ_ASSERT(sVRManagerSingleton == nullptr);
|
||||
@ -154,7 +156,12 @@ VRManager::Destroy()
|
||||
for (uint32_t i = 0; i < mManagers.Length(); ++i) {
|
||||
mManagers[i]->Destroy();
|
||||
}
|
||||
|
||||
#if defined(XP_WIN) || defined(XP_MACOSX) || (defined(XP_LINUX) && !defined(MOZ_WIDGET_ANDROID))
|
||||
if (mVRService) {
|
||||
mVRService->Stop();
|
||||
mVRService = nullptr;
|
||||
}
|
||||
#endif
|
||||
mInitialized = false;
|
||||
}
|
||||
|
||||
@ -170,7 +177,18 @@ VRManager::Shutdown()
|
||||
if (mVRService) {
|
||||
mVRService->Stop();
|
||||
}
|
||||
if (gfxPrefs::VRProcessEnabled()) {
|
||||
RefPtr<Runnable> task = NS_NewRunnableFunction(
|
||||
"VRGPUChild::SendStopVRService",
|
||||
[] () -> void {
|
||||
VRGPUChild* vrGPUChild = VRGPUChild::Get();
|
||||
vrGPUChild->SendStopVRService();
|
||||
});
|
||||
|
||||
NS_DispatchToMainThread(task.forget());
|
||||
}
|
||||
#endif
|
||||
mVRServiceStarted = false;
|
||||
}
|
||||
|
||||
void
|
||||
@ -358,8 +376,22 @@ VRManager::RefreshVRDisplays(bool aMustDispatch)
|
||||
*/
|
||||
if (mVRDisplaysRequested || aMustDispatch) {
|
||||
#if defined(XP_WIN) || defined(XP_MACOSX) || (defined(XP_LINUX) && !defined(MOZ_WIDGET_ANDROID))
|
||||
if (mVRService) {
|
||||
mVRService->Start();
|
||||
// Tell VR process to start VR service.
|
||||
if (gfxPrefs::VRProcessEnabled() && !mVRServiceStarted) {
|
||||
RefPtr<Runnable> task = NS_NewRunnableFunction(
|
||||
"VRGPUChild::SendStartVRService",
|
||||
[] () -> void {
|
||||
VRGPUChild* vrGPUChild = VRGPUChild::Get();
|
||||
vrGPUChild->SendStartVRService();
|
||||
});
|
||||
|
||||
NS_DispatchToMainThread(task.forget());
|
||||
mVRServiceStarted = true;
|
||||
} else if (!gfxPrefs::VRProcessEnabled()){
|
||||
if (mVRService) {
|
||||
mVRService->Start();
|
||||
mVRServiceStarted = true;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
EnumerateVRDisplays();
|
||||
|
@ -102,6 +102,7 @@ private:
|
||||
#endif
|
||||
bool mVRDisplaysRequested;
|
||||
bool mVRControllersRequested;
|
||||
bool mVRServiceStarted;
|
||||
};
|
||||
|
||||
} // namespace gfx
|
||||
|
@ -10,7 +10,8 @@ namespace gfx {
|
||||
async protocol PVRGPU
|
||||
{
|
||||
parent:
|
||||
async InitVRService(nsCString aId, uint64_t aGPUHandle, uint64_t aVRHandle, uint64_t aShmemFile);
|
||||
async StartVRService();
|
||||
async StopVRService();
|
||||
};
|
||||
|
||||
} // gfx
|
||||
|
@ -39,12 +39,6 @@ VRGPUChild::Get()
|
||||
return sVRGPUChildSingleton;
|
||||
}
|
||||
|
||||
/*static*/ void
|
||||
VRGPUChild::DeferredDestroy(RefPtr<VRGPUChild> aVRGPUChild)
|
||||
{
|
||||
aVRGPUChild->Close();
|
||||
}
|
||||
|
||||
/*static*/ void
|
||||
VRGPUChild::ShutDown()
|
||||
{
|
||||
|
@ -26,7 +26,6 @@ protected:
|
||||
explicit VRGPUChild() {}
|
||||
~VRGPUChild() {}
|
||||
|
||||
static void DeferredDestroy(RefPtr<VRGPUChild> aVRManagerChild);
|
||||
void Destroy();
|
||||
|
||||
private:
|
||||
|
@ -26,6 +26,13 @@ VRGPUParent::VRGPUParent(ProcessId aChildProcessId)
|
||||
void
|
||||
VRGPUParent::ActorDestroy(ActorDestroyReason aWhy)
|
||||
{
|
||||
#if defined(XP_WIN) || defined(XP_MACOSX) || (defined(XP_LINUX) && !defined(MOZ_WIDGET_ANDROID))
|
||||
if (mVRService) {
|
||||
mVRService->Stop();
|
||||
mVRService = nullptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
MessageLoop::current()->PostTask(
|
||||
NewRunnableMethod("gfx::VRGPUParent::DeferredDestroy",
|
||||
this,
|
||||
@ -63,10 +70,28 @@ VRGPUParent::Bind(Endpoint<PVRGPUParent>&& aEndpoint)
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult
|
||||
VRGPUParent::RecvInitVRService(const nsCString& aId, const uint64_t& aGPUHandle,
|
||||
const uint64_t& aVRHandle, const uint64_t& aShmemFile)
|
||||
VRGPUParent::RecvStartVRService()
|
||||
{
|
||||
// TODO: Create duplicate shared memory handle from GPU process.
|
||||
#if defined(XP_WIN) || defined(XP_MACOSX) || (defined(XP_LINUX) && !defined(MOZ_WIDGET_ANDROID))
|
||||
mVRService = VRService::Create();
|
||||
MOZ_ASSERT(mVRService);
|
||||
|
||||
mVRService->Start();
|
||||
#endif
|
||||
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult
|
||||
VRGPUParent::RecvStopVRService()
|
||||
{
|
||||
#if defined(XP_WIN) || defined(XP_MACOSX) || (defined(XP_LINUX) && !defined(MOZ_WIDGET_ANDROID))
|
||||
if (mVRService) {
|
||||
mVRService->Stop();
|
||||
mVRService = nullptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
|
@ -25,10 +25,8 @@ protected:
|
||||
~VRGPUParent() {}
|
||||
|
||||
void Bind(Endpoint<PVRGPUParent>&& aEndpoint);
|
||||
virtual mozilla::ipc::IPCResult RecvInitVRService(const nsCString& aId,
|
||||
const uint64_t& aGPUHandle,
|
||||
const uint64_t& aVRHandle,
|
||||
const uint64_t& aShmemFile) override;
|
||||
virtual mozilla::ipc::IPCResult RecvStartVRService() override;
|
||||
virtual mozilla::ipc::IPCResult RecvStopVRService() override;
|
||||
|
||||
private:
|
||||
void DeferredDestroy();
|
||||
|
Loading…
Reference in New Issue
Block a user