Bug 1306493 - Part 1: Fix bug of getting frame data from VRPuppet; r?kip
MozReview-Commit-ID: L8gPVjxELtV
--- a/dom/vr/VRServiceTest.cpp
+++ b/dom/vr/VRServiceTest.cpp
@@ -72,16 +72,18 @@ VRMockDisplay::SetEyeParameter(VREye aEy
void
VRMockDisplay::SetPose(const Nullable<Float32Array>& aPosition,
const Nullable<Float32Array>& aLinearVelocity,
const Nullable<Float32Array>& aLinearAcceleration,
const Nullable<Float32Array>& aOrientation,
const Nullable<Float32Array>& aAngularVelocity,
const Nullable<Float32Array>& aAngularAcceleration)
{
+ mSensorState.Clear();
+ mSensorState.timestamp = PR_Now();
mSensorState.flags = VRDisplayCapabilityFlags::Cap_Orientation |
VRDisplayCapabilityFlags::Cap_Position |
VRDisplayCapabilityFlags::Cap_AngularAcceleration |
VRDisplayCapabilityFlags::Cap_LinearAcceleration |
VRDisplayCapabilityFlags::Cap_External |
VRDisplayCapabilityFlags::Cap_MountDetection |
VRDisplayCapabilityFlags::Cap_Present;
--- a/gfx/vr/gfxVRPuppet.cpp
+++ b/gfx/vr/gfxVRPuppet.cpp
@@ -114,17 +114,22 @@ VRDisplayPuppet::VRDisplayPuppet()
VRDisplayPuppet::~VRDisplayPuppet()
{
MOZ_COUNT_DTOR_INHERITED(VRDisplayPuppet, VRDisplayHost);
}
void
VRDisplayPuppet::SetDisplayInfo(const VRDisplayInfo& aDisplayInfo)
{
- mDisplayInfo = aDisplayInfo;
+ // We are only interested in the eye info of the display info.
+ mDisplayInfo.mEyeResolution = aDisplayInfo.mEyeResolution;
+ memcpy(&mDisplayInfo.mEyeFOV, &aDisplayInfo.mEyeFOV,
+ sizeof(mDisplayInfo.mEyeFOV[0]) * VRDisplayInfo::NumEyes);
+ memcpy(&mDisplayInfo.mEyeTranslation, &aDisplayInfo.mEyeTranslation,
+ sizeof(mDisplayInfo.mEyeTranslation[0]) * VRDisplayInfo::NumEyes);
}
void
VRDisplayPuppet::Destroy()
{
StopPresentation();
}
@@ -143,17 +148,17 @@ VRHMDSensorState
VRDisplayPuppet::GetSensorState(double timeOffset)
{
return mSensorState;
}
void
VRDisplayPuppet::SetSensorState(const VRHMDSensorState& aSensorState)
{
- mSensorState = aSensorState;
+ memcpy(&mSensorState, &aSensorState, sizeof(mSensorState));
}
void
VRDisplayPuppet::StartPresentation()
{
if (mIsPresenting) {
return;
}
--- a/gfx/vr/ipc/VRManagerParent.cpp
+++ b/gfx/vr/ipc/VRManagerParent.cpp
@@ -386,62 +386,67 @@ VRManagerParent::RecvCreateVRServiceTest
return IPC_FAIL(this, "SendReplyCreateVRServiceTestController fail");
}
mozilla::ipc::IPCResult
VRManagerParent::RecvSetDisplayInfoToMockDisplay(const uint32_t& aDeviceID,
const VRDisplayInfo& aDisplayInfo)
{
RefPtr<impl::VRDisplayPuppet> displayPuppet;
- MOZ_ASSERT(mVRDisplayTests.Get(mDisplayTestID,
- getter_AddRefs(displayPuppet)));
+ mVRDisplayTests.Get(mDisplayTestID,
+ getter_AddRefs(displayPuppet));
+ MOZ_ASSERT(displayPuppet);
displayPuppet->SetDisplayInfo(aDisplayInfo);
return IPC_OK();
}
mozilla::ipc::IPCResult
VRManagerParent::RecvSetSensorStateToMockDisplay(const uint32_t& aDeviceID,
const VRHMDSensorState& aSensorState)
{
RefPtr<impl::VRDisplayPuppet> displayPuppet;
- MOZ_ASSERT(mVRDisplayTests.Get(mControllerTestID,
- getter_AddRefs(displayPuppet)));
+ mVRDisplayTests.Get(mDisplayTestID,
+ getter_AddRefs(displayPuppet));
+ MOZ_ASSERT(displayPuppet);
displayPuppet->SetSensorState(aSensorState);
return IPC_OK();
}
mozilla::ipc::IPCResult
VRManagerParent::RecvNewButtonEventToMockController(const uint32_t& aDeviceID, const long& aButton,
const bool& aPressed)
{
RefPtr<impl::VRControllerPuppet> controllerPuppet;
- MOZ_ASSERT(mVRControllerTests.Get(mControllerTestID,
- getter_AddRefs(controllerPuppet)));
+ mVRControllerTests.Get(mControllerTestID,
+ getter_AddRefs(controllerPuppet));
+ MOZ_ASSERT(controllerPuppet);
controllerPuppet->SetButtonPressState(aButton, aPressed);
return IPC_OK();
}
mozilla::ipc::IPCResult
VRManagerParent::RecvNewAxisMoveEventToMockController(const uint32_t& aDeviceID, const long& aAxis,
const double& aValue)
{
RefPtr<impl::VRControllerPuppet> controllerPuppet;
- MOZ_ASSERT(mVRControllerTests.Get(mControllerTestID,
- getter_AddRefs(controllerPuppet)));
+ mVRControllerTests.Get(mControllerTestID,
+ getter_AddRefs(controllerPuppet));
+ MOZ_ASSERT(controllerPuppet);
controllerPuppet->SetAxisMoveState(aAxis, aValue);
return IPC_OK();
}
mozilla::ipc::IPCResult
VRManagerParent::RecvNewPoseMoveToMockController(const uint32_t& aDeviceID,
const GamepadPoseState& pose)
{
RefPtr<impl::VRControllerPuppet> controllerPuppet;
- MOZ_ASSERT(mVRControllerTests.Get(mControllerTestID,
- getter_AddRefs(controllerPuppet)));
+ mVRControllerTests.Get(mControllerTestID,
+ getter_AddRefs(controllerPuppet));
+ MOZ_ASSERT(controllerPuppet);
controllerPuppet->SetPoseMoveState(pose);
return IPC_OK();
}
bool
VRManagerParent::SendGamepadUpdate(const GamepadChangeEvent& aGamepadEvent)
{
// GamepadManager only exists at the content process