Diff
Modified: trunk/Source/WebCore/CMakeLists.txt (228661 => 228662)
--- trunk/Source/WebCore/CMakeLists.txt 2018-02-19 12:10:16 UTC (rev 228661)
+++ trunk/Source/WebCore/CMakeLists.txt 2018-02-19 13:16:13 UTC (rev 228662)
@@ -118,6 +118,7 @@
"${WEBCORE_DIR}/platform/sql"
"${WEBCORE_DIR}/platform/text"
"${WEBCORE_DIR}/platform/text/icu"
+ "${WEBCORE_DIR}/platform/vr"
"${WEBCORE_DIR}/plugins"
"${WEBCORE_DIR}/rendering"
"${WEBCORE_DIR}/rendering/line"
@@ -1525,6 +1526,7 @@
if (USE_OPENVR)
list(APPEND WebCore_INCLUDE_DIRECTORIES "${THIRDPARTY_DIR}/openvr/headers")
+ list(APPEND WebCore_INCLUDE_DIRECTORIES "${WEBCORE_DIR}/platform/vr/openvr")
list(APPEND WebCore_LIBRARIES openvr_api)
endif ()
Modified: trunk/Source/WebCore/ChangeLog (228661 => 228662)
--- trunk/Source/WebCore/ChangeLog 2018-02-19 12:10:16 UTC (rev 228661)
+++ trunk/Source/WebCore/ChangeLog 2018-02-19 13:16:13 UTC (rev 228662)
@@ -1,3 +1,65 @@
+2018-02-12 Sergio Villar Senin <svil...@igalia.com>
+
+ [WebVR][OpenVR] Implement getVRDisplays()
+ https://bugs.webkit.org/show_bug.cgi?id=182692
+
+ Reviewed by Žan Doberšek.
+
+ This provides an implementation of Navigator's getVRDisplays()
+ method using OpenVR as backend. It queues several promises in
+ a queue and resolves them all just once. The information retrieved
+ is very minimal for the time being, but this change lays the ground
+ for all the changes that are about to land.
+
+ The VR code uses a VRManager which is the interface with the
+ platform code and the responsible for instantiating the right
+ platform code. This platform code is currently being implemented
+ using OpenVR but could we also ported in the future to OpenXR or any
+ other VR SDK.
+
+ * CMakeLists.txt:
+ * Modules/webvr/NavigatorWebVR.cpp:
+ (WebCore::NavigatorWebVR::getVRDisplays):
+ (WebCore::NavigatorWebVR::vrEnabled):
+ * Modules/webvr/NavigatorWebVR.h:
+ * Modules/webvr/VRDisplay.cpp:
+ (WebCore::VRDisplay::create):
+ (WebCore::VRDisplay::VRDisplay):
+ (WebCore::VRDisplay::isConnected const):
+ (WebCore::VRDisplay::displayName const):
+ * Modules/webvr/VRDisplay.h:
+ * Modules/webvr/VRDisplayCapabilities.cpp:
+ (WebCore::VRDisplayCapabilities::VRDisplayCapabilities):
+ (WebCore::VRDisplayCapabilities::hasPosition const):
+ (WebCore::VRDisplayCapabilities::hasOrientation const):
+ (WebCore::VRDisplayCapabilities::hasExternalDisplay const):
+ (WebCore::VRDisplayCapabilities::canPresent const):
+ (WebCore::VRDisplayCapabilities::maxLayer const):
+ * Modules/webvr/VRDisplayCapabilities.h:
+ (WebCore::VRDisplayCapabilities::create):
+ * Sources.txt:
+ * platform/vr/VRManager.cpp: Added. This is the main interface used by bindings code to
+ access VR devices data provided by platform code.
+ (WebCore::VRManager::singleton):
+ (WebCore::VRManager::VRManager):
+ (WebCore::VRManager::~VRManager):
+ (WebCore::VRManager::refreshVRDevices):
+ * platform/vr/VRManager.h: Added.
+ * platform/vr/VRPlatformDisplay.h: Added. Abstraction of a VR display system. To be
+ implemented by backends like OpenVR, OpenXR...
+ * platform/vr/VRPlatformManager.h: Added. Abstraction of the platform specific class which
+ retrieves data from VR devices. To be implemented by backends like OpenVR, OpenXR...
+ * platform/vr/openvr/VRPlatformDisplayOpenVR.cpp: Added.
+ (WebCore::VRPlatformDisplayOpenVR::VRPlatformDisplayOpenVR):
+ * platform/vr/openvr/VRPlatformDisplayOpenVR.h: Added.
+ * platform/vr/openvr/VRPlatformManagerOpenVR.cpp: Added.
+ (WebCore::VRPlatformManagerOpenVR::create):
+ (WebCore::VRPlatformManagerOpenVR::VRPlatformManagerOpenVR):
+ (WebCore::VRPlatformManagerOpenVR::~VRPlatformManagerOpenVR):
+ (WebCore::VRPlatformManagerOpenVR::initOpenVR):
+ * platform/vr/openvr/VRPlatformManagerOpenVR.h: Added.
+ * WebCore.xcodeproj/project.pbxproj:
+
2018-02-19 Manuel Rego Casasnovas <r...@igalia.com>
[css-grid] Apply automatic minimum size clamping to spanning items too
Modified: trunk/Source/WebCore/Modules/webvr/NavigatorWebVR.cpp (228661 => 228662)
--- trunk/Source/WebCore/Modules/webvr/NavigatorWebVR.cpp 2018-02-19 12:10:16 UTC (rev 228661)
+++ trunk/Source/WebCore/Modules/webvr/NavigatorWebVR.cpp 2018-02-19 13:16:13 UTC (rev 228662)
@@ -26,12 +26,33 @@
#include "config.h"
#include "NavigatorWebVR.h"
+#include "Document.h"
+#include "JSVRDisplay.h"
+#include "Navigator.h"
#include "VRDisplay.h"
+#include "VRManager.h"
namespace WebCore {
-void NavigatorWebVR::getVRDisplays(Navigator&, Ref<DeferredPromise>&&)
+void NavigatorWebVR::getVRDisplays(Navigator& navigator, Document& document, GetVRDisplaysPromise&& promise)
{
+ if (!vrEnabled(navigator)) {
+ promise.reject();
+ return;
+ }
+
+ document.postTask([promise = WTFMove(promise)] (ScriptExecutionContext& context) mutable {
+ std::optional<VRManager::VRDisplaysVector> platformDisplays = VRManager::singleton().getVRDisplays();
+ if (!platformDisplays) {
+ promise.reject();
+ return;
+ }
+
+ Vector<Ref<VRDisplay>> displays;
+ for (auto& platformDisplay : platformDisplays.value())
+ displays.append(VRDisplay::create(context, WTFMove(platformDisplay)));
+ promise.resolve(displays);
+ });
}
const Vector<RefPtr<VRDisplay>>& NavigatorWebVR::activeVRDisplays(Navigator&)
Modified: trunk/Source/WebCore/Modules/webvr/NavigatorWebVR.h (228661 => 228662)
--- trunk/Source/WebCore/Modules/webvr/NavigatorWebVR.h 2018-02-19 12:10:16 UTC (rev 228661)
+++ trunk/Source/WebCore/Modules/webvr/NavigatorWebVR.h 2018-02-19 13:16:13 UTC (rev 228662)
@@ -31,6 +31,7 @@
namespace WebCore {
+class Document;
class Navigator;
class Page;
class VRDisplay;
@@ -37,7 +38,9 @@
class NavigatorWebVR final : public Supplement<Page> {
public:
- static void getVRDisplays(Navigator&, Ref<DeferredPromise>&&);
+ using GetVRDisplaysPromise = DOMPromiseDeferred<IDLSequence<IDLInterface<VRDisplay>>>;
+
+ static void getVRDisplays(Navigator&, Document&, GetVRDisplaysPromise&&);
static const Vector<RefPtr<VRDisplay>>& activeVRDisplays(Navigator&);
static bool vrEnabled(Navigator&);
};
Modified: trunk/Source/WebCore/Modules/webvr/NavigatorWebVR.idl (228661 => 228662)
--- trunk/Source/WebCore/Modules/webvr/NavigatorWebVR.idl 2018-02-19 12:10:16 UTC (rev 228661)
+++ trunk/Source/WebCore/Modules/webvr/NavigatorWebVR.idl 2018-02-19 13:16:13 UTC (rev 228662)
@@ -26,6 +26,6 @@
[
EnabledAtRuntime=WebVR,
] partial interface Navigator {
- Promise<sequence<VRDisplay>> getVRDisplays();
+ [CallWith=Document] Promise<sequence<VRDisplay>> getVRDisplays();
readonly attribute FrozenArray<VRDisplay> activeVRDisplays;
};
Modified: trunk/Source/WebCore/Modules/webvr/VRDisplay.cpp (228661 => 228662)
--- trunk/Source/WebCore/Modules/webvr/VRDisplay.cpp 2018-02-19 12:10:16 UTC (rev 228661)
+++ trunk/Source/WebCore/Modules/webvr/VRDisplay.cpp 2018-02-19 13:16:13 UTC (rev 228662)
@@ -29,21 +29,24 @@
#include "VRDisplayCapabilities.h"
#include "VREyeParameters.h"
#include "VRLayerInit.h"
+#include "VRPlatformDisplay.h"
#include "VRPose.h"
namespace WebCore {
-Ref<VRDisplay> VRDisplay::create(ScriptExecutionContext& context)
+Ref<VRDisplay> VRDisplay::create(ScriptExecutionContext& context, WeakPtr<VRPlatformDisplay>&& platformDisplay)
{
- auto display = adoptRef(*new VRDisplay(context));
+ auto display = adoptRef(*new VRDisplay(context, WTFMove(platformDisplay)));
display->suspendIfNeeded();
return display;
}
-VRDisplay::VRDisplay(ScriptExecutionContext& context)
+VRDisplay::VRDisplay(ScriptExecutionContext& context, WeakPtr<VRPlatformDisplay>&& platformDisplay)
: ActiveDOMObject(&context)
- , m_capabilities(VRDisplayCapabilities::create())
+ , m_capabilities(VRDisplayCapabilities::create(platformDisplay->getDisplayInfo().capabilityFlags))
, m_eyeParameters(VREyeParameters::create())
+ , m_display(WTFMove(platformDisplay))
+ , m_displayName(platformDisplay->getDisplayInfo().displayName)
{
}
@@ -51,7 +54,10 @@
bool VRDisplay::isConnected() const
{
- return false;
+ if (!m_display)
+ return false;
+
+ return m_display->getDisplayInfo().isConnected;
}
bool VRDisplay::isPresenting() const
@@ -81,7 +87,7 @@
const String& VRDisplay::displayName() const
{
- return emptyString();
+ return m_displayName;
}
bool VRDisplay::getFrameData(VRFrameData&) const
Modified: trunk/Source/WebCore/Modules/webvr/VRDisplay.h (228661 => 228662)
--- trunk/Source/WebCore/Modules/webvr/VRDisplay.h 2018-02-19 12:10:16 UTC (rev 228661)
+++ trunk/Source/WebCore/Modules/webvr/VRDisplay.h 2018-02-19 13:16:13 UTC (rev 228662)
@@ -37,6 +37,7 @@
class VRDisplayCapabilities;
class VREyeParameters;
class VRFrameData;
+class VRPlatformDisplay;
class VRPose;
class VRStageParameters;
struct VRLayerInit;
@@ -43,7 +44,7 @@
class VRDisplay : public RefCounted<VRDisplay>, public EventTargetWithInlineData, public ActiveDOMObject {
public:
- static Ref<VRDisplay> create(ScriptExecutionContext&);
+ static Ref<VRDisplay> create(ScriptExecutionContext&, WeakPtr<VRPlatformDisplay>&&);
virtual ~VRDisplay();
@@ -82,7 +83,7 @@
void submitFrame();
private:
- VRDisplay(ScriptExecutionContext&);
+ VRDisplay(ScriptExecutionContext&, WeakPtr<VRPlatformDisplay>&&);
// EventTarget
EventTargetInterface eventTargetInterface() const override { return VRDisplayEventTargetInterfaceType; }
@@ -98,6 +99,10 @@
Ref<VRDisplayCapabilities> m_capabilities;
Ref<VREyeParameters> m_eyeParameters;
+
+ WeakPtr<VRPlatformDisplay> m_display;
+
+ const String m_displayName;
};
} // namespace WebCore
Modified: trunk/Source/WebCore/Modules/webvr/VRDisplayCapabilities.cpp (228661 => 228662)
--- trunk/Source/WebCore/Modules/webvr/VRDisplayCapabilities.cpp 2018-02-19 12:10:16 UTC (rev 228661)
+++ trunk/Source/WebCore/Modules/webvr/VRDisplayCapabilities.cpp 2018-02-19 13:16:13 UTC (rev 228662)
@@ -28,31 +28,34 @@
namespace WebCore {
-VRDisplayCapabilities::VRDisplayCapabilities() = default;
+VRDisplayCapabilities::VRDisplayCapabilities(unsigned capabilityFlags)
+{
+ m_flags = capabilityFlags;
+}
bool VRDisplayCapabilities::hasPosition() const
{
- return false;
+ return m_flags & VRDisplayCapabilityFlags::Position;
}
bool VRDisplayCapabilities::hasOrientation() const
{
- return false;
+ return m_flags & VRDisplayCapabilityFlags::Orientation;
}
bool VRDisplayCapabilities::hasExternalDisplay() const
{
- return false;
+ return m_flags & VRDisplayCapabilityFlags::ExternalDisplay;
}
bool VRDisplayCapabilities::canPresent() const
{
- return false;
+ return m_flags & VRDisplayCapabilityFlags::Present;
}
unsigned VRDisplayCapabilities::maxLayer() const
{
- return 0;
+ return canPresent() ? 1 : 0;
}
} // namespace WebCore
Modified: trunk/Source/WebCore/Modules/webvr/VRDisplayCapabilities.h (228661 => 228662)
--- trunk/Source/WebCore/Modules/webvr/VRDisplayCapabilities.h 2018-02-19 12:10:16 UTC (rev 228661)
+++ trunk/Source/WebCore/Modules/webvr/VRDisplayCapabilities.h 2018-02-19 13:16:13 UTC (rev 228662)
@@ -32,9 +32,9 @@
class VRDisplayCapabilities : public RefCounted<VRDisplayCapabilities> {
public:
- static Ref<VRDisplayCapabilities> create()
+ static Ref<VRDisplayCapabilities> create(unsigned capabilityFlags)
{
- return adoptRef(*new VRDisplayCapabilities);
+ return adoptRef(*new VRDisplayCapabilities(capabilityFlags));
}
bool hasPosition() const;
@@ -44,7 +44,9 @@
unsigned maxLayer() const;
private:
- VRDisplayCapabilities();
+ VRDisplayCapabilities(unsigned capabilityFlags);
+
+ unsigned m_flags;
};
} // namespace WebCore
Modified: trunk/Source/WebCore/Sources.txt (228661 => 228662)
--- trunk/Source/WebCore/Sources.txt 2018-02-19 12:10:16 UTC (rev 228661)
+++ trunk/Source/WebCore/Sources.txt 2018-02-19 13:16:13 UTC (rev 228662)
@@ -1755,6 +1755,10 @@
platform/text/TextEncodingDetectorICU.cpp
platform/text/TextEncodingRegistry.cpp
+platform/vr/VRManager.cpp
+platform/vr/openvr/VRPlatformDisplayOpenVR.cpp
+platform/vr/openvr/VRPlatformManagerOpenVR.cpp
+
plugins/DOMMimeType.cpp
plugins/DOMMimeTypeArray.cpp
plugins/DOMPlugin.cpp
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (228661 => 228662)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2018-02-19 12:10:16 UTC (rev 228661)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2018-02-19 13:16:13 UTC (rev 228662)
@@ -4514,6 +4514,9 @@
E180811716FCF9CB00B80D07 /* SynchronousLoaderClient.h in Headers */ = {isa = PBXBuildFile; fileRef = E180811516FCF9CB00B80D07 /* SynchronousLoaderClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
E18256900EF2B02D00933242 /* JSWorkerGlobalScope.h in Headers */ = {isa = PBXBuildFile; fileRef = E182568E0EF2B02D00933242 /* JSWorkerGlobalScope.h */; };
E18536841F4E481400FE091B /* WebArchiveResourceFromNSAttributedString.h in Headers */ = {isa = PBXBuildFile; fileRef = E18536811F4E472700FE091B /* WebArchiveResourceFromNSAttributedString.h */; };
+ E18823642031F57100B42DF3 /* VRManager.h in Headers */ = {isa = PBXBuildFile; fileRef = E18823632031F55D00B42DF3 /* VRManager.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ E18823652031F57F00B42DF3 /* VRPlatformDisplay.h in Headers */ = {isa = PBXBuildFile; fileRef = E18823602031F55A00B42DF3 /* VRPlatformDisplay.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ E18823662031F59400B42DF3 /* VRPlatformManager.h in Headers */ = {isa = PBXBuildFile; fileRef = E18823612031F55B00B42DF3 /* VRPlatformManager.h */; settings = {ATTRIBUTES = (Private, ); }; };
E18C35441F71970C00FF632D /* WebArchiveResourceWebResourceHandler.h in Headers */ = {isa = PBXBuildFile; fileRef = E18C35411F7196CD00FF632D /* WebArchiveResourceWebResourceHandler.h */; };
E18DF33518AAF12C00773E59 /* SerializedCryptoKeyWrap.h in Headers */ = {isa = PBXBuildFile; fileRef = E18DF33418AAF12C00773E59 /* SerializedCryptoKeyWrap.h */; settings = {ATTRIBUTES = (Private, ); }; };
E19727161820549E00592D51 /* CryptoKeyType.h in Headers */ = {isa = PBXBuildFile; fileRef = E19727151820549E00592D51 /* CryptoKeyType.h */; };
@@ -13870,6 +13873,10 @@
E18258AB0EF3CD7000933242 /* JSWorkerGlobalScopeCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSWorkerGlobalScopeCustom.cpp; sourceTree = "<group>"; };
E18536811F4E472700FE091B /* WebArchiveResourceFromNSAttributedString.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebArchiveResourceFromNSAttributedString.h; sourceTree = "<group>"; };
E18536821F4E472700FE091B /* WebArchiveResourceFromNSAttributedString.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = WebArchiveResourceFromNSAttributedString.mm; sourceTree = "<group>"; };
+ E18823602031F55A00B42DF3 /* VRPlatformDisplay.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VRPlatformDisplay.h; sourceTree = "<group>"; };
+ E18823612031F55B00B42DF3 /* VRPlatformManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VRPlatformManager.h; sourceTree = "<group>"; };
+ E18823622031F55C00B42DF3 /* VRManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = VRManager.cpp; sourceTree = "<group>"; };
+ E18823632031F55D00B42DF3 /* VRManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VRManager.h; sourceTree = "<group>"; };
E18C35411F7196CD00FF632D /* WebArchiveResourceWebResourceHandler.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebArchiveResourceWebResourceHandler.h; sourceTree = "<group>"; };
E18C35421F71970100FF632D /* WebArchiveResourceWebResourceHandler.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = WebArchiveResourceWebResourceHandler.mm; sourceTree = "<group>"; };
E18DF33418AAF12C00773E59 /* SerializedCryptoKeyWrap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SerializedCryptoKeyWrap.h; sourceTree = "<group>"; };
@@ -23839,6 +23846,7 @@
516030090CC4245400C8AC25 /* posix */,
1A2E6E560CC551E0004A2062 /* sql */,
B2C3D9EC0D006C1D00EF6F26 /* text */,
+ E188235F2031F50F00B42DF3 /* vr */,
49AE2D94134EE5F90072920A /* CalculationValue.cpp */,
49AE2D95134EE5F90072920A /* CalculationValue.h */,
C330A22113EC196B0000B45B /* ColorChooser.h */,
@@ -24483,6 +24491,17 @@
path = algorithms;
sourceTree = "<group>";
};
+ E188235F2031F50F00B42DF3 /* vr */ = {
+ isa = PBXGroup;
+ children = (
+ E18823622031F55C00B42DF3 /* VRManager.cpp */,
+ E18823632031F55D00B42DF3 /* VRManager.h */,
+ E18823602031F55A00B42DF3 /* VRPlatformDisplay.h */,
+ E18823612031F55B00B42DF3 /* VRPlatformManager.h */,
+ );
+ path = vr;
+ sourceTree = "<group>";
+ };
E19DA29D181995CE00088BC8 /* keys */ = {
isa = PBXGroup;
children = (
@@ -30159,6 +30178,9 @@
419BC2DF1685329900D64D6D /* VisitedLinkState.h in Headers */,
1ABA80001897341200DCE9D6 /* VisitedLinkStore.h in Headers */,
E44613B60CD6344E00FADA75 /* VoidCallback.h in Headers */,
+ E18823642031F57100B42DF3 /* VRManager.h in Headers */,
+ E18823652031F57F00B42DF3 /* VRPlatformDisplay.h in Headers */,
+ E18823662031F59400B42DF3 /* VRPlatformManager.h in Headers */,
BE20507A18A4586B0080647E /* VTTCue.h in Headers */,
7AF9B20318CFB2DF00C64BEF /* VTTRegion.h in Headers */,
7AF9B20618CFB2DF00C64BEF /* VTTRegionList.h in Headers */,
Added: trunk/Source/WebCore/platform/vr/VRManager.cpp (0 => 228662)
--- trunk/Source/WebCore/platform/vr/VRManager.cpp (rev 0)
+++ trunk/Source/WebCore/platform/vr/VRManager.cpp 2018-02-19 13:16:13 UTC (rev 228662)
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2017 Igalia, S.L. All right reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "config.h"
+#include "VRManager.h"
+
+#include "VRPlatformDisplay.h"
+#include "VRPlatformManager.h"
+
+#if USE(OPENVR)
+#include "VRPlatformManagerOpenVR.h"
+#endif
+
+namespace WebCore {
+
+VRManager& VRManager::singleton()
+{
+ static NeverDestroyed<VRManager> instance;
+ return instance;
+}
+
+VRManager::VRManager()
+{
+#if USE(OPENVR)
+ m_platformManager = VRPlatformManagerOpenVR::create();
+#endif
+}
+
+VRManager::~VRManager()
+{
+ m_platformManager = nullptr;
+}
+
+std::optional<VRManager::VRDisplaysVector> VRManager::getVRDisplays()
+{
+ if (!m_platformManager)
+ return std::nullopt;
+
+ return m_platformManager->getVRDisplays();
+}
+
+}; // namespace WebCore
Property changes on: trunk/Source/WebCore/platform/vr/VRManager.cpp
___________________________________________________________________
Added: svn:eol-style
+LF
\ No newline at end of property
Added: trunk/Source/WebCore/platform/vr/VRManager.h (0 => 228662)
--- trunk/Source/WebCore/platform/vr/VRManager.h (rev 0)
+++ trunk/Source/WebCore/platform/vr/VRManager.h 2018-02-19 13:16:13 UTC (rev 228662)
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2017 Igalia, S.L. All right reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#pragma once
+
+#include <wtf/NeverDestroyed.h>
+#include <wtf/Vector.h>
+#include <wtf/WeakPtr.h>
+
+namespace WebCore {
+
+class VRPlatformDisplay;
+class VRPlatformManager;
+
+class VRManager final {
+ friend class WTF::NeverDestroyed<VRManager>;
+public:
+ using VRDisplaysVector = Vector<WeakPtr<VRPlatformDisplay>>;
+
+ ~VRManager();
+
+ WEBCORE_EXPORT static VRManager& singleton();
+
+ std::optional<VRDisplaysVector> getVRDisplays();
+
+private:
+ VRManager();
+
+ std::unique_ptr<VRPlatformManager> m_platformManager;
+};
+
+}; // namespace WebCore
Property changes on: trunk/Source/WebCore/platform/vr/VRManager.h
___________________________________________________________________
Added: svn:eol-style
+LF
\ No newline at end of property
Added: trunk/Source/WebCore/platform/vr/VRPlatformDisplay.h (0 => 228662)
--- trunk/Source/WebCore/platform/vr/VRPlatformDisplay.h (rev 0)
+++ trunk/Source/WebCore/platform/vr/VRPlatformDisplay.h 2018-02-19 13:16:13 UTC (rev 228662)
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2018 Igalia, S.L. All right reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#pragma once
+
+#include <wtf/WeakPtr.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+
+enum VRDisplayCapabilityFlags {
+ None = 0,
+ Position = 1 << 1,
+ Orientation = 1 << 2,
+ ExternalDisplay = 1 << 3,
+ Present = 1 << 4
+};
+
+/* The purpose of this class is to encapsulate all the info about the display in a single class/data
+ * structure. This way we wouldn't have to replicate all the API calls of VRDisplay in
+ * VRPlatformDisplay. Also the client of this API would only have to issue a single call to get all
+ * 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;
+};
+
+class VRPlatformDisplay {
+public:
+ virtual VRPlatformDisplayInfo getDisplayInfo() = 0;
+ virtual ~VRPlatformDisplay() = default;
+
+ WeakPtr<VRPlatformDisplay> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(*this); }
+private:
+ WeakPtrFactory<VRPlatformDisplay> m_weakPtrFactory;
+};
+
+}; // namespace WebCore
Property changes on: trunk/Source/WebCore/platform/vr/VRPlatformDisplay.h
___________________________________________________________________
Added: svn:eol-style
+LF
\ No newline at end of property
Added: trunk/Source/WebCore/platform/vr/VRPlatformManager.h (0 => 228662)
--- trunk/Source/WebCore/platform/vr/VRPlatformManager.h (rev 0)
+++ trunk/Source/WebCore/platform/vr/VRPlatformManager.h 2018-02-19 13:16:13 UTC (rev 228662)
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2017 Igalia, S.L. All right reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#pragma once
+
+#include "VRPlatformDisplay.h"
+
+namespace WebCore {
+
+class VRDisplay;
+
+class VRPlatformManager {
+public:
+ virtual Vector<WeakPtr<VRPlatformDisplay>> getVRDisplays() = 0;
+ virtual ~VRPlatformManager() = default;
+};
+
+}; // namespace WebCore
Property changes on: trunk/Source/WebCore/platform/vr/VRPlatformManager.h
___________________________________________________________________
Added: svn:eol-style
+LF
\ No newline at end of property
Added: trunk/Source/WebCore/platform/vr/openvr/VRPlatformDisplayOpenVR.cpp (0 => 228662)
--- trunk/Source/WebCore/platform/vr/openvr/VRPlatformDisplayOpenVR.cpp (rev 0)
+++ trunk/Source/WebCore/platform/vr/openvr/VRPlatformDisplayOpenVR.cpp 2018-02-19 13:16:13 UTC (rev 228662)
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2018 Igalia, S.L. All right reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "config.h"
+#include "VRPlatformDisplayOpenVR.h"
+
+#if USE(OPENVR)
+
+#include <wtf/text/StringBuilder.h>
+
+namespace WebCore {
+
+VRPlatformDisplayOpenVR::VRPlatformDisplayOpenVR(vr::IVRSystem* system, vr::IVRChaperone* chaperone, vr::IVRCompositor* compositor)
+ : m_system(system)
+ , m_chaperone(chaperone)
+ , m_compositor(compositor)
+{
+ m_displayInfo.isConnected = m_system->IsTrackedDeviceConnected(vr::k_unTrackedDeviceIndex_Hmd);
+
+ StringBuilder stringBuilder;
+ stringBuilder.appendLiteral("OpenVR HMD");
+ char HMDName[128];
+ if (auto length = m_system->GetStringTrackedDeviceProperty(vr::k_unTrackedDeviceIndex_Hmd, vr::Prop_ManufacturerName_String, HMDName, 128)) {
+ stringBuilder.append(" (");
+ stringBuilder.append(HMDName, length);
+ stringBuilder.append(')');
+ }
+ m_displayInfo.displayName = stringBuilder.toString();
+
+ m_displayInfo.isMounted = 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;
+}
+
+}; // namespace WebCore
+
+#endif // USE(OPENVR)
Property changes on: trunk/Source/WebCore/platform/vr/openvr/VRPlatformDisplayOpenVR.cpp
___________________________________________________________________
Added: svn:eol-style
+LF
\ No newline at end of property
Added: trunk/Source/WebCore/platform/vr/openvr/VRPlatformDisplayOpenVR.h (0 => 228662)
--- trunk/Source/WebCore/platform/vr/openvr/VRPlatformDisplayOpenVR.h (rev 0)
+++ trunk/Source/WebCore/platform/vr/openvr/VRPlatformDisplayOpenVR.h 2018-02-19 13:16:13 UTC (rev 228662)
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2017 Igalia, S.L. All right reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#pragma once
+
+#if USE(OPENVR)
+
+#include "VRPlatformDisplay.h"
+
+#include <openvr.h>
+
+namespace WebCore {
+
+class VRPlatformDisplayOpenVR : public VRPlatformDisplay {
+public:
+ explicit VRPlatformDisplayOpenVR(vr::IVRSystem*, vr::IVRChaperone*, vr::IVRCompositor*);
+
+ VRPlatformDisplayInfo getDisplayInfo() override { return m_displayInfo; }
+
+private:
+ vr::IVRSystem* m_system;
+ vr::IVRChaperone* m_chaperone;
+ vr::IVRCompositor* m_compositor;
+
+ VRPlatformDisplayInfo m_displayInfo;
+};
+
+}; // namespace WebCore
+
+#endif // USE(OPENVR)
Property changes on: trunk/Source/WebCore/platform/vr/openvr/VRPlatformDisplayOpenVR.h
___________________________________________________________________
Added: svn:eol-style
+LF
\ No newline at end of property
Added: trunk/Source/WebCore/platform/vr/openvr/VRPlatformManagerOpenVR.cpp (0 => 228662)
--- trunk/Source/WebCore/platform/vr/openvr/VRPlatformManagerOpenVR.cpp (rev 0)
+++ trunk/Source/WebCore/platform/vr/openvr/VRPlatformManagerOpenVR.cpp 2018-02-19 13:16:13 UTC (rev 228662)
@@ -0,0 +1,88 @@
+/*
+ * Copyright (C) 2017 Igalia, S.L. All right reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "config.h"
+#include "VRPlatformManagerOpenVR.h"
+
+#include "VRPlatformDisplayOpenVR.h"
+
+#if USE(OPENVR)
+
+#include "JSVRDisplay.h"
+#include "VRDisplay.h"
+
+namespace WebCore {
+
+std::unique_ptr<VRPlatformManagerOpenVR> VRPlatformManagerOpenVR::create()
+{
+ if (!vr::VR_IsRuntimeInstalled())
+ return nullptr;
+
+ return std::make_unique<VRPlatformManagerOpenVR>();
+}
+
+VRPlatformManagerOpenVR::~VRPlatformManagerOpenVR()
+{
+ vr::VR_Shutdown();
+}
+
+bool VRPlatformManagerOpenVR::initOpenVR()
+{
+ vr::HmdError error;
+ m_system = vr::VR_Init(&error, vr::VRApplication_Scene);
+ if (error)
+ return false;
+
+ return true;
+}
+
+Vector<WeakPtr<VRPlatformDisplay>> VRPlatformManagerOpenVR::getVRDisplays()
+{
+ // Quickly check for HMDs. Much faster than initializing the whole OpenVR API.
+ if (!vr::VR_IsHmdPresent()) {
+ m_system = nullptr;
+ return { };
+ }
+
+ if (!m_system && !initOpenVR()) {
+ m_system = nullptr;
+ vr::VR_Shutdown();
+ return { };
+ }
+
+ vr::HmdError error;
+ vr::IVRChaperone* chaperone = static_cast<vr::IVRChaperone*>(vr::VR_GetGenericInterface(vr::IVRChaperone_Version, &error));
+ if (error || !chaperone)
+ return { };
+
+ vr::IVRCompositor* compositor = static_cast<vr::IVRCompositor*>(vr::VR_GetGenericInterface(vr::IVRCompositor_Version, &error));
+ if (error || !compositor)
+ return { };
+
+ Vector<WeakPtr<VRPlatformDisplay>> displays;
+ if (!m_display)
+ m_display = std::make_unique<VRPlatformDisplayOpenVR>(m_system, chaperone, compositor);
+ displays.append(m_display->createWeakPtr());
+ return displays;
+}
+
+}; // namespace WebCore
+
+#endif // USE(OPENVR)
Property changes on: trunk/Source/WebCore/platform/vr/openvr/VRPlatformManagerOpenVR.cpp
___________________________________________________________________
Added: svn:eol-style
+LF
\ No newline at end of property
Added: trunk/Source/WebCore/platform/vr/openvr/VRPlatformManagerOpenVR.h (0 => 228662)
--- trunk/Source/WebCore/platform/vr/openvr/VRPlatformManagerOpenVR.h (rev 0)
+++ trunk/Source/WebCore/platform/vr/openvr/VRPlatformManagerOpenVR.h 2018-02-19 13:16:13 UTC (rev 228662)
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2017 Igalia, S.L. All right reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#pragma once
+
+#if USE(OPENVR)
+
+#include "VRPlatformManager.h"
+
+#include <openvr.h>
+
+namespace WebCore {
+
+class VRPlatformDisplayOpenVR;
+
+class VRPlatformManagerOpenVR : public VRPlatformManager {
+public:
+ static std::unique_ptr<VRPlatformManagerOpenVR> create();
+ explicit VRPlatformManagerOpenVR() = default;
+
+ Vector<WeakPtr<VRPlatformDisplay>> getVRDisplays() override;
+
+ ~VRPlatformManagerOpenVR();
+private:
+ bool initOpenVR();
+
+ vr::IVRSystem* m_system { nullptr };
+ std::unique_ptr<VRPlatformDisplayOpenVR> m_display;
+};
+
+}; // namespace WebCore
+
+#endif // USE(OPENVR)
Property changes on: trunk/Source/WebCore/platform/vr/openvr/VRPlatformManagerOpenVR.h
___________________________________________________________________
Added: svn:eol-style
+LF
\ No newline at end of property