mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 13:51:41 +00:00
Bug 1323328 - Part 4: Delay create VRSystemManagerPuppet for making it only be run for tests; r=kip
MozReview-Commit-ID: 6RxFheaP1sg --HG-- extra : rebase_source : 6ceccf9068b8d38e94890f5543c512d5b40639bf
This commit is contained in:
parent
d7b6a3ff79
commit
73147a8a4c
@ -140,7 +140,6 @@ void
|
||||
VRMockDisplay::Update()
|
||||
{
|
||||
gfx::VRManagerChild* vm = gfx::VRManagerChild::Get();
|
||||
MOZ_ASSERT(vm);
|
||||
|
||||
vm->SendSetSensorStateToMockDisplay(mDeviceID, mSensorState);
|
||||
vm->SendSetDisplayInfoToMockDisplay(mDeviceID, mDisplayInfo);
|
||||
@ -177,7 +176,6 @@ void
|
||||
VRMockController::NewButtonEvent(unsigned long aButton, bool aPressed)
|
||||
{
|
||||
gfx::VRManagerChild* vm = gfx::VRManagerChild::Get();
|
||||
MOZ_ASSERT(vm);
|
||||
vm->SendNewButtonEventToMockController(mDeviceID, aButton, aPressed);
|
||||
}
|
||||
|
||||
@ -185,7 +183,6 @@ void
|
||||
VRMockController::NewAxisMoveEvent(unsigned long aAxis, double aValue)
|
||||
{
|
||||
gfx::VRManagerChild* vm = gfx::VRManagerChild::Get();
|
||||
MOZ_ASSERT(vm);
|
||||
vm->SendNewAxisMoveEventToMockController(mDeviceID, aAxis, aValue);
|
||||
}
|
||||
|
||||
@ -198,9 +195,8 @@ VRMockController::NewPoseMove(const Nullable<Float32Array>& aPosition,
|
||||
const Nullable<Float32Array>& aAngularAcceleration)
|
||||
{
|
||||
gfx::VRManagerChild* vm = gfx::VRManagerChild::Get();
|
||||
MOZ_ASSERT(vm);
|
||||
|
||||
GamepadPoseState poseState;
|
||||
|
||||
poseState.flags = GamepadCapabilityFlags::Cap_Orientation |
|
||||
GamepadCapabilityFlags::Cap_Position |
|
||||
GamepadCapabilityFlags::Cap_AngularAcceleration |
|
||||
@ -292,7 +288,10 @@ VRServiceTest::CreateTestService(nsPIDOMWindowInner* aWindow)
|
||||
VRServiceTest::VRServiceTest(nsPIDOMWindowInner* aWindow)
|
||||
: mWindow(aWindow),
|
||||
mShuttingDown(false)
|
||||
{}
|
||||
{
|
||||
gfx::VRManagerChild* vm = gfx::VRManagerChild::Get();
|
||||
vm->SendCreateVRTestSystem();
|
||||
}
|
||||
|
||||
VRServiceTest::~VRServiceTest()
|
||||
{}
|
||||
@ -320,7 +319,6 @@ VRServiceTest::AttachVRDisplay(const nsAString& aID, ErrorResult& aRv)
|
||||
}
|
||||
|
||||
gfx::VRManagerChild* vm = gfx::VRManagerChild::Get();
|
||||
MOZ_ASSERT(vm);
|
||||
vm->CreateVRServiceTestDisplay(nsCString(ToNewUTF8String(aID)), p);
|
||||
|
||||
return p.forget();
|
||||
@ -341,7 +339,6 @@ VRServiceTest::AttachVRController(const nsAString& aID, ErrorResult& aRv)
|
||||
}
|
||||
|
||||
gfx::VRManagerChild* vm = gfx::VRManagerChild::Get();
|
||||
MOZ_ASSERT(vm);
|
||||
vm->CreateVRServiceTestController(nsCString(ToNewUTF8String(aID)), p);
|
||||
|
||||
return p.forget();
|
||||
|
@ -325,7 +325,7 @@ private:
|
||||
DECL_GFX_PREF(Once, "dom.vr.openvr.enabled", VROpenVREnabled, bool, false);
|
||||
DECL_GFX_PREF(Once, "dom.vr.osvr.enabled", VROSVREnabled, bool, false);
|
||||
DECL_GFX_PREF(Live, "dom.vr.poseprediction.enabled", VRPosePredictionEnabled, bool, false);
|
||||
DECL_GFX_PREF(Once, "dom.vr.puppet.enabled", VRPuppetEnabled, bool, false);
|
||||
DECL_GFX_PREF(Live, "dom.vr.puppet.enabled", VRPuppetEnabled, bool, false);
|
||||
DECL_GFX_PREF(Live, "dom.w3c_pointer_events.enabled", PointerEventsEnabled, bool, false);
|
||||
DECL_GFX_PREF(Live, "dom.w3c_touch_events.enabled", TouchEventsEnabled, int32_t, 0);
|
||||
|
||||
|
@ -48,6 +48,7 @@ VRManager::ManagerInit()
|
||||
|
||||
VRManager::VRManager()
|
||||
: mInitialized(false)
|
||||
, mVRTestSystemCreated(false)
|
||||
{
|
||||
MOZ_COUNT_CTOR(VRManager);
|
||||
MOZ_ASSERT(sVRManagerSingleton == nullptr);
|
||||
@ -89,10 +90,6 @@ VRManager::VRManager()
|
||||
mManagers.AppendElement(mgr);
|
||||
}
|
||||
#endif
|
||||
mgr = VRSystemManagerPuppet::Create();
|
||||
if (mgr) {
|
||||
mManagers.AppendElement(mgr);
|
||||
}
|
||||
// Enable gamepad extensions while VR is enabled.
|
||||
// Preference only can be set at the Parent process.
|
||||
if (XRE_IsParentProcess() && gfxPrefs::VREnabled()) {
|
||||
@ -389,6 +386,21 @@ VRManager::RemoveControllers()
|
||||
mVRControllers.Clear();
|
||||
}
|
||||
|
||||
void
|
||||
VRManager::CreateVRTestSystem()
|
||||
{
|
||||
if (mVRTestSystemCreated) {
|
||||
return;
|
||||
}
|
||||
|
||||
RefPtr<VRSystemManager> mgr = VRSystemManagerPuppet::Create();
|
||||
if (mgr) {
|
||||
mgr->Init();
|
||||
mManagers.AppendElement(mgr);
|
||||
mVRTestSystemCreated = true;
|
||||
}
|
||||
}
|
||||
|
||||
template<class T>
|
||||
void
|
||||
VRManager::NotifyGamepadChange(const T& aInfo)
|
||||
|
@ -48,6 +48,7 @@ public:
|
||||
const gfx::Rect& aRightEyeRect);
|
||||
RefPtr<gfx::VRControllerHost> GetController(const uint32_t& aControllerID);
|
||||
void GetVRControllerInfo(nsTArray<VRControllerInfo>& aControllerInfo);
|
||||
void CreateVRTestSystem();
|
||||
|
||||
protected:
|
||||
VRManager();
|
||||
@ -77,6 +78,7 @@ private:
|
||||
Atomic<bool> mInitialized;
|
||||
|
||||
TimeStamp mLastRefreshTime;
|
||||
bool mVRTestSystemCreated;
|
||||
};
|
||||
|
||||
} // namespace gfx
|
||||
|
@ -314,8 +314,6 @@ VRSystemManagerPuppet::VRSystemManagerPuppet()
|
||||
/*static*/ already_AddRefed<VRSystemManagerPuppet>
|
||||
VRSystemManagerPuppet::Create()
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
if (!gfxPrefs::VREnabled() || !gfxPrefs::VRPuppetEnabled()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -62,6 +62,7 @@ parent:
|
||||
// GetControllers synchronously returns the VR controllers that have already been
|
||||
// enumerated by RefreshVRControllers() but does not enumerate new ones.
|
||||
sync GetControllers() returns(VRControllerInfo[] aControllerInfo);
|
||||
async CreateVRTestSystem();
|
||||
async CreateVRServiceTestDisplay(nsCString aID, uint32_t aPromiseID);
|
||||
async CreateVRServiceTestController(nsCString aID, uint32_t aPromiseID);
|
||||
async SetDisplayInfoToMockDisplay(uint32_t aDeviceID, VRDisplayInfo aDisplayInfo);
|
||||
|
@ -329,6 +329,14 @@ VRManagerParent::RecvGetControllers(nsTArray<VRControllerInfo> *aControllers)
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult
|
||||
VRManagerParent::RecvCreateVRTestSystem()
|
||||
{
|
||||
VRManager* vm = VRManager::Get();
|
||||
vm->CreateVRTestSystem();
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult
|
||||
VRManagerParent::RecvCreateVRServiceTestDisplay(const nsCString& aID, const uint32_t& aPromiseID)
|
||||
{
|
||||
|
@ -94,6 +94,7 @@ protected:
|
||||
virtual mozilla::ipc::IPCResult RecvControllerListenerAdded() override;
|
||||
virtual mozilla::ipc::IPCResult RecvControllerListenerRemoved() override;
|
||||
virtual mozilla::ipc::IPCResult RecvGetControllers(nsTArray<VRControllerInfo> *aControllers) override;
|
||||
virtual mozilla::ipc::IPCResult RecvCreateVRTestSystem() override;
|
||||
virtual mozilla::ipc::IPCResult RecvCreateVRServiceTestDisplay(const nsCString& aID, const uint32_t& aPromiseID) override;
|
||||
virtual mozilla::ipc::IPCResult RecvCreateVRServiceTestController(const nsCString& aID, const uint32_t& aPromiseID) override;
|
||||
virtual mozilla::ipc::IPCResult RecvSetDisplayInfoToMockDisplay(const uint32_t& aDeviceID,
|
||||
|
Loading…
Reference in New Issue
Block a user