Bug 1309988 - Change InputFrameID to unsigned r=kearwood
☠☠ backed out by d3de60b2f630 ☠ ☠
authorGeorge Wright <george@mozilla.com>
Wed, 19 Oct 2016 15:27:20 -0400
changeset 427717 c1559b3712f202267981d82a70fb25299e776e84
parent 427716 fbd443ce8fb5b8a1897baac3bfe62f8c5c5b054f
child 427718 e02e34d291ca4f16caf687bd14d5fbc5081453f0
child 427731 ac181fd282b9307f6a1f4c58bb4f8b57c3d36745
push id33099
push userdholbert@mozilla.com
push dateThu, 20 Oct 2016 20:25:54 +0000
reviewerskearwood
bugs1309988
milestone52.0a1
Bug 1309988 - Change InputFrameID to unsigned r=kearwood
gfx/vr/VRDisplayHost.cpp
gfx/vr/VRDisplayHost.h
gfx/vr/gfxVR.h
gfx/vr/ipc/VRManagerChild.cpp
gfx/vr/ipc/VRManagerChild.h
--- a/gfx/vr/VRDisplayHost.cpp
+++ b/gfx/vr/VRDisplayHost.cpp
@@ -63,35 +63,30 @@ VRDisplayHost::RemoveLayer(VRLayerParent
   // Ensure that the content process receives the change immediately
   VRManager* vm = VRManager::Get();
   vm->RefreshVRDisplays();
 }
 
 #if defined(XP_WIN)
 
 void
-VRDisplayHost::SubmitFrame(VRLayerParent* aLayer, const int32_t& aInputFrameID,
+VRDisplayHost::SubmitFrame(VRLayerParent* aLayer, const uint32_t& aInputFrameID,
   PTextureParent* aTexture, const gfx::Rect& aLeftEyeRect,
   const gfx::Rect& aRightEyeRect)
 {
   // aInputFrameID is no longer controlled by content with the WebVR 1.1 API
   // update; however, we will later use this code to enable asynchronous
   // submission of multiple layers to be composited.  This will enable
   // us to build browser UX that remains responsive even when content does
   // not consistently submit frames.
 
-  int32_t inputFrameID = aInputFrameID;
+  uint32_t inputFrameID = aInputFrameID;
   if (inputFrameID == 0) {
     inputFrameID = mInputFrameID;
   }
-  if (inputFrameID < 0) {
-    // Sanity check to prevent invalid memory access on builds with assertions
-    // disabled.
-    inputFrameID = 0;
-  }
 
   VRHMDSensorState sensorState = mLastSensorState[inputFrameID % kMaxLatencyFrames];
   // It is possible to get a cache miss on mLastSensorState if latency is
   // longer than kMaxLatencyFrames.  An optimization would be to find a frame
   // that is closer than the one selected with the modulus.
   // If we hit this; however, latency is already so high that the site is
   // un-viewable and a more accurate pose prediction is not likely to
   // compensate.
@@ -121,17 +116,17 @@ VRDisplayHost::SubmitFrame(VRLayerParent
   }
 
   SubmitFrame(sourceD3D11, texSize, sensorState, aLeftEyeRect, aRightEyeRect);
 }
 
 #else
 
 void
-VRDisplayHost::SubmitFrame(VRLayerParent* aLayer, const int32_t& aInputFrameID,
+VRDisplayHost::SubmitFrame(VRLayerParent* aLayer, const uint32_t& aInputFrameID,
   PTextureParent* aTexture, const gfx::Rect& aLeftEyeRect,
   const gfx::Rect& aRightEyeRect)
 {
   NS_WARNING("WebVR only supported in Windows.");
 }
 
 #endif
 
@@ -150,9 +145,9 @@ VRControllerHost::VRControllerHost(VRDev
   MOZ_COUNT_CTOR(VRControllerHost);
   mControllerInfo.mType = aType;
   mControllerInfo.mControllerID = VRDisplayManager::AllocateDisplayID();
 }
 
 VRControllerHost::~VRControllerHost()
 {
   MOZ_COUNT_DTOR(VRControllerHost);
-}
\ No newline at end of file
+}
--- a/gfx/vr/VRDisplayHost.h
+++ b/gfx/vr/VRDisplayHost.h
@@ -39,17 +39,17 @@ public:
   virtual VRHMDSensorState GetSensorState() = 0;
   virtual VRHMDSensorState GetImmediateSensorState() = 0;
   virtual void ZeroSensor() = 0;
   virtual void StartPresentation() = 0;
   virtual void StopPresentation() = 0;
   virtual void NotifyVSync() { };
 
   void SubmitFrame(VRLayerParent* aLayer,
-                   const int32_t& aInputFrameID,
+                   const uint32_t& aInputFrameID,
                    mozilla::layers::PTextureParent* aTexture,
                    const gfx::Rect& aLeftEyeRect,
                    const gfx::Rect& aRightEyeRect);
 
   bool CheckClearDisplayInfoDirty();
 
 protected:
   explicit VRDisplayHost(VRDeviceType aType);
@@ -72,17 +72,17 @@ protected:
   // should give up applying pose prediction.
   // If latency is greater than one second, then the experience is not likely
   // to be corrected by pose prediction.  Setting this value too
   // high may result in unnecessary memory allocation.
   // As the current fastest refresh rate is 90hz, 100 is selected as a
   // conservative value.
   static const int kMaxLatencyFrames = 100;
   VRHMDSensorState mLastSensorState[kMaxLatencyFrames];
-  int32_t mInputFrameID;
+  uint32_t mInputFrameID;
 
 private:
   VRDisplayInfo mLastUpdateDisplayInfo;
 };
 
 class VRControllerHost {
 public:
   NS_INLINE_DECL_THREADSAFE_REFCOUNTING(VRControllerHost)
--- a/gfx/vr/gfxVR.h
+++ b/gfx/vr/gfxVR.h
@@ -173,17 +173,17 @@ struct VRDisplayInfo
 
   bool operator!=(const VRDisplayInfo& other) const {
     return !(*this == other);
   }
 };
 
 struct VRHMDSensorState {
   double timestamp;
-  int32_t inputFrameID;
+  uint32_t inputFrameID;
   VRDisplayCapabilityFlags flags;
   float orientation[4];
   float position[3];
   float angularVelocity[3];
   float angularAcceleration[3];
   float linearVelocity[3];
   float linearAcceleration[3];
 
--- a/gfx/vr/ipc/VRManagerChild.cpp
+++ b/gfx/vr/ipc/VRManagerChild.cpp
@@ -35,17 +35,17 @@ static StaticRefPtr<VRManagerParent> sVR
 void ReleaseVRManagerParentSingleton() {
   sVRManagerParentSingleton = nullptr;
 }
 
 VRManagerChild::VRManagerChild()
   : TextureForwarder()
   , mDisplaysInitialized(false)
   , mGamepadManager(nullptr)
-  , mInputFrameID(-1)
+  , mInputFrameID(0)
   , mMessageLoop(MessageLoop::current())
   , mFrameRequestCallbackCounter(0)
   , mBackend(layers::LayersBackend::LAYERS_NONE)
 {
   MOZ_COUNT_CTOR(VRManagerChild);
   MOZ_ASSERT(NS_IsMainThread());
 
   mStartTimeStamp = TimeStamp::Now();
@@ -301,17 +301,17 @@ VRManagerChild::RefreshVRDisplaysWithCal
 {
   bool success = SendRefreshDisplays();
   if (success) {
     mNavigatorCallbacks.AppendElement(aNavigator);
   }
   return success;
 }
 
-int
+uint32_t
 VRManagerChild::GetInputFrameID()
 {
   return mInputFrameID;
 }
 
 bool
 VRManagerChild::RecvParentAsyncMessages(InfallibleTArray<AsyncParentMessageData>&& aMessages)
 {
--- a/gfx/vr/ipc/VRManagerChild.h
+++ b/gfx/vr/ipc/VRManagerChild.h
@@ -42,17 +42,17 @@ public:
 
   static VRManagerChild* Get();
 
   // Indicate that an observer wants to receive VR events.
   void AddListener(dom::VREventObserver* aObserver);
   // Indicate that an observer should no longer receive VR events.
   void RemoveListener(dom::VREventObserver* aObserver);
 
-  int GetInputFrameID();
+  uint32_t GetInputFrameID();
   bool GetVRDisplays(nsTArray<RefPtr<VRDisplayClient> >& aDisplays);
   bool RefreshVRDisplaysWithCallback(dom::Navigator* aNavigator);
 
   static void InitSameProcess();
   static void InitWithGPUProcess(Endpoint<PVRManagerChild>&& aEndpoint);
   static bool InitForContent(Endpoint<PVRManagerChild>&& aEndpoint);
   static bool ReinitForContent(Endpoint<PVRManagerChild>&& aEndpoint);
   static void ShutDown();
@@ -152,17 +152,17 @@ private:
   */
   void NotifyNotUsed(uint64_t aTextureId, uint64_t aFwdTransactionId);
 
   nsTArray<RefPtr<VRDisplayClient> > mDisplays;
   bool mDisplaysInitialized;
   nsTArray<dom::Navigator*> mNavigatorCallbacks;
   dom::GamepadManager* mGamepadManager;
 
-  int32_t mInputFrameID;
+  uint32_t mInputFrameID;
 
   MessageLoop* mMessageLoop;
 
   struct FrameRequest;
 
   nsTArray<FrameRequest> mFrameRequestCallbacks;
   /**
   * The current frame request callback handle