[WebVR][OpenVR] Retrieve displayId and the z-depth of eye view frustum
authorsvillar@igalia.com <svillar@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 26 Feb 2018 13:37:55 +0000 (13:37 +0000)
committersvillar@igalia.com <svillar@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 26 Feb 2018 13:37:55 +0000 (13:37 +0000)
https://bugs.webkit.org/show_bug.cgi?id=182999

Reviewed by Žan Doberšek.

Retrieve the z-depth of the eye view frustum and the HMD unique id.
The unique identifier is generated by the VRPlatormManager whereas
we use the default values from the spec for the z-depth (those can
be changed by applications later via JavaScript).

Once this lands the only remaining data to be retrieved from VR
backends for VRDisplay is the pose (getPose() call) and the frame
data (getFrameData() call).

* Modules/webvr/VRDisplay.cpp:
(WebCore::VRDisplay::VRDisplay):
(WebCore::VRDisplay::displayId const): Deleted.
(WebCore::VRDisplay::displayName const): Deleted.
(WebCore::VRDisplay::depthNear const): Deleted.
(WebCore::VRDisplay::setDepthNear): Deleted.
(WebCore::VRDisplay::depthFar const): Deleted.
(WebCore::VRDisplay::setDepthFar): Deleted.
* Modules/webvr/VRDisplay.h:
(WebCore::VRDisplay::displayId const): Moved implementation from
source file.
(WebCore::VRDisplay::displayName const): Ditto.
(WebCore::VRDisplay::depthNear const):
(WebCore::VRDisplay::setDepthNear):
(WebCore::VRDisplay::depthFar const):
(WebCore::VRDisplay::setDepthFar):
* platform/vr/VRManager.cpp:
(WebCore::VRManager::generateUniqueDisplayIdentifier):
* platform/vr/VRManager.h:
* platform/vr/VRPlatformDisplay.h:
* platform/vr/openvr/VRPlatformDisplayOpenVR.cpp:
(WebCore::VRPlatformDisplayOpenVR::VRPlatformDisplayOpenVR):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@229014 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/Modules/webvr/VRDisplay.cpp
Source/WebCore/Modules/webvr/VRDisplay.h
Source/WebCore/platform/vr/VRPlatformDisplay.h
Source/WebCore/platform/vr/openvr/VRPlatformDisplayOpenVR.cpp
Source/WebCore/platform/vr/openvr/VRPlatformDisplayOpenVR.h

index b187406..65cbe47 100644 (file)
@@ -1,3 +1,42 @@
+2018-02-21  Sergio Villar Senin  <svillar@igalia.com>
+
+        [WebVR][OpenVR] Retrieve displayId and the z-depth of eye view frustum
+        https://bugs.webkit.org/show_bug.cgi?id=182999
+
+        Reviewed by Žan Doberšek.
+
+        Retrieve the z-depth of the eye view frustum and the HMD unique id.
+        The unique identifier is generated by the VRPlatormManager whereas
+        we use the default values from the spec for the z-depth (those can
+        be changed by applications later via JavaScript).
+
+        Once this lands the only remaining data to be retrieved from VR
+        backends for VRDisplay is the pose (getPose() call) and the frame
+        data (getFrameData() call).
+
+        * Modules/webvr/VRDisplay.cpp:
+        (WebCore::VRDisplay::VRDisplay):
+        (WebCore::VRDisplay::displayId const): Deleted.
+        (WebCore::VRDisplay::displayName const): Deleted.
+        (WebCore::VRDisplay::depthNear const): Deleted.
+        (WebCore::VRDisplay::setDepthNear): Deleted.
+        (WebCore::VRDisplay::depthFar const): Deleted.
+        (WebCore::VRDisplay::setDepthFar): Deleted.
+        * Modules/webvr/VRDisplay.h:
+        (WebCore::VRDisplay::displayId const): Moved implementation from
+        source file.
+        (WebCore::VRDisplay::displayName const): Ditto.
+        (WebCore::VRDisplay::depthNear const):
+        (WebCore::VRDisplay::setDepthNear):
+        (WebCore::VRDisplay::depthFar const):
+        (WebCore::VRDisplay::setDepthFar):
+        * platform/vr/VRManager.cpp:
+        (WebCore::VRManager::generateUniqueDisplayIdentifier):
+        * platform/vr/VRManager.h:
+        * platform/vr/VRPlatformDisplay.h:
+        * platform/vr/openvr/VRPlatformDisplayOpenVR.cpp:
+        (WebCore::VRPlatformDisplayOpenVR::VRPlatformDisplayOpenVR):
+
 2018-02-26  Charlie Turner  <cturner@igalia.com>
 
         Fix build error with !LOG_DISABLED
index 58c78de..4de9125 100644 (file)
@@ -50,6 +50,7 @@ VRDisplay::VRDisplay(ScriptExecutionContext& context, WeakPtr<VRPlatformDisplay>
     m_capabilities = VRDisplayCapabilities::create(displayInfo.capabilityFlags);
     m_leftEyeParameters = VREyeParameters::create(displayInfo.eyeTranslation[VRPlatformDisplayInfo::EyeLeft], displayInfo.eyeFieldOfView[VRPlatformDisplayInfo::EyeLeft], displayInfo.renderSize);
     m_rightEyeParameters = VREyeParameters::create(displayInfo.eyeTranslation[VRPlatformDisplayInfo::EyeRight], displayInfo.eyeFieldOfView[VRPlatformDisplayInfo::EyeRight], displayInfo.renderSize);
+    m_displayId = displayInfo.displayIdentifier;
     m_displayName = displayInfo.displayName;
 }
 
@@ -84,16 +85,6 @@ const VREyeParameters& VRDisplay::getEyeParameters(VREye eye) const
     return eye == VREye::Left ? *m_leftEyeParameters : *m_rightEyeParameters;
 }
 
-unsigned VRDisplay::displayId() const
-{
-    return 0;
-}
-
-const String& VRDisplay::displayName() const
-{
-    return m_displayName;
-}
-
 bool VRDisplay::getFrameData(VRFrameData&) const
 {
     return false;
@@ -108,24 +99,6 @@ void VRDisplay::resetPose()
 {
 }
 
-double VRDisplay::depthNear() const
-{
-    return 0;
-}
-
-void VRDisplay::setDepthNear(double)
-{
-}
-
-double VRDisplay::depthFar() const
-{
-    return 0;
-}
-
-void VRDisplay::setDepthFar(double)
-{
-}
-
 long VRDisplay::requestAnimationFrame(Ref<RequestAnimationFrameCallback>&&)
 {
     return 0;
index 50a3312..a242e44 100644 (file)
@@ -59,18 +59,18 @@ public:
 
     const VREyeParameters& getEyeParameters(VREye) const;
 
-    unsigned displayId() const;
-    const String& displayName() const;
+    const String& displayName() const { return m_displayName; }
+    uint32_t displayId() const { return m_displayId; }
 
     bool getFrameData(VRFrameData&) const;
 
     Ref<VRPose> getPose() const;
     void resetPose();
 
-    double depthNear() const;
-    void setDepthNear(double);
-    double depthFar() const;
-    void setDepthFar(double);
+    double depthNear() const { return m_depthNear; }
+    void setDepthNear(double depthNear) { m_depthNear = depthNear; }
+    double depthFar() const { return m_depthFar; }
+    void setDepthFar(double depthFar) { m_depthFar = depthFar; }
 
     long requestAnimationFrame(Ref<RequestAnimationFrameCallback>&&);
     void cancelAnimationFrame(unsigned);
@@ -107,6 +107,10 @@ private:
     RefPtr<VRStageParameters> m_stageParameters;
 
     String m_displayName;
+    uint32_t m_displayId;
+
+    double m_depthNear { 0.01 }; // Default value from the specs.
+    double m_depthFar { 10000 }; // Default value from the specs.
 };
 
 } // namespace WebCore
index 1e42933..2014934 100644 (file)
@@ -47,6 +47,7 @@ struct VRPlatformDisplayInfo {
     bool isConnected;
     bool isMounted;
     unsigned capabilityFlags;
+    uint32_t displayIdentifier;
 
     enum Eye { EyeLeft = 0, EyeRight, NumEyes };
     FloatPoint3D eyeTranslation[Eye::NumEyes];
index baed994..13c7b60 100644 (file)
 
 namespace WebCore {
 
+uint32_t VRPlatformDisplayOpenVR::s_displayIdentifier = 0;
+
 VRPlatformDisplayOpenVR::VRPlatformDisplayOpenVR(vr::IVRSystem* system, vr::IVRChaperone* chaperone, vr::IVRCompositor* compositor)
     : m_system(system)
     , m_chaperone(chaperone)
     , m_compositor(compositor)
 {
+    m_displayInfo.displayIdentifier = ++s_displayIdentifier;
     m_displayInfo.isConnected = m_system->IsTrackedDeviceConnected(vr::k_unTrackedDeviceIndex_Hmd);
 
     StringBuilder stringBuilder;
index 6524f4e..0b933f3 100644 (file)
@@ -40,6 +40,8 @@ private:
     void updateEyeParameters();
     void updateStageParameters();
 
+    static uint32_t s_displayIdentifier;
+
     vr::IVRSystem* m_system;
     vr::IVRChaperone* m_chaperone;
     vr::IVRCompositor* m_compositor;