Diff
Modified: trunk/Source/WebCore/ChangeLog (229088 => 229089)
--- trunk/Source/WebCore/ChangeLog 2018-02-28 07:49:44 UTC (rev 229088)
+++ trunk/Source/WebCore/ChangeLog 2018-02-28 08:45:26 UTC (rev 229089)
@@ -1,3 +1,58 @@
+2018-02-27 Sergio Villar Senin <[email protected]>
+
+ [WebVR] Convert VRPlatformDisplayInfo into a class
+ https://bugs.webkit.org/show_bug.cgi?id=183162
+
+ Reviewed by Žan Doberšek.
+
+ In preparation for further changes we're transforming the
+ VRPlatformDisplayInfo into a class. All the members are now private
+ and the class provides the needed getters/setters.
+
+ Apart from that VRDisplayCapabilityFlags is now just an unsigned and
+ the different flags are defined in VRDisplayCapabilityFlag enum.
+ Another cleanup was the removal of VRDisplayCapabilities.cpp as
+ everything can be implemented in the header.
+
+ * Modules/webvr/VRDisplay.cpp:
+ (WebCore::VRDisplay::VRDisplay):
+ (WebCore::VRDisplay::isConnected const):
+ (WebCore::VRDisplay::stageParameters const):
+ * Modules/webvr/VRDisplayCapabilities.cpp: Removed.
+ * Modules/webvr/VRDisplayCapabilities.h:
+ (WebCore::VRDisplayCapabilities::hasPosition const):
+ (WebCore::VRDisplayCapabilities::hasOrientation const):
+ (WebCore::VRDisplayCapabilities::hasExternalDisplay const):
+ (WebCore::VRDisplayCapabilities::canPresent const):
+ (WebCore::VRDisplayCapabilities::maxLayer const):
+ (WebCore::VRDisplayCapabilities::VRDisplayCapabilities):
+ * Sources.txt:
+ * platform/vr/VRPlatformDisplay.h:
+ (WebCore::VRPlatformDisplayInfo::displayName const):
+ (WebCore::VRPlatformDisplayInfo::setDisplayName):
+ (WebCore::VRPlatformDisplayInfo::isConnected const):
+ (WebCore::VRPlatformDisplayInfo::setIsConnected):
+ (WebCore::VRPlatformDisplayInfo::isMounted const):
+ (WebCore::VRPlatformDisplayInfo::setIsMounted):
+ (WebCore::VRPlatformDisplayInfo::capabilityFlags const):
+ (WebCore::VRPlatformDisplayInfo::setCapabilityFlags):
+ (WebCore::VRPlatformDisplayInfo::displayIdentifier const):
+ (WebCore::VRPlatformDisplayInfo::setDisplayIdentifier):
+ (WebCore::VRPlatformDisplayInfo::eyeTranslation const):
+ (WebCore::VRPlatformDisplayInfo::setEyeTranslation):
+ (WebCore::VRPlatformDisplayInfo::eyeFieldOfView const):
+ (WebCore::VRPlatformDisplayInfo::setEyeFieldOfView):
+ (WebCore::VRPlatformDisplayInfo::renderSize const):
+ (WebCore::VRPlatformDisplayInfo::setRenderSize):
+ (WebCore::VRPlatformDisplayInfo::setPlayAreaBounds):
+ (WebCore::VRPlatformDisplayInfo::playAreaBounds const):
+ (WebCore::VRPlatformDisplayInfo::setSittingToStandingTransform):
+ (WebCore::VRPlatformDisplayInfo::sittingToStandingTransform const):
+ * platform/vr/openvr/VRPlatformDisplayOpenVR.cpp:
+ (WebCore::VRPlatformDisplayOpenVR::VRPlatformDisplayOpenVR):
+ (WebCore::VRPlatformDisplayOpenVR::updateEyeParameters):
+ (WebCore::VRPlatformDisplayOpenVR::updateStageParameters):
+
2018-02-27 Commit Queue <[email protected]>
Unreviewed, rolling out r229060.
Modified: trunk/Source/WebCore/Modules/webvr/VRDisplay.cpp (229088 => 229089)
--- trunk/Source/WebCore/Modules/webvr/VRDisplay.cpp 2018-02-28 07:49:44 UTC (rev 229088)
+++ trunk/Source/WebCore/Modules/webvr/VRDisplay.cpp 2018-02-28 08:45:26 UTC (rev 229089)
@@ -47,11 +47,11 @@
, m_display(WTFMove(platformDisplay))
{
auto displayInfo = m_display->getDisplayInfo();
- 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;
+ 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();
}
VRDisplay::~VRDisplay() = default;
@@ -61,7 +61,7 @@
if (!m_display)
return false;
- return m_display->getDisplayInfo().isConnected;
+ return m_display->getDisplayInfo().isConnected();
}
bool VRDisplay::isPresenting() const
@@ -77,7 +77,7 @@
RefPtr<VRStageParameters> VRDisplay::stageParameters() const
{
auto displayInfo = m_display->getDisplayInfo();
- return VRStageParameters::create(displayInfo.sittingToStandingTransform, displayInfo.playAreaBounds);
+ return VRStageParameters::create(displayInfo.sittingToStandingTransform(), displayInfo.playAreaBounds());
}
const VREyeParameters& VRDisplay::getEyeParameters(VREye eye) const
Deleted: trunk/Source/WebCore/Modules/webvr/VRDisplayCapabilities.cpp (229088 => 229089)
--- trunk/Source/WebCore/Modules/webvr/VRDisplayCapabilities.cpp 2018-02-28 07:49:44 UTC (rev 229088)
+++ trunk/Source/WebCore/Modules/webvr/VRDisplayCapabilities.cpp 2018-02-28 08:45:26 UTC (rev 229089)
@@ -1,61 +0,0 @@
-/*
- * Copyright (C) 2017 Igalia S.L. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "VRDisplayCapabilities.h"
-
-namespace WebCore {
-
-VRDisplayCapabilities::VRDisplayCapabilities(unsigned capabilityFlags)
-{
- m_flags = capabilityFlags;
-}
-
-bool VRDisplayCapabilities::hasPosition() const
-{
- return m_flags & VRDisplayCapabilityFlags::Position;
-}
-
-bool VRDisplayCapabilities::hasOrientation() const
-{
- return m_flags & VRDisplayCapabilityFlags::Orientation;
-}
-
-bool VRDisplayCapabilities::hasExternalDisplay() const
-{
- return m_flags & VRDisplayCapabilityFlags::ExternalDisplay;
-}
-
-bool VRDisplayCapabilities::canPresent() const
-{
- return m_flags & VRDisplayCapabilityFlags::Present;
-}
-
-unsigned VRDisplayCapabilities::maxLayer() const
-{
- return canPresent() ? 1 : 0;
-}
-
-} // namespace WebCore
Modified: trunk/Source/WebCore/Modules/webvr/VRDisplayCapabilities.h (229088 => 229089)
--- trunk/Source/WebCore/Modules/webvr/VRDisplayCapabilities.h 2018-02-28 07:49:44 UTC (rev 229088)
+++ trunk/Source/WebCore/Modules/webvr/VRDisplayCapabilities.h 2018-02-28 08:45:26 UTC (rev 229089)
@@ -25,6 +25,8 @@
#pragma once
+#include "VRPlatformDisplay.h"
+
#include <wtf/Ref.h>
#include <wtf/RefCounted.h>
@@ -37,14 +39,17 @@
return adoptRef(*new VRDisplayCapabilities(capabilityFlags));
}
- bool hasPosition() const;
- bool hasOrientation() const;
- bool hasExternalDisplay() const;
- bool canPresent() const;
- unsigned maxLayer() const;
+ bool hasPosition() const { return m_flags & VRDisplayCapabilityFlag::Position; }
+ bool hasOrientation() const { return m_flags & VRDisplayCapabilityFlag::Orientation; }
+ bool hasExternalDisplay() const { return m_flags & VRDisplayCapabilityFlag::ExternalDisplay; }
+ bool canPresent() const { return m_flags & VRDisplayCapabilityFlag::Present; }
+ unsigned maxLayer() const { return canPresent() ? 1 : 0; }
private:
- VRDisplayCapabilities(unsigned capabilityFlags);
+ VRDisplayCapabilities(unsigned capabilityFlags)
+ : m_flags(capabilityFlags)
+ {
+ }
unsigned m_flags;
};
Modified: trunk/Source/WebCore/Sources.txt (229088 => 229089)
--- trunk/Source/WebCore/Sources.txt 2018-02-28 07:49:44 UTC (rev 229088)
+++ trunk/Source/WebCore/Sources.txt 2018-02-28 08:45:26 UTC (rev 229089)
@@ -290,7 +290,6 @@
Modules/webvr/NavigatorWebVR.cpp
Modules/webvr/VRDisplay.cpp
-Modules/webvr/VRDisplayCapabilities.cpp
Modules/webvr/VRDisplayEvent.cpp
Modules/webvr/VREyeParameters.cpp
Modules/webvr/VRFrameData.cpp
Modified: trunk/Source/WebCore/platform/vr/VRPlatformDisplay.h (229088 => 229089)
--- trunk/Source/WebCore/platform/vr/VRPlatformDisplay.h 2018-02-28 07:49:44 UTC (rev 229088)
+++ trunk/Source/WebCore/platform/vr/VRPlatformDisplay.h 2018-02-28 08:45:26 UTC (rev 229089)
@@ -28,7 +28,9 @@
namespace WebCore {
-enum VRDisplayCapabilityFlags {
+typedef unsigned VRDisplayCapabilityFlags;
+
+enum VRDisplayCapabilityFlag {
None = 0,
Position = 1 << 1,
Orientation = 1 << 2,
@@ -42,15 +44,26 @@
* the info from the display. Note that it's fairly unlikely that a VR application would only
* require just a few pieces of information from the device.
*/
-struct VRPlatformDisplayInfo {
- String displayName;
- bool isConnected;
- bool isMounted;
- unsigned capabilityFlags;
- uint32_t displayIdentifier;
+class VRPlatformDisplayInfo {
+public:
+ const String displayName() const { return m_displayName; }
+ void setDisplayName(String&& displayName) { m_displayName = WTFMove(displayName); }
+ bool isConnected() const { return m_isConnected; }
+ void setIsConnected(bool isConnected) { m_isConnected = isConnected; }
+
+ bool isMounted() const { return m_isMounted; }
+ void setIsMounted(bool isMounted) { m_isMounted = isMounted; }
+
+ const VRDisplayCapabilityFlags& capabilityFlags() const { return m_capabilityFlags; }
+ void setCapabilityFlags(const VRDisplayCapabilityFlags& flags) { m_capabilityFlags = flags; }
+
+ uint32_t displayIdentifier() const { return m_displayIdentifier; }
+ void setDisplayIdentifier(uint32_t displayIdentifier) { m_displayIdentifier = displayIdentifier; }
+
enum Eye { EyeLeft = 0, EyeRight, NumEyes };
- FloatPoint3D eyeTranslation[Eye::NumEyes];
+ const FloatPoint3D& eyeTranslation(Eye eye) const { return m_eyeTranslation[eye]; }
+ void setEyeTranslation(Eye eye, const FloatPoint3D& translation) { m_eyeTranslation[eye] = translation; }
struct FieldOfView {
double upDegrees;
@@ -57,15 +70,37 @@
double downDegrees;
double leftDegrees;
double rightDegrees;
- } eyeFieldOfView[Eye::NumEyes];
+ };
+ const FieldOfView& eyeFieldOfView(Eye eye) const { return m_eyeFieldOfView[eye]; }
+ void setEyeFieldOfView(Eye eye, const FieldOfView& fieldOfView) { m_eyeFieldOfView[eye] = fieldOfView; }
struct RenderSize {
unsigned width;
unsigned height;
- } renderSize;
+ };
+ const RenderSize& renderSize() const { return m_renderSize; }
+ void setRenderSize(const RenderSize& renderSize) { m_renderSize = renderSize; }
- std::optional<FloatSize> playAreaBounds;
- std::optional<TransformationMatrix> sittingToStandingTransform;
+ void setPlayAreaBounds(const FloatSize& playAreaBounds) { m_playAreaBounds = playAreaBounds; }
+ const std::optional<FloatSize>& playAreaBounds() const { return m_playAreaBounds; }
+
+ void setSittingToStandingTransform(const TransformationMatrix& transform) { m_sittingToStandingTransform = transform; }
+ const std::optional<TransformationMatrix>& sittingToStandingTransform() const { return m_sittingToStandingTransform; }
+
+private:
+ String m_displayName;
+ bool m_isConnected;
+ bool m_isMounted;
+ VRDisplayCapabilityFlags m_capabilityFlags;
+ uint32_t m_displayIdentifier;
+
+ FloatPoint3D m_eyeTranslation[Eye::NumEyes];
+
+ RenderSize m_renderSize;
+ FieldOfView m_eyeFieldOfView[Eye::NumEyes];
+
+ std::optional<FloatSize> m_playAreaBounds;
+ std::optional<TransformationMatrix> m_sittingToStandingTransform;
};
class VRPlatformDisplay {
Modified: trunk/Source/WebCore/platform/vr/openvr/VRPlatformDisplayOpenVR.cpp (229088 => 229089)
--- trunk/Source/WebCore/platform/vr/openvr/VRPlatformDisplayOpenVR.cpp 2018-02-28 07:49:44 UTC (rev 229088)
+++ trunk/Source/WebCore/platform/vr/openvr/VRPlatformDisplayOpenVR.cpp 2018-02-28 08:45:26 UTC (rev 229089)
@@ -34,8 +34,8 @@
, m_chaperone(chaperone)
, m_compositor(compositor)
{
- m_displayInfo.displayIdentifier = ++s_displayIdentifier;
- m_displayInfo.isConnected = m_system->IsTrackedDeviceConnected(vr::k_unTrackedDeviceIndex_Hmd);
+ m_displayInfo.setDisplayIdentifier(++s_displayIdentifier);
+ m_displayInfo.setIsConnected(m_system->IsTrackedDeviceConnected(vr::k_unTrackedDeviceIndex_Hmd));
StringBuilder stringBuilder;
stringBuilder.appendLiteral("OpenVR HMD");
@@ -45,15 +45,10 @@
stringBuilder.append(HMDName, length);
stringBuilder.append(')');
}
- m_displayInfo.displayName = stringBuilder.toString();
-
- m_displayInfo.isMounted = false;
+ m_displayInfo.setDisplayName(stringBuilder.toString());
+ m_displayInfo.setIsMounted(false);
// FIXME: We're assuming an HTC Vive HMD here. Get this info from OpenVR?.
- m_displayInfo.capabilityFlags = VRDisplayCapabilityFlags::None |
- VRDisplayCapabilityFlags::Position |
- VRDisplayCapabilityFlags::Orientation |
- VRDisplayCapabilityFlags::ExternalDisplay |
- VRDisplayCapabilityFlags::Present;
+ m_displayInfo.setCapabilityFlags(VRDisplayCapabilityFlag::None | VRDisplayCapabilityFlag::Position | VRDisplayCapabilityFlag::Orientation | VRDisplayCapabilityFlag::ExternalDisplay | VRDisplayCapabilityFlag::Present);
updateEyeParameters();
updateStageParameters();
@@ -70,16 +65,17 @@
void VRPlatformDisplayOpenVR::updateEyeParameters()
{
for (unsigned eye = 0; eye < VRPlatformDisplayInfo::NumEyes; ++eye) {
- m_displayInfo.eyeFieldOfView[eye] = computeFieldOfView(static_cast<vr::Hmd_Eye>(eye));
+ auto platformEye = static_cast<VRPlatformDisplayInfo::Eye>(eye);
+ m_displayInfo.setEyeFieldOfView(platformEye, computeFieldOfView(static_cast<vr::Hmd_Eye>(eye)));
vr::HmdMatrix34_t eyeToHead = m_system->GetEyeToHeadTransform(static_cast<vr::Hmd_Eye>(eye));
- m_displayInfo.eyeTranslation[eye].set(eyeToHead.m[0][3], eyeToHead.m[1][3], eyeToHead.m[2][3]);
+ m_displayInfo.setEyeTranslation(platformEye, { eyeToHead.m[0][3], eyeToHead.m[1][3], eyeToHead.m[2][3] });
}
uint32_t width;
uint32_t height;
m_system->GetRecommendedRenderTargetSize(&width, &height);
- m_displayInfo.renderSize = { width, height };
+ m_displayInfo.setRenderSize({ width, height });
}
void VRPlatformDisplayOpenVR::updateStageParameters()
@@ -89,16 +85,18 @@
if (!m_chaperone->GetPlayAreaSize(&playAreaWidth, &playAreaDepth)) {
// Fallback to sensible values, 1mx1m play area and 0.75m high seated position. We do as
// Firefox does.
- m_displayInfo.sittingToStandingTransform = TransformationMatrix();
- m_displayInfo.sittingToStandingTransform->setM42(0.75);
+ TransformationMatrix matrix;
+ matrix.setM42(0.75);
+ m_displayInfo.setSittingToStandingTransform(WTFMove(matrix));
} else {
vr::HmdMatrix34_t transformMatrix = m_system->GetSeatedZeroPoseToStandingAbsoluteTrackingPose();
- m_displayInfo.sittingToStandingTransform = TransformationMatrix(transformMatrix.m[0][0], transformMatrix.m[1][0], transformMatrix.m[2][0], 0,
+ auto matrix = TransformationMatrix(transformMatrix.m[0][0], transformMatrix.m[1][0], transformMatrix.m[2][0], 0,
transformMatrix.m[0][1], transformMatrix.m[1][1], transformMatrix.m[2][1], 0,
transformMatrix.m[0][2], transformMatrix.m[1][2], transformMatrix.m[2][2], 0,
transformMatrix.m[0][3], transformMatrix.m[1][3], transformMatrix.m[2][3], 1);
+ m_displayInfo.setSittingToStandingTransform(WTFMove(matrix));
}
- m_displayInfo.playAreaBounds = FloatSize(playAreaWidth, playAreaDepth);
+ m_displayInfo.setPlayAreaBounds(FloatSize(playAreaWidth, playAreaDepth));
}
}; // namespace WebCore