Bug 1407423 - Part 3: Update Puppet Device Implementation,r=daoshengmu

- Update prefs to accomodate tests, disabling
  enumeration throttling
- Updated Puppet display and controller implementation
  to act more like the actual devices.
- Updated tests to ensure that they explicitly
  create a VR mock display and don't create duplicate
  mock displays.

MozReview-Commit-ID: 6RPVqekG2je

--HG--
extra : rebase_source : 9cc9ea116114cc191edbf5a01ac8f84fff9709c4
This commit is contained in:
Kearwood Gilbert 2017-11-21 14:18:16 -08:00
Родитель f34bcd9f1e
Коммит 1bed477cca
14 изменённых файлов: 244 добавлений и 136 удалений

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

@ -6,6 +6,10 @@ var VRSimulationDriver = (function() {
"use strict";
var AttachWebVRDisplay = function() {
if (vrMockDisplay) {
// Avoid creating multiple displays
return Promise.resolve(vrMockDisplay);
}
var promise = VRServiceTest.attachVRDisplay("VRDisplayTest");
promise.then(function (display) {
assert_true(display != null, "AttachWebVRDisplay should success.");

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

@ -1,7 +1,9 @@
function runVRTest(callback) {
SpecialPowers.pushPrefEnv({"set" : [["dom.vr.puppet.enabled", true],
["dom.vr.require-gesture", false],
["dom.vr.test.enabled", true]]},
["dom.vr.test.enabled", true],
["dom.vr.display.enumerate.interval", 0],
["dom.vr.controller.enumerate.interval", 0]]},
() => {
VRServiceTest = navigator.requestVRServiceTest();
callback();

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

@ -38,12 +38,14 @@
function startTest() {
promise_test((test) => {
listenControllerEvents();
return navigator.getVRDisplays().then((displays) => {
vrDisplay = displays[0];
assert_equals(displays.length, 1, "displays.length must be one after attach.");
assert_equals(displays[0].displayId, 1, "displayId must be one.");
addController();
addController();
return VRSimulationDriver.AttachWebVRDisplay().then(() => {
return navigator.getVRDisplays().then((displays) => {
vrDisplay = displays[0];
assert_equals(displays.length, 1, "displays.length must be one after attach.");
assert_equals(displays[0].displayId, 1, "displayId must be one.");
addController();
addController();
});
});
}, "Finish to add VRDisplay.");
}

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

@ -6,6 +6,7 @@
<meta http-equiv="Content-type" content="text/html;charset=UTF-8">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="VRSimulationDriver.js"></script>
<script src="runVRTest.js"></script>
</head>
<body>
@ -35,12 +36,14 @@
var img = document.createElement('img');
img.src = "data:image/gif;base64,R0lGODlhAQABAAAAACw=";
return navigator.getVRDisplays().then((displays) => {
assert_equals(displays.length, 1, "displays.length must be one after attach.");
vrDisplay = displays[0];
var frameData = new VRFrameData();
return vrDisplay.requestPresent([{source: canvas}]).then(() => {
requestPresentTest();
return VRSimulationDriver.AttachWebVRDisplay().then(() => {
return navigator.getVRDisplays().then((displays) => {
assert_equals(displays.length, 1, "displays.length must be one after attach.");
vrDisplay = displays[0];
var frameData = new VRFrameData();
return vrDisplay.requestPresent([{source: canvas}]).then(() => {
requestPresentTest();
});
});
});
}, "Finish running WebVR Canvas2D test.");

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

@ -6,6 +6,7 @@
<meta http-equiv="Content-type" content="text/html;charset=UTF-8">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="VRSimulationDriver.js"></script>
<script src="runVRTest.js"></script>
</head>
<body>
@ -17,23 +18,29 @@
});
}
var initVRPresentation = function(content) {
return content.navigator.getVRDisplays().then((displays) => {
return VRSimulationDriver.AttachWebVRDisplay().then(() => {
return content.navigator.getVRDisplays().then((displays) => {
content.vrDisplay = displays[0];
content.canvas = content.document.createElement("canvas");
content.canvas.id = "vrCanvas";
return content.vrDisplay.requestPresent([{source:content.canvas}]);
});
});
}
function startTest() {
var ifr1 = document.getElementById("iframe1");
var ifr2 = document.getElementById("iframe2");
var frame1 = ifr1.contentWindow;
var frame2 = ifr2.contentWindow;
initVRPresentation(frame1).then(() => {
promise_test((test) => {
return promise_rejects(test, null, testExitPresentOnOtherIframe(frame2));
}, "We cannot exist VR presentation established by another content, this promise is expected to be rejected.")
});
promise_test((test) => {
return VRSimulationDriver.AttachWebVRDisplay().then(() => {
return initVRPresentation(frame1).then(() => {
promise_test((test) => {
return promise_rejects(test, null, testExitPresentOnOtherIframe(frame2));
}, "We cannot exit VR presentation established by another content, this promise is expected to be rejected.")
});
});
}, "Finish running WebVR exitPresent test.");
}
runVRTest(startTest);
</script>

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

@ -6,6 +6,10 @@ var VRSimulationDriver = (function() {
"use strict";
var AttachWebVRDisplay = function() {
if (vrMockDisplay) {
// Avoid creating multiple displays
return Promise.resolve(vrMockDisplay);
}
var promise = VRServiceTest.attachVRDisplay("VRDisplayTest");
promise.then(function (display) {
vrMockDisplay = display;

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

@ -1,6 +1,6 @@
# WebVR Reftests
# Please confirm there is no other VR display connected. Otherwise, VRPuppetDisplay can't be attached.
default-preferences pref(dom.vr.puppet.enabled,true) pref(dom.vr.test.enabled,true) pref(dom.vr.require-gesture,false) pref(dom.vr.puppet.submitframe,1) pref(dom.vr.display.rafMaxDuration,200)
default-preferences pref(dom.vr.puppet.enabled,true) pref(dom.vr.test.enabled,true) pref(dom.vr.require-gesture,false) pref(dom.vr.puppet.submitframe,1) pref(dom.vr.display.rafMaxDuration,200) pref(dom.vr.display.enumerate.interval,0) pref(dom.vr.controller.enumerate.interval,0)
# VR SubmitFrame is only implemented for D3D11.1 and MacOSX now.
# Our Windows 7 test machines don't support D3D11.1, so we run these tests on Windows 8+ only.

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

@ -55,7 +55,6 @@ VRManager::ManagerInit()
VRManager::VRManager()
: mInitialized(false)
, mVRTestSystemCreated(false)
, mVRDisplaysRequested(false)
, mVRControllersRequested(false)
{
@ -498,15 +497,20 @@ VRManager::RemoveControllers()
void
VRManager::CreateVRTestSystem()
{
if (mVRTestSystemCreated) {
if (mPuppetManager) {
mPuppetManager->ClearTestDisplays();
return;
}
RefPtr<VRSystemManager> mgr = VRSystemManagerPuppet::Create();
if (mgr) {
mManagers.AppendElement(mgr);
mVRTestSystemCreated = true;
}
mPuppetManager = VRSystemManagerPuppet::Create();
mManagers.AppendElement(mPuppetManager);
}
VRSystemManagerPuppet*
VRManager::GetPuppetManager()
{
MOZ_ASSERT(mPuppetManager);
return mPuppetManager;
}
template<class T>

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

@ -23,6 +23,7 @@ namespace gfx {
class VRLayerParent;
class VRManagerParent;
class VRDisplayHost;
class VRSystemManagerPuppet;
class VRManager
{
@ -47,6 +48,8 @@ public:
RefPtr<gfx::VRControllerHost> GetController(const uint32_t& aControllerID);
void GetVRControllerInfo(nsTArray<VRControllerInfo>& aControllerInfo);
void CreateVRTestSystem();
VRSystemManagerPuppet* GetPuppetManager();
void VibrateHaptic(uint32_t aControllerIdx, uint32_t aHapticIndex,
double aIntensity, double aDuration, const VRManagerPromise& aPromise);
void StopVibrateHaptic(uint32_t aControllerIdx);
@ -85,7 +88,7 @@ private:
TimeStamp mLastControllerEnumerationTime;
TimeStamp mLastDisplayEnumerationTime;
TimeStamp mLastActiveTime;
bool mVRTestSystemCreated;
RefPtr<VRSystemManagerPuppet> mPuppetManager;
bool mVRDisplaysRequested;
bool mVRControllersRequested;
};

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

@ -675,6 +675,9 @@ VRControllerPuppet::SetAxisMove(uint32_t aAxis, float aValue)
}
VRSystemManagerPuppet::VRSystemManagerPuppet()
: mPuppetDisplayCount(0)
, mPuppetDisplayInfo{}
, mPuppetDisplaySensorState{}
{
}
@ -698,58 +701,119 @@ VRSystemManagerPuppet::Destroy()
void
VRSystemManagerPuppet::Shutdown()
{
mPuppetHMD = nullptr;
mPuppetHMDs.Clear();
}
void
VRSystemManagerPuppet::NotifyVSync()
{
VRSystemManager::NotifyVSync();
if (mPuppetHMD) {
mPuppetHMD->Refresh();
for (const auto& display: mPuppetHMDs) {
display->Refresh();
}
}
uint32_t
VRSystemManagerPuppet::CreateTestDisplay()
{
if (mPuppetDisplayCount >= kMaxPuppetDisplays) {
MOZ_ASSERT(false);
return mPuppetDisplayCount;
}
return mPuppetDisplayCount++;
}
void
VRSystemManagerPuppet::ClearTestDisplays()
{
mPuppetDisplayCount = 0;
}
void
VRSystemManagerPuppet::Enumerate()
{
if (mPuppetHMD == nullptr) {
mPuppetHMD = new VRDisplayPuppet();
while (mPuppetHMDs.Length() < mPuppetDisplayCount) {
VRDisplayPuppet* puppetDisplay = new VRDisplayPuppet();
uint32_t deviceID = mPuppetHMDs.Length();
puppetDisplay->SetDisplayInfo(mPuppetDisplayInfo[deviceID]);
puppetDisplay->SetSensorState(mPuppetDisplaySensorState[deviceID]);
mPuppetHMDs.AppendElement(puppetDisplay);
}
while (mPuppetHMDs.Length() > mPuppetDisplayCount) {
mPuppetHMDs.RemoveElementAt(mPuppetHMDs.Length() - 1);
}
}
bool
VRSystemManagerPuppet::ShouldInhibitEnumeration()
void
VRSystemManagerPuppet::SetPuppetDisplayInfo(const uint32_t& aDeviceID,
const VRDisplayInfo& aDisplayInfo)
{
if (VRSystemManager::ShouldInhibitEnumeration()) {
return true;
if (aDeviceID >= mPuppetDisplayCount) {
MOZ_ASSERT(false);
return;
}
if (mPuppetHMD) {
// When we find an a VR device, don't
// allow any further enumeration as it
// may get picked up redundantly by other
// API's.
return true;
/**
* Even if mPuppetHMDs.Length() <= aDeviceID, we need to
* update mPuppetDisplayInfo[aDeviceID]. In the case that
* a puppet display is added and SetPuppetDisplayInfo is
* immediately called, mPuppetHMDs may not be populated yet.
* VRSystemManagerPuppet::Enumerate() will initialize
* the VRDisplayPuppet later using mPuppetDisplayInfo.
*/
mPuppetDisplayInfo[aDeviceID] = aDisplayInfo;
if (mPuppetHMDs.Length() > aDeviceID) {
/**
* In the event that the VRDisplayPuppet has already been
* created, we update it directly.
*/
mPuppetHMDs[aDeviceID]->SetDisplayInfo(aDisplayInfo);
}
}
void
VRSystemManagerPuppet::SetPuppetDisplaySensorState(const uint32_t& aDeviceID,
const VRHMDSensorState& aSensorState)
{
if (aDeviceID >= mPuppetDisplayCount) {
MOZ_ASSERT(false);
return;
}
/**
* Even if mPuppetHMDs.Length() <= aDeviceID, we need to
* update mPuppetDisplaySensorState[aDeviceID]. In the case that
* a puppet display is added and SetPuppetDisplaySensorState is
* immediately called, mPuppetHMDs may not be populated yet.
* VRSystemManagerPuppet::Enumerate() will initialize
* the VRDisplayPuppet later using mPuppetDisplaySensorState.
*/
mPuppetDisplaySensorState[aDeviceID] = aSensorState;
if (mPuppetHMDs.Length() > aDeviceID) {
/**
* In the event that the VRDisplayPuppet has already been
* created, we update it directly.
*/
mPuppetHMDs[aDeviceID]->SetSensorState(aSensorState);
}
return false;
}
void
VRSystemManagerPuppet::GetHMDs(nsTArray<RefPtr<VRDisplayHost>>& aHMDResult)
{
if (mPuppetHMD) {
aHMDResult.AppendElement(mPuppetHMD);
for (auto display: mPuppetHMDs) {
aHMDResult.AppendElement(display);
}
}
bool
VRSystemManagerPuppet::GetIsPresenting()
{
if (mPuppetHMD) {
VRDisplayInfo displayInfo(mPuppetHMD->GetDisplayInfo());
return displayInfo.GetPresentingGroups() != kVRGroupNone;
for (const auto& display: mPuppetHMDs) {
const VRDisplayInfo& displayInfo(display->GetDisplayInfo());
if (displayInfo.GetPresentingGroups() != kVRGroupNone) {
return true;
}
}
return false;
}
@ -851,28 +915,27 @@ VRSystemManagerPuppet::GetControllers(nsTArray<RefPtr<VRControllerHost>>& aContr
void
VRSystemManagerPuppet::ScanForControllers()
{
// mPuppetHMD is available after VRDisplay is created
// at GetHMDs().
if (!mPuppetHMD) {
return;
}
// We make VRSystemManagerPuppet has two controllers always.
const uint32_t newControllerCount = 2;
// We make sure VRSystemManagerPuppet has two controllers
// for each display
const uint32_t newControllerCount = mPuppetHMDs.Length() * 2;
if (newControllerCount != mControllerCount) {
RemoveControllers();
// Re-adding controllers to VRControllerManager.
for (uint32_t i = 0; i < newControllerCount; ++i) {
dom::GamepadHand hand = (i % 2) ? dom::GamepadHand::Right :
dom::GamepadHand::Left;
RefPtr<VRControllerPuppet> puppetController = new VRControllerPuppet(hand,
mPuppetHMD->GetDisplayInfo().GetDisplayID());
mPuppetController.AppendElement(puppetController);
for (const auto& display: mPuppetHMDs) {
uint32_t displayID = display->GetDisplayInfo().GetDisplayID();
for (uint32_t i = 0; i < 2; i++) {
dom::GamepadHand hand = (i % 2) ? dom::GamepadHand::Right :
dom::GamepadHand::Left;
RefPtr<VRControllerPuppet> puppetController;
puppetController = new VRControllerPuppet(hand, displayID);
mPuppetController.AppendElement(puppetController);
// Not already present, add it.
AddGamepad(puppetController->GetControllerInfo());
++mControllerCount;
// Not already present, add it.
AddGamepad(puppetController->GetControllerInfo());
++mControllerCount;
}
}
}
}

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

@ -9,6 +9,7 @@
#include "nsTArray.h"
#include "mozilla/RefPtr.h"
#include "nsRefPtrHashtable.h"
#include "gfxVR.h"
#include "VRDisplayHost.h"
@ -107,11 +108,16 @@ class VRSystemManagerPuppet : public VRSystemManager
{
public:
static already_AddRefed<VRSystemManagerPuppet> Create();
uint32_t CreateTestDisplay();
void ClearTestDisplays();
void SetPuppetDisplayInfo(const uint32_t& aDeviceID,
const VRDisplayInfo& aDisplayInfo);
void SetPuppetDisplaySensorState(const uint32_t& aDeviceID,
const VRHMDSensorState& aSensorState);
virtual void Destroy() override;
virtual void Shutdown() override;
virtual void Enumerate() override;
virtual bool ShouldInhibitEnumeration() override;
virtual void GetHMDs(nsTArray<RefPtr<VRDisplayHost>>& aHMDResult) override;
virtual bool GetIsPresenting() override;
virtual void HandleInput() override;
@ -142,9 +148,15 @@ private:
const dom::GamepadPoseState& aPose,
VRControllerHost* aController);
// there can only be one
RefPtr<impl::VRDisplayPuppet> mPuppetHMD;
// Enumerated puppet hardware devices, as seen by Web APIs:
nsTArray<RefPtr<impl::VRDisplayPuppet>> mPuppetHMDs;
nsTArray<RefPtr<impl::VRControllerPuppet>> mPuppetController;
// Emulated hardware state, persistent through VRSystemManager::Shutdown():
static const uint32_t kMaxPuppetDisplays = 5;
uint32_t mPuppetDisplayCount;
VRDisplayInfo mPuppetDisplayInfo[kMaxPuppetDisplays];
VRHMDSensorState mPuppetDisplaySensorState[kMaxPuppetDisplays];
};
} // namespace gfx

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

@ -405,7 +405,14 @@ VRManagerChild::RecvReplyCreateVRServiceTestController(const nsCString& aID,
MOZ_CRASH("We should always have a promise.");
}
p->MaybeResolve(new VRMockController(aID, aDeviceID));
if (aDeviceID == 0) {
// A value of 0 indicates that the controller could not
// be created. Most likely due to having no VR display
// to associate it with.
p->MaybeRejectWithUndefined();
} else {
p->MaybeResolve(new VRMockController(aID, aDeviceID));
}
mPromiseList.Remove(aPromiseID);
return IPC_OK();
}

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

@ -20,8 +20,7 @@ using namespace layers;
namespace gfx {
VRManagerParent::VRManagerParent(ProcessId aChildProcessId, bool aIsContentChild)
: mDisplayTestID(0)
, mControllerTestID(0)
: mControllerTestID(1)
, mHaveEventListener(false)
, mHaveControllerListener(false)
, mIsContentChild(aIsContentChild)
@ -247,9 +246,8 @@ VRManagerParent::RecvCreateVRTestSystem()
{
VRManager* vm = VRManager::Get();
vm->CreateVRTestSystem();
mDisplayTestID = 0;
mControllerTestID = 0;
mVRDisplayTests.Clear();
// The mControllerTestID is 1 based
mControllerTestID = 1;
mVRControllerTests.Clear();
return IPC_OK();
}
@ -257,29 +255,11 @@ VRManagerParent::RecvCreateVRTestSystem()
mozilla::ipc::IPCResult
VRManagerParent::RecvCreateVRServiceTestDisplay(const nsCString& aID, const uint32_t& aPromiseID)
{
nsTArray<VRDisplayInfo> displayInfoArray;
impl::VRDisplayPuppet* displayPuppet = nullptr;
VRManager* vm = VRManager::Get();
vm->RefreshVRDisplays();
VRSystemManagerPuppet* puppetManager = vm->GetPuppetManager();
uint32_t deviceID = puppetManager->CreateTestDisplay();
// Get VRDisplayPuppet from VRManager
vm->GetVRDisplayInfo(displayInfoArray);
for (auto& displayInfo : displayInfoArray) {
if (displayInfo.GetType() == VRDeviceType::Puppet) {
displayPuppet = static_cast<impl::VRDisplayPuppet*>(
vm->GetDisplay(displayInfo.GetDisplayID()).get());
break;
}
}
MOZ_ASSERT(displayPuppet);
MOZ_ASSERT(!mDisplayTestID); // We have only one display in VRSystemManagerPuppet.
if (!mVRDisplayTests.Get(mDisplayTestID, nullptr)) {
mVRDisplayTests.Put(mDisplayTestID, displayPuppet);
}
if (SendReplyCreateVRServiceTestDisplay(aID, aPromiseID, mDisplayTestID)) {
if (SendReplyCreateVRServiceTestDisplay(aID, aPromiseID, deviceID)) {
return IPC_OK();
}
@ -289,14 +269,20 @@ VRManagerParent::RecvCreateVRServiceTestDisplay(const nsCString& aID, const uint
mozilla::ipc::IPCResult
VRManagerParent::RecvCreateVRServiceTestController(const nsCString& aID, const uint32_t& aPromiseID)
{
uint32_t controllerIdx = 0;
uint32_t controllerIdx = 1; // ID's are 1 based
nsTArray<VRControllerInfo> controllerInfoArray;
impl::VRControllerPuppet* controllerPuppet = nullptr;
VRManager* vm = VRManager::Get();
if (mHaveControllerListener) {
vm->RefreshVRControllers();
}
/**
* When running headless mochitests on some of our automated test
* infrastructure, 2d display vsyncs are not always generated.
* In this case, the test controllers can't be created immediately
* after the VR display was created as the state of the VR displays
* are updated during vsync.
* To workaround, we produce a vsync manually.
*/
vm->NotifyVsync(TimeStamp::Now());
// Get VRControllerPuppet from VRManager
vm->GetVRControllerInfo(controllerInfoArray);
@ -311,16 +297,22 @@ VRManagerParent::RecvCreateVRServiceTestController(const nsCString& aID, const u
}
}
MOZ_ASSERT(controllerPuppet);
MOZ_ASSERT(mControllerTestID < 2); // We have only two controllers in VRSystemManagerPuppet.
// We might not have a controllerPuppet if the test did
// not create a VR display first.
if (!controllerPuppet) {
// We send a device ID of "0" to indicate failure
if (SendReplyCreateVRServiceTestController(aID, aPromiseID, 0)) {
return IPC_OK();
}
} else {
if (!mVRControllerTests.Get(mControllerTestID, nullptr)) {
mVRControllerTests.Put(mControllerTestID, controllerPuppet);
}
if (!mVRControllerTests.Get(mControllerTestID, nullptr)) {
mVRControllerTests.Put(mControllerTestID, controllerPuppet);
}
if (SendReplyCreateVRServiceTestController(aID, aPromiseID, mControllerTestID)) {
++mControllerTestID;
return IPC_OK();
if (SendReplyCreateVRServiceTestController(aID, aPromiseID, mControllerTestID)) {
++mControllerTestID;
return IPC_OK();
}
}
return IPC_FAIL(this, "SendReplyCreateVRServiceTestController fail");
@ -330,11 +322,9 @@ mozilla::ipc::IPCResult
VRManagerParent::RecvSetDisplayInfoToMockDisplay(const uint32_t& aDeviceID,
const VRDisplayInfo& aDisplayInfo)
{
RefPtr<impl::VRDisplayPuppet> displayPuppet;
mVRDisplayTests.Get(aDeviceID,
getter_AddRefs(displayPuppet));
MOZ_ASSERT(displayPuppet);
displayPuppet->SetDisplayInfo(aDisplayInfo);
VRManager* vm = VRManager::Get();
VRSystemManagerPuppet* puppetManager = vm->GetPuppetManager();
puppetManager->SetPuppetDisplayInfo(aDeviceID, aDisplayInfo);
return IPC_OK();
}
@ -342,23 +332,33 @@ mozilla::ipc::IPCResult
VRManagerParent::RecvSetSensorStateToMockDisplay(const uint32_t& aDeviceID,
const VRHMDSensorState& aSensorState)
{
RefPtr<impl::VRDisplayPuppet> displayPuppet;
mVRDisplayTests.Get(aDeviceID,
getter_AddRefs(displayPuppet));
MOZ_ASSERT(displayPuppet);
displayPuppet->SetSensorState(aSensorState);
VRManager* vm = VRManager::Get();
VRSystemManagerPuppet* puppetManager = vm->GetPuppetManager();
puppetManager->SetPuppetDisplaySensorState(aDeviceID, aSensorState);
return IPC_OK();
}
already_AddRefed<impl::VRControllerPuppet>
VRManagerParent::GetControllerPuppet(uint32_t aDeviceID)
{
// aDeviceID for controllers start at 1 and are
// used as a key to mVRControllerTests
MOZ_ASSERT(aDeviceID > 0);
RefPtr<impl::VRControllerPuppet> controllerPuppet;
mVRControllerTests.Get(aDeviceID,
getter_AddRefs(controllerPuppet));
MOZ_ASSERT(controllerPuppet);
return controllerPuppet.forget();
}
mozilla::ipc::IPCResult
VRManagerParent::RecvNewButtonEventToMockController(const uint32_t& aDeviceID, const long& aButton,
const bool& aPressed)
{
RefPtr<impl::VRControllerPuppet> controllerPuppet;
mVRControllerTests.Get(aDeviceID,
getter_AddRefs(controllerPuppet));
MOZ_ASSERT(controllerPuppet);
controllerPuppet->SetButtonPressState(aButton, aPressed);
RefPtr<impl::VRControllerPuppet> controllerPuppet = GetControllerPuppet(aDeviceID);
if (controllerPuppet) {
controllerPuppet->SetButtonPressState(aButton, aPressed);
}
return IPC_OK();
}
@ -366,11 +366,10 @@ mozilla::ipc::IPCResult
VRManagerParent::RecvNewAxisMoveEventToMockController(const uint32_t& aDeviceID, const long& aAxis,
const double& aValue)
{
RefPtr<impl::VRControllerPuppet> controllerPuppet;
mVRControllerTests.Get(aDeviceID,
getter_AddRefs(controllerPuppet));
MOZ_ASSERT(controllerPuppet);
controllerPuppet->SetAxisMoveState(aAxis, aValue);
RefPtr<impl::VRControllerPuppet> controllerPuppet = GetControllerPuppet(aDeviceID);
if (controllerPuppet) {
controllerPuppet->SetAxisMoveState(aAxis, aValue);
}
return IPC_OK();
}
@ -378,11 +377,10 @@ mozilla::ipc::IPCResult
VRManagerParent::RecvNewPoseMoveToMockController(const uint32_t& aDeviceID,
const GamepadPoseState& pose)
{
RefPtr<impl::VRControllerPuppet> controllerPuppet;
mVRControllerTests.Get(aDeviceID,
getter_AddRefs(controllerPuppet));
MOZ_ASSERT(controllerPuppet);
controllerPuppet->SetPoseMoveState(pose);
RefPtr<impl::VRControllerPuppet> controllerPuppet = GetControllerPuppet(aDeviceID);
if (controllerPuppet) {
controllerPuppet->SetPoseMoveState(pose);
}
return IPC_OK();
}

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

@ -83,6 +83,7 @@ private:
static void RegisterVRManagerInVRListenerThread(VRManagerParent* aVRManager);
void DeferredDestroy();
already_AddRefed<impl::VRControllerPuppet> GetControllerPuppet(uint32_t aDeviceID);
// This keeps us alive until ActorDestroy(), at which point we do a
// deferred destruction of ourselves.
@ -91,9 +92,7 @@ private:
// Keep the VRManager alive, until we have destroyed ourselves.
RefPtr<VRManager> mVRManagerHolder;
nsRefPtrHashtable<nsUint32HashKey, impl::VRDisplayPuppet> mVRDisplayTests;
nsRefPtrHashtable<nsUint32HashKey, impl::VRControllerPuppet> mVRControllerTests;
uint32_t mDisplayTestID;
uint32_t mControllerTestID;
bool mHaveEventListener;
bool mHaveControllerListener;