Bug 1411630 - make mozilla::gfx::VRHMDSensorState to be trivial typed. r?kip draft
authorAndi-Bogdan Postelnicu <bpostelnicu@mozilla.com>
Mon, 30 Oct 2017 14:51:32 +0200
changeset 688655 4efa7a6835e7e94f5cf7eb86c826c1a37cfdf5f6
parent 688650 515407ebfa1433c31144374313bbfd8b942af41c
child 738132 3cc57c0e6d22d82efa2136bdf2e20fa35b2948f8
push id86816
push userbmo:bpostelnicu@mozilla.com
push dateMon, 30 Oct 2017 12:58:39 +0000
reviewerskip
bugs1411630
milestone58.0a1
Bug 1411630 - make mozilla::gfx::VRHMDSensorState to be trivial typed. r?kip MozReview-Commit-ID: 7BniyasLIQD
dom/vr/VRServiceTest.cpp
gfx/vr/VRDisplayHost.cpp
gfx/vr/gfxVR.h
gfx/vr/gfxVROSVR.cpp
gfx/vr/gfxVROculus.cpp
gfx/vr/gfxVROpenVR.cpp
gfx/vr/gfxVRPuppet.cpp
--- a/dom/vr/VRServiceTest.cpp
+++ b/dom/vr/VRServiceTest.cpp
@@ -23,16 +23,18 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_END
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(VRMockDisplay)
 NS_INTERFACE_MAP_END_INHERITING(DOMEventTargetHelper)
 
 NS_IMPL_ADDREF_INHERITED(VRMockDisplay, DOMEventTargetHelper)
 NS_IMPL_RELEASE_INHERITED(VRMockDisplay, DOMEventTargetHelper)
 
 VRMockDisplay::VRMockDisplay(const nsCString& aID, uint32_t aDeviceID)
  : mDeviceID(aDeviceID)
+ , mDisplayInfo{}
+ , mSensorState{}
  , mTimestamp(TimeStamp::Now())
 {
   mDisplayInfo.mDisplayName = aID;
   mDisplayInfo.mType = VRDeviceType::Puppet;
   mDisplayInfo.mIsConnected = true;
   mDisplayInfo.mIsMounted = false;
   mDisplayInfo.mCapabilityFlags = VRDisplayCapabilityFlags::Cap_None |
                                   VRDisplayCapabilityFlags::Cap_Orientation |
--- a/gfx/vr/VRDisplayHost.cpp
+++ b/gfx/vr/VRDisplayHost.cpp
@@ -57,17 +57,19 @@ VRDisplayHost::AutoRestoreRenderState::~
 
 bool
 VRDisplayHost::AutoRestoreRenderState::IsSuccess()
 {
   return mSuccess;
 }
 
 VRDisplayHost::VRDisplayHost(VRDeviceType aType)
- : mFrameStarted(false)
+ : mDisplayInfo{}
+ , mLastUpdateDisplayInfo{}
+ , mFrameStarted(false)
 {
   MOZ_COUNT_CTOR(VRDisplayHost);
   mDisplayInfo.mType = aType;
   mDisplayInfo.mDisplayID = VRSystemManager::AllocateDisplayID();
   mDisplayInfo.mPresentingGroups = 0;
   mDisplayInfo.mGroupMask = kVRGroupContent;
   mDisplayInfo.mFrameId = 0;
 }
--- a/gfx/vr/gfxVR.h
+++ b/gfx/vr/gfxVR.h
@@ -128,20 +128,16 @@ struct VRFieldOfView {
 
   double upDegrees;
   double rightDegrees;
   double downDegrees;
   double leftDegrees;
 };
 
 struct VRHMDSensorState {
-  VRHMDSensorState()
-  {
-    Clear();
-  }
   int64_t inputFrameID;
   double timestamp;
   VRDisplayCapabilityFlags flags;
 
   // These members will only change with inputFrameID:
   float orientation[4];
   float position[3];
   float angularVelocity[3];
--- a/gfx/vr/gfxVROSVR.cpp
+++ b/gfx/vr/gfxVROSVR.cpp
@@ -282,17 +282,17 @@ VRDisplayOSVR::ZeroSensor()
 VRHMDSensorState
 VRDisplayOSVR::GetSensorState()
 {
 
   //update client context before anything
   //this usually goes into app's mainloop
   osvr_ClientUpdate(*m_ctx);
 
-  VRHMDSensorState result;
+  VRHMDSensorState result{};
   OSVR_TimeValue timestamp;
 
   OSVR_OrientationState orientation;
 
   OSVR_ReturnCode ret =
     osvr_GetOrientationState(*m_iface, &timestamp, &orientation);
 
   result.timestamp = timestamp.seconds;
--- a/gfx/vr/gfxVROculus.cpp
+++ b/gfx/vr/gfxVROculus.cpp
@@ -858,17 +858,17 @@ VRDisplayOculus::ZeroSensor()
   }
   ovr_RecenterTrackingOrigin(mSession->Get());
   UpdateStageParameters();
 }
 
 VRHMDSensorState
 VRDisplayOculus::GetSensorState()
 {
-  VRHMDSensorState result;
+  VRHMDSensorState result{};
   if (mSession->IsTrackingReady()) {
     double predictedFrameTime = 0.0f;
     if (gfxPrefs::VRPosePredictionEnabled()) {
       // XXX We might need to call ovr_GetPredictedDisplayTime even if we don't use the result.
       // If we don't call it, the Oculus driver will spew out many warnings...
       predictedFrameTime = ovr_GetPredictedDisplayTime(mSession->Get(), 0);
     }
     result = GetSensorState(predictedFrameTime);
@@ -877,31 +877,31 @@ VRDisplayOculus::GetSensorState()
   result.position[1] -= mEyeHeight;
   mDisplayInfo.mLastSensorState[result.inputFrameID % kVRMaxLatencyFrames] = result;
   return result;
 }
 
 VRHMDSensorState
 VRDisplayOculus::GetSensorState(double absTime)
 {
-  VRHMDSensorState result;
+  VRHMDSensorState result{};
 
   ovrTrackingState state = ovr_GetTrackingState(mSession->Get(), absTime, true);
   ovrPoseStatef& pose(state.HeadPose);
 
   result.timestamp = pose.TimeInSeconds;
 
   if (state.StatusFlags & ovrStatus_OrientationTracked) {
     result.flags |= VRDisplayCapabilityFlags::Cap_Orientation;
 
     result.orientation[0] = pose.ThePose.Orientation.x;
     result.orientation[1] = pose.ThePose.Orientation.y;
     result.orientation[2] = pose.ThePose.Orientation.z;
     result.orientation[3] = pose.ThePose.Orientation.w;
-    
+
     result.angularVelocity[0] = pose.AngularVelocity.x;
     result.angularVelocity[1] = pose.AngularVelocity.y;
     result.angularVelocity[2] = pose.AngularVelocity.z;
 
     result.flags |= VRDisplayCapabilityFlags::Cap_AngularAcceleration;
 
     result.angularAcceleration[0] = pose.AngularAcceleration.x;
     result.angularAcceleration[1] = pose.AngularAcceleration.y;
@@ -909,17 +909,17 @@ VRDisplayOculus::GetSensorState(double a
   }
 
   if (state.StatusFlags & ovrStatus_PositionTracked) {
     result.flags |= VRDisplayCapabilityFlags::Cap_Position;
 
     result.position[0] = pose.ThePose.Position.x;
     result.position[1] = pose.ThePose.Position.y;
     result.position[2] = pose.ThePose.Position.z;
-    
+
     result.linearVelocity[0] = pose.LinearVelocity.x;
     result.linearVelocity[1] = pose.LinearVelocity.y;
     result.linearVelocity[2] = pose.LinearVelocity.z;
 
     result.flags |= VRDisplayCapabilityFlags::Cap_LinearAcceleration;
 
     result.linearAcceleration[0] = pose.LinearAcceleration.x;
     result.linearAcceleration[1] = pose.LinearAcceleration.y;
--- a/gfx/vr/gfxVROpenVR.cpp
+++ b/gfx/vr/gfxVROpenVR.cpp
@@ -226,17 +226,17 @@ VRDisplayOpenVR::GetSensorState()
 {
   PollEvents();
 
   const uint32_t posesSize = ::vr::k_unTrackedDeviceIndex_Hmd + 1;
   ::vr::TrackedDevicePose_t poses[posesSize];
   // Note: We *must* call WaitGetPoses in order for any rendering to happen at all.
   mVRCompositor->WaitGetPoses(nullptr, 0, poses, posesSize);
 
-  VRHMDSensorState result;
+  VRHMDSensorState result{};
 
   ::vr::Compositor_FrameTiming timing;
   timing.m_nSize = sizeof(::vr::Compositor_FrameTiming);
   if (mVRCompositor->GetFrameTiming(&timing)) {
     result.timestamp = timing.m_flSystemTimeInSeconds;
   } else {
     // This should not happen, but log it just in case
     NS_WARNING("OpenVR - IVRCompositor::GetFrameTiming failed");
--- a/gfx/vr/gfxVRPuppet.cpp
+++ b/gfx/vr/gfxVRPuppet.cpp
@@ -46,16 +46,17 @@ static const uint64_t kPuppetButtonMask[
 static const uint32_t kNumPuppetButtonMask = sizeof(kPuppetButtonMask) /
                                              sizeof(uint64_t);
 static const uint32_t kNumPuppetAxis = 3;
 static const uint32_t kNumPuppetHaptcs = 1;
 
 VRDisplayPuppet::VRDisplayPuppet()
  : VRDisplayHost(VRDeviceType::Puppet)
  , mIsPresenting(false)
+ , mSensorState{}
 {
   MOZ_COUNT_CTOR_INHERITED(VRDisplayPuppet, VRDisplayHost);
 
   mDisplayInfo.mDisplayName.AssignLiteral("Puppet HMD");
   mDisplayInfo.mIsConnected = true;
   mDisplayInfo.mIsMounted = false;
   mDisplayInfo.mCapabilityFlags = VRDisplayCapabilityFlags::Cap_None |
                                   VRDisplayCapabilityFlags::Cap_Orientation |