Bug 1311802 - Part1 - Add SetMountState interface for VRMockDisplay; r?daoshengmu, baku draft
authorChih-Yi Leu <cleu@mozilla.com>
Mon, 27 Mar 2017 11:26:19 +0800
changeset 560127 2cb5bc0838961905c4aebf8dfce98dced46a96b3
parent 560035 b5b5dbed1c409d96aa6b97f2036cd66312fc45ad
child 560128 235a649ff17c0b6de735208794b9eee2cfe28ace
push id53332
push userbmo:cleu@mozilla.com
push dateTue, 11 Apr 2017 06:00:13 +0000
reviewersdaoshengmu, baku
bugs1311802
milestone55.0a1
Bug 1311802 - Part1 - Add SetMountState interface for VRMockDisplay; r?daoshengmu, baku MozReview-Commit-ID: 7MFHIri2Bq7
dom/vr/VRServiceTest.h
dom/vr/test/VRSimulationDriver.js
dom/webidl/VRServiceTest.webidl
gfx/vr/gfxVRPuppet.cpp
--- a/dom/vr/VRServiceTest.h
+++ b/dom/vr/VRServiceTest.h
@@ -22,16 +22,17 @@ public:
   VRMockDisplay(const nsCString& aID, uint32_t aDeviceID);
   void SetEyeParameter(VREye aEye, double aOffsetX, double aOffsetY, double aOffsetZ,
                        double aUpDegree, double aRightDegree,
                        double aDownDegree, double aLeftDegree);
   void SetEyeResolution(unsigned long aRenderWidth, unsigned long aRenderHeight);
   void 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);
+  void SetMountState(bool aIsMounted) { mDisplayInfo.mIsMounted = aIsMounted; }
   void Update();
   virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
 
 private:
   ~VRMockDisplay() = default;
 
   uint32_t mDeviceID;
   gfx::VRDisplayInfo mDisplayInfo;
@@ -79,9 +80,9 @@ private:
 
   nsCOMPtr<nsPIDOMWindowInner> mWindow;
   bool mShuttingDown;
 };
 
 } // namespace dom
 } // namespace mozilla
 
-#endif // mozilla_dom_VRServiceTest_h_
\ No newline at end of file
+#endif // mozilla_dom_VRServiceTest_h_
--- a/dom/vr/test/VRSimulationDriver.js
+++ b/dom/vr/test/VRSimulationDriver.js
@@ -28,25 +28,30 @@ var SetEyeResolution = function(width, h
 }
 
 var SetEyeParameter = function(eye, offsetX, offsetY, offsetZ,
                                upDegree, rightDegree, downDegree, leftDegree) {
   vrMockDisplay.setEyeParameter(eye, offsetX, offsetY, offsetZ, upDegree, rightDegree,
                                 downDegree, leftDegree);
 }
 
+var SetMountState = function(isMounted) {
+  vrMockDisplay.setMountState(isMounted);
+}
+
 var UpdateVRDisplay = function() {
   vrMockDisplay.update();
 }
 
 var API = {
   AttachWebVRDisplay: AttachWebVRDisplay,
   SetVRDisplayPose: SetVRDisplayPose,
   SetEyeResolution: SetEyeResolution,
   SetEyeParameter: SetEyeParameter,
+  SetMountState: SetMountState,
   UpdateVRDisplay: UpdateVRDisplay,
 
   none: false
 };
 
 return API;
 
 }());
\ No newline at end of file
--- a/dom/webidl/VRServiceTest.webidl
+++ b/dom/webidl/VRServiceTest.webidl
@@ -10,16 +10,17 @@
 interface VRMockDisplay {
   void setEyeResolution(unsigned long aRenderWidth, unsigned long aRenderHeight);
   void setEyeParameter(VREye eye, double offsetX, double offsetY, double offsetZ,
                        double upDegree, double rightDegree,
                        double downDegree, double leftDegree);
   void setPose(Float32Array? position, Float32Array? linearVelocity,
                Float32Array? linearAcceleration, Float32Array? orientation,
                Float32Array? angularVelocity, Float32Array? angularAcceleration);
+  void setMountState(boolean isMounted);
   void update();
 };
 
 [Pref="dom.vr.test.enabled",
  HeaderFile="mozilla/dom/VRServiceTest.h"]
 interface VRMockController {
   void newButtonEvent(unsigned long button, boolean pressed);
   void newAxisMoveEvent(unsigned long axis, double value);
--- a/gfx/vr/gfxVRPuppet.cpp
+++ b/gfx/vr/gfxVRPuppet.cpp
@@ -115,18 +115,19 @@ VRDisplayPuppet::VRDisplayPuppet()
 VRDisplayPuppet::~VRDisplayPuppet()
 {
   MOZ_COUNT_DTOR_INHERITED(VRDisplayPuppet, VRDisplayHost);
 }
 
 void
 VRDisplayPuppet::SetDisplayInfo(const VRDisplayInfo& aDisplayInfo)
 {
-  // We are only interested in the eye info of the display info.
+  // We are only interested in the eye and mount info of the display info.
   mDisplayInfo.mEyeResolution = aDisplayInfo.mEyeResolution;
+  mDisplayInfo.mIsMounted = aDisplayInfo.mIsMounted;
   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()