WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Patch
bug-212470-20200528180511.patch (text/plain), 37.67 KB, created by
Sergio Villar Senin
on 2020-05-28 09:05:13 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Sergio Villar Senin
Created:
2020-05-28 09:05:13 PDT
Size:
37.67 KB
patch
obsolete
>Subversion Revision: 262243 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 41f0e981076d8c22eaa02742554dbb6de145c205..d36e67e6aab1e0e020d31585b02bd961eda79b02 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,37 @@ >+2020-05-28 Sergio Villar Senin <svillar@igalia.com> >+ >+ [WebXR] Refactor OpenXR platform code >+ https://bugs.webkit.org/show_bug.cgi?id=212470 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Refactored a bit the platform code because we want to extend the PlatformXR::Device for the OpenXR >+ library. Also we're removing all the device id code because there is no need to expose it, we only >+ needed it to compare Devices. We can do the same by virtualizing the operator== and at the same time >+ we hide the implementation of device ids which are opaque atoms in the case of OpenXR for example. >+ >+ The idea from now on is to only define interfaces in PlatformXR.h and then add all the OpenXR specifics >+ in the newly renamed PlatformXROpenXR.[ch] files. >+ >+ We're also renaming PlatformXR.cpp to PlatformXROpenXR.cpp to clearly state that it's the OpenXR >+ implementation and to differentiate it from the implementation agnostic PlatformXR.h file. >+ >+ No new tests as there is no change in functionality. >+ >+ * Modules/webxr/WebXRSystem.cpp: >+ (WebCore::WebXRSystem::DummyInlineDevice::operator== const): Make it virtual. >+ * Modules/webxr/WebXRSystem.h: >+ * Sources.txt: Added renamed files. Removed PlatformXR.cpp. >+ * WebCore.xcodeproj/project.pbxproj: Ditto. >+ * platform/xr/PlatformXR.cpp: Removed. >+ * platform/xr/PlatformXR.h: >+ (PlatformXR::Device::id const): Deleted. >+ (PlatformXR::Device::operator== const): Deleted. >+ * platform/xr/openxr/PlatformXROpenXR.cpp: Renamed from Source/WebCore/platform/xr/openxr/PlatformXR.cpp. >+ (PlatformXR::Instance::enumerateImmersiveXRDevices): Create an OpenXRDevice instead of a Device. >+ * platform/xr/openxr/PlatformXROpenXR.h: Added. >+ * testing/WebFakeXRDevice.h: Add implementation for operator==. >+ > 2020-05-27 Simon Fraser <simon.fraser@apple.com> > > ScrollingTreeMac::eventListenerRegionTypesForPoint() needs to convert the point to local coordinates >diff --git a/Source/WebCore/Modules/webxr/WebXRSystem.cpp b/Source/WebCore/Modules/webxr/WebXRSystem.cpp >index f88e274970a81f539c91bbc00d777d48793e9c23..72a195f31c072cf8b410a938a717ff4ebdb2b750 100644 >--- a/Source/WebCore/Modules/webxr/WebXRSystem.cpp >+++ b/Source/WebCore/Modules/webxr/WebXRSystem.cpp >@@ -54,6 +54,12 @@ WebXRSystem::DummyInlineDevice::DummyInlineDevice() > setEnabledFeatures(XRSessionMode::Inline, { XRReferenceSpaceType::Viewer }); > } > >+bool WebXRSystem::DummyInlineDevice::operator==(const Device& other) const >+{ >+ // There musn't be another dummy inline device >+ return this == &other ? true : false; >+} >+ > Ref<WebXRSystem> WebXRSystem::create(ScriptExecutionContext& scriptExecutionContext) > { > return adoptRef(*new WebXRSystem(scriptExecutionContext)); >diff --git a/Source/WebCore/Modules/webxr/WebXRSystem.h b/Source/WebCore/Modules/webxr/WebXRSystem.h >index 9aad128b56e6bfc97d3b4fd20609707f25d26a5e..a9d60c9cd39ef35df9b4897311b4dde95683f9c5 100644 >--- a/Source/WebCore/Modules/webxr/WebXRSystem.h >+++ b/Source/WebCore/Modules/webxr/WebXRSystem.h >@@ -107,6 +107,7 @@ private: > class DummyInlineDevice final : public PlatformXR::Device { > public: > DummyInlineDevice(); >+ bool operator==(const Device& other) const final; > }; > DummyInlineDevice m_defaultInlineDevice; > >diff --git a/Source/WebCore/Sources.txt b/Source/WebCore/Sources.txt >index 47622b95c250dbfdb5f60c23f903342c049fac3b..8d61164bd0cedf946713b7a97a6731281e2709df 100644 >--- a/Source/WebCore/Sources.txt >+++ b/Source/WebCore/Sources.txt >@@ -2118,8 +2118,7 @@ platform/text/TextEncoding.cpp > platform/text/TextEncodingDetectorICU.cpp > platform/text/TextEncodingRegistry.cpp > >-platform/xr/PlatformXR.cpp @no-unify >-platform/xr/openxr/PlatformXR.cpp @no-unify >+platform/xr/openxr/PlatformXROpenXR.cpp @no-unify > > plugins/DOMMimeType.cpp > plugins/DOMMimeTypeArray.cpp >diff --git a/Source/WebCore/WebCore.xcodeproj/project.pbxproj b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >index ff6985b16c7dd84fa0e840a13616a73a20ff0cbd..82d65ecdbc56dd39359d8a205df4cb82df96fa00 100644 >--- a/Source/WebCore/WebCore.xcodeproj/project.pbxproj >+++ b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >@@ -4825,6 +4825,8 @@ > E1BA671A1742BEF400C20251 /* WebCoreTestShimLibrary.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1BA67191742BEF400C20251 /* WebCoreTestShimLibrary.cpp */; }; > E1BD331A182D8DDD00C05D9F /* CryptoAlgorithmRSASSA_PKCS1_v1_5.h in Headers */ = {isa = PBXBuildFile; fileRef = E1BD3318182D8DDD00C05D9F /* CryptoAlgorithmRSASSA_PKCS1_v1_5.h */; }; > E1BE512E0CF6C512002EA959 /* XSLTUnicodeSort.h in Headers */ = {isa = PBXBuildFile; fileRef = E1BE512C0CF6C512002EA959 /* XSLTUnicodeSort.h */; }; >+ E1C1A39D2480080800E0AF66 /* PlatformXROpenXR.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1C1A39B2480080600E0AF66 /* PlatformXROpenXR.cpp */; }; >+ E1C1A39E2480080800E0AF66 /* PlatformXROpenXR.h in Headers */ = {isa = PBXBuildFile; fileRef = E1C1A39C2480080700E0AF66 /* PlatformXROpenXR.h */; }; > E1C266DF18319F31003F8B33 /* CryptoKeyRSAComponents.h in Headers */ = {isa = PBXBuildFile; fileRef = E1C266DD18319F31003F8B33 /* CryptoKeyRSAComponents.h */; }; > E1C362EF0EAF2AA9007410BC /* JSWorkerLocation.h in Headers */ = {isa = PBXBuildFile; fileRef = E1C362ED0EAF2AA9007410BC /* JSWorkerLocation.h */; }; > E1C36C030EB076D6007410BC /* JSDOMGlobalObject.h in Headers */ = {isa = PBXBuildFile; fileRef = E1C36C020EB076D6007410BC /* JSDOMGlobalObject.h */; settings = {ATTRIBUTES = (Private, ); }; }; >@@ -4841,8 +4843,6 @@ > E1E6EEA80B628DB3005F2F70 /* JSHTMLSelectElement.h in Headers */ = {isa = PBXBuildFile; fileRef = E1E6EEA70B628DB3005F2F70 /* JSHTMLSelectElement.h */; }; > E1EC29A00BB04C6B00EA187B /* XPathNodeSet.h in Headers */ = {isa = PBXBuildFile; fileRef = E1EC299E0BB04C6B00EA187B /* XPathNodeSet.h */; settings = {ATTRIBUTES = (Private, ); }; }; > E1ED8AC30CC49BE000BFC557 /* CSSPrimitiveValueMappings.h in Headers */ = {isa = PBXBuildFile; fileRef = E1ED8AC20CC49BE000BFC557 /* CSSPrimitiveValueMappings.h */; settings = {ATTRIBUTES = (Private, ); }; }; >- E1EE8B702412B2A800E794D6 /* PlatformXR.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1EE8B6C2412B2A700E794D6 /* PlatformXR.cpp */; }; >- E1EE8B712412B2A800E794D6 /* PlatformXR.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1EE8B6E2412B2A700E794D6 /* PlatformXR.cpp */; }; > E1EE8B722412B2A800E794D6 /* PlatformXR.h in Headers */ = {isa = PBXBuildFile; fileRef = E1EE8B6F2412B2A700E794D6 /* PlatformXR.h */; }; > E1EE8B762413191F00E794D6 /* WebXRViewerPose.h in Headers */ = {isa = PBXBuildFile; fileRef = E1EE8AC72412B16F00E794D6 /* WebXRViewerPose.h */; }; > E1EE8B772413191F00E794D6 /* XRReferenceSpaceType.h in Headers */ = {isa = PBXBuildFile; fileRef = E1EE8AC92412B17000E794D6 /* XRReferenceSpaceType.h */; }; >@@ -15310,6 +15310,8 @@ > E1BD3318182D8DDD00C05D9F /* CryptoAlgorithmRSASSA_PKCS1_v1_5.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CryptoAlgorithmRSASSA_PKCS1_v1_5.h; sourceTree = "<group>"; }; > E1BE512B0CF6C512002EA959 /* XSLTUnicodeSort.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = XSLTUnicodeSort.cpp; sourceTree = "<group>"; }; > E1BE512C0CF6C512002EA959 /* XSLTUnicodeSort.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XSLTUnicodeSort.h; sourceTree = "<group>"; }; >+ E1C1A39B2480080600E0AF66 /* PlatformXROpenXR.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PlatformXROpenXR.cpp; sourceTree = "<group>"; }; >+ E1C1A39C2480080700E0AF66 /* PlatformXROpenXR.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlatformXROpenXR.h; sourceTree = "<group>"; }; > E1C266D618317AB4003F8B33 /* CryptoAlgorithmRSASSA_PKCS1_v1_5Mac.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CryptoAlgorithmRSASSA_PKCS1_v1_5Mac.cpp; sourceTree = "<group>"; }; > E1C266DC18319F31003F8B33 /* CryptoKeyRSAComponents.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CryptoKeyRSAComponents.cpp; sourceTree = "<group>"; }; > E1C266DD18319F31003F8B33 /* CryptoKeyRSAComponents.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CryptoKeyRSAComponents.h; sourceTree = "<group>"; }; >@@ -15422,8 +15424,6 @@ > E1EE8B162412B17000E794D6 /* XRPose.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = XRPose.idl; sourceTree = "<group>"; }; > E1EE8B172412B17000E794D6 /* WebXRInputSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebXRInputSource.h; sourceTree = "<group>"; }; > E1EE8B182412B17000E794D6 /* XRInputSourceArray.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = XRInputSourceArray.idl; sourceTree = "<group>"; }; >- E1EE8B6C2412B2A700E794D6 /* PlatformXR.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PlatformXR.cpp; sourceTree = "<group>"; }; >- E1EE8B6E2412B2A700E794D6 /* PlatformXR.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PlatformXR.cpp; sourceTree = "<group>"; }; > E1EE8B6F2412B2A700E794D6 /* PlatformXR.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlatformXR.h; sourceTree = "<group>"; }; > E1F1E82D0C3C2BB9006DB391 /* XSLTExtensions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = XSLTExtensions.cpp; sourceTree = "<group>"; }; > E1F1E82E0C3C2BB9006DB391 /* XSLTExtensions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XSLTExtensions.h; sourceTree = "<group>"; }; >@@ -27539,7 +27539,6 @@ > isa = PBXGroup; > children = ( > E1EE8B6D2412B2A700E794D6 /* openxr */, >- E1EE8B6C2412B2A700E794D6 /* PlatformXR.cpp */, > E1EE8B6F2412B2A700E794D6 /* PlatformXR.h */, > ); > path = xr; >@@ -27548,7 +27547,8 @@ > E1EE8B6D2412B2A700E794D6 /* openxr */ = { > isa = PBXGroup; > children = ( >- E1EE8B6E2412B2A700E794D6 /* PlatformXR.cpp */, >+ E1C1A39B2480080600E0AF66 /* PlatformXROpenXR.cpp */, >+ E1C1A39C2480080700E0AF66 /* PlatformXROpenXR.h */, > ); > path = openxr; > sourceTree = "<group>"; >@@ -29970,6 +29970,7 @@ > C330A22313EC196B0000B45B /* ColorChooser.h in Headers */, > C37CDEBD149EF2030042090D /* ColorChooserClient.h in Headers */, > F48D2AA52159740D00C6752B /* ColorCocoa.h in Headers */, >+ 7CAC6AF0247F411000E61D59 /* ColorComponents.h in Headers */, > 3103B7DF1DB01567008BB890 /* ColorHash.h in Headers */, > F55B3DB41251F12D003EF269 /* ColorInputType.h in Headers */, > CE5169E721F1B84700EA4F78 /* ColorIOS.h in Headers */, >@@ -32484,6 +32485,7 @@ > 52B0D4BE1C57FD1E0077CE53 /* PlatformView.h in Headers */, > 935C476B09AC4D4F00A6AAB4 /* PlatformWheelEvent.h in Headers */, > E1EE8B722412B2A800E794D6 /* PlatformXR.h in Headers */, >+ E1C1A39E2480080800E0AF66 /* PlatformXROpenXR.h in Headers */, > 712BE4801FE864A7002031CC /* PlaybackDirection.h in Headers */, > CDA29A321CC01A9500901CCF /* PlaybackSessionInterfaceAVKit.h in Headers */, > CDA29A171CBDA56C00901CCF /* PlaybackSessionInterfaceMac.h in Headers */, >@@ -32800,7 +32802,6 @@ > A5071E871C56D0E1009951BE /* ResourceUsageThread.h in Headers */, > 418938B22429F9B4007FDC41 /* RetrieveRecordsOptions.h in Headers */, > FD3160A512B026F700C1A359 /* Reverb.h in Headers */, >- 7CAC6AF0247F411000E61D59 /* ColorComponents.h in Headers */, > FD3160A712B026F700C1A359 /* ReverbAccumulationBuffer.h in Headers */, > FD3160A912B026F700C1A359 /* ReverbConvolver.h in Headers */, > FD3160AB12B026F700C1A359 /* ReverbConvolverStage.h in Headers */, >@@ -34390,8 +34391,7 @@ > E16982601134636A00894115 /* ObjCRuntimeObject.mm in Sources */, > CEA284662141E84900E407E8 /* PlatformEventFactoryIOS.mm in Sources */, > AA12DF491743DF83004DAFDF /* PlatformSpeechSynthesizerIOS.mm in Sources */, >- E1EE8B712412B2A800E794D6 /* PlatformXR.cpp in Sources */, >- E1EE8B702412B2A800E794D6 /* PlatformXR.cpp in Sources */, >+ E1C1A39D2480080800E0AF66 /* PlatformXROpenXR.cpp in Sources */, > CDA29A301CBF74D400901CCF /* PlaybackSessionInterfaceAVKit.mm in Sources */, > CDA29A161CBDA56C00901CCF /* PlaybackSessionInterfaceMac.mm in Sources */, > 419242492127B93E00634FCF /* RealtimeOutgoingVideoSourceCocoa.mm in Sources */, >diff --git a/Source/WebCore/platform/xr/PlatformXR.cpp b/Source/WebCore/platform/xr/PlatformXR.cpp >deleted file mode 100644 >index 8c98cc5e3041d70cd4cc4588a23b90c36705ab4b..0000000000000000000000000000000000000000 >--- a/Source/WebCore/platform/xr/PlatformXR.cpp >+++ /dev/null >@@ -1,40 +0,0 @@ >-/* >- * Copyright (C) 2020 Igalia, S.L. >- * >- * 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 >- * aint 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 "PlatformXR.h" >- >-namespace PlatformXR { >- >-#if ENABLE(WEBXR) >- >-Device::DeviceId Instance::nextDeviceId() >-{ >- static Device::DeviceId s_nextDeviceId { 0 }; >- return s_nextDeviceId++; >-} >- >-Device::Device() >- : m_id(Instance::nextDeviceId()) >-{ >-} >- >-#endif // ENABLE(WEBXR) >- >-} // namespace PlatformXR >diff --git a/Source/WebCore/platform/xr/PlatformXR.h b/Source/WebCore/platform/xr/PlatformXR.h >index 0b0413bcb587b9f14ab340cda4e49e9b06e94f5d..244c807c82c609136cc1ba97986af8f4e5f8b226 100644 >--- a/Source/WebCore/platform/xr/PlatformXR.h >+++ b/Source/WebCore/platform/xr/PlatformXR.h >@@ -45,34 +45,29 @@ class Device : public CanMakeWeakPtr<Device> { > WTF_MAKE_FAST_ALLOCATED; > WTF_MAKE_NONCOPYABLE(Device); > public: >- using DeviceId = uint32_t; >- Device(); >- DeviceId id() const { return m_id; } >+ virtual ~Device() = default; > > using ListOfEnabledFeatures = Vector<ReferenceSpaceType>; > bool supports(SessionMode mode) const { return m_enabledFeaturesMap.contains(mode); } > void setEnabledFeatures(SessionMode mode, const ListOfEnabledFeatures& features) { m_enabledFeaturesMap.set(mode, features); } > ListOfEnabledFeatures enabledFeatures(SessionMode mode) const { return m_enabledFeaturesMap.get(mode); } > >- inline bool operator==(const Device& other) const { return m_id == other.m_id; } >+ virtual bool operator==(const Device& other) const = 0; > > protected: >+ Device() = default; >+ > // https://immersive-web.github.io/webxr/#xr-device-concept > // Each XR device has a list of enabled features for each XRSessionMode in its list of supported modes, > // which is a list of feature descriptors which MUST be initially an empty list. > using EnabledFeaturesPerModeMap = WTF::HashMap<SessionMode, ListOfEnabledFeatures, WTF::IntHash<SessionMode>, WTF::StrongEnumHashTraits<SessionMode>>; > EnabledFeaturesPerModeMap m_enabledFeaturesMap; >- >-private: >- DeviceId m_id; > }; > > class Instance { > public: > static Instance& singleton(); > >- static Device::DeviceId nextDeviceId(); >- > void enumerateImmersiveXRDevices(); > const Vector<std::unique_ptr<Device>>& immersiveXRDevices() const { return m_immersiveXRDevices; } > private: >diff --git a/Source/WebCore/platform/xr/openxr/PlatformXR.cpp b/Source/WebCore/platform/xr/openxr/PlatformXR.cpp >deleted file mode 100644 >index 4a647050f97e863e56f25928b55ad9f629a2a8cd..0000000000000000000000000000000000000000 >--- a/Source/WebCore/platform/xr/openxr/PlatformXR.cpp >+++ /dev/null >@@ -1,236 +0,0 @@ >-/* >- * Copyright (C) 2020 Igalia, S.L. >- * >- * 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 >- * aint 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 "PlatformXR.h" >- >-#if ENABLE(WEBXR) >- >-#if USE_OPENXR >-#include <openxr/openxr.h> >-#include <wtf/Optional.h> >-#include <wtf/text/StringConcatenateNumbers.h> >-#include <wtf/text/WTFString.h> >-#endif // USE_OPENXR >-#include <wtf/NeverDestroyed.h> >- >-namespace PlatformXR { >- >-#if USE_OPENXR >- >-template<typename T, XrStructureType StructureType> >-T createStructure() >-{ >- T object; >- std::memset(&object, 0, sizeof(T)); >- object.type = StructureType; >- object.next = nullptr; >- return object; >-} >- >-String resultToString(XrResult value, XrInstance instance) >-{ >- char buffer[XR_MAX_RESULT_STRING_SIZE]; >- XrResult result = xrResultToString(instance, value, buffer); >- if (result == XR_SUCCESS) >- return String(buffer); >- return makeString("<unknown ", int(value), ">"); >-} >- >-#define RETURN_IF_FAILED(result, call, instance) \ >- if (XR_FAILED(result)) { \ >- WTFLogAlways("%s %s: %s\n", __func__, call, resultToString(result, instance).utf8().data()); \ >- return; \ >- } \ >- >-#endif // USE_OPENXR >- >-struct Instance::Impl { >- WTF_MAKE_FAST_ALLOCATED; >-public: >- Impl(); >- ~Impl(); >- >-#if USE_OPENXR >- Optional<Vector<SessionMode>> collectSupportedSessionModes(Device&, XrSystemId); >- XrInstance m_instance { XR_NULL_HANDLE }; >-#endif // USE_OPENXR >-}; >- >-Instance::Impl::Impl() >-{ >-#if USE_OPENXR >- WTFLogAlways("OpenXR: initializing\n"); >- >- [&] { >- uint32_t propertyCountOutput { 0 }; >- XrResult result = xrEnumerateApiLayerProperties(0, &propertyCountOutput, nullptr); >- RETURN_IF_FAILED(result, "xrEnumerateApiLayerProperties()", m_instance); >- >- if (!propertyCountOutput) { >- WTFLogAlways("xrEnumerateApiLayerProperties(): no properties\n"); >- return; >- } >- >- Vector<XrApiLayerProperties> properties(propertyCountOutput); >- result = xrEnumerateApiLayerProperties(propertyCountOutput, nullptr, properties.data()); >- RETURN_IF_FAILED(result, "xrEnumerateApiLayerProperties()", m_instance); >- >- WTFLogAlways("xrEnumerateApiLayerProperties(): %zu properties\n", properties.size()); >- }(); >- >- [&] { >- uint32_t propertyCountOutput { 0 }; >- XrResult result = xrEnumerateInstanceExtensionProperties(nullptr, 0, &propertyCountOutput, nullptr); >- RETURN_IF_FAILED(result, "xrEnumerateInstanceExtensionProperties()", m_instance); >- >- if (!propertyCountOutput) { >- WTFLogAlways("xrEnumerateInstanceExtensionProperties(): no properties\n"); >- return; >- } >- >- Vector<XrExtensionProperties> properties(propertyCountOutput, >- [] { >- XrExtensionProperties object; >- std::memset(&object, 0, sizeof(XrExtensionProperties)); >- object.type = XR_TYPE_EXTENSION_PROPERTIES; >- return object; >- }()); >- uint32_t propertyCountWritten { 0 }; >- result = xrEnumerateInstanceExtensionProperties(nullptr, propertyCountOutput, &propertyCountWritten, properties.data()); >- RETURN_IF_FAILED(result, "xrEnumerateInstanceExtensionProperties()", m_instance); >- >- WTFLogAlways("xrEnumerateInstanceExtensionProperties(): %zu extension properties\n", properties.size()); >- for (auto& property : properties) { >- WTFLogAlways(" extension '%s', version %u\n", >- property.extensionName, property.extensionVersion); >- } >- }(); >- >- static const char* s_applicationName = "WebXR (WebKit)"; >- static const uint32_t s_applicationVersion = 1; >- >- { >- auto createInfo = createStructure<XrInstanceCreateInfo, XR_TYPE_INSTANCE_CREATE_INFO>(); >- createInfo.createFlags = 0; >- std::memcpy(createInfo.applicationInfo.applicationName, s_applicationName, XR_MAX_APPLICATION_NAME_SIZE); >- createInfo.applicationInfo.apiVersion = XR_CURRENT_API_VERSION; >- createInfo.applicationInfo.applicationVersion = s_applicationVersion; >- createInfo.enabledApiLayerCount = 0; >- createInfo.enabledExtensionCount = 0; >- >- XrInstance instance; >- XrResult result = xrCreateInstance(&createInfo, &instance); >- RETURN_IF_FAILED(result, "xrCreateInstance()", m_instance); >- >- m_instance = instance; >- WTFLogAlways("xrCreateInstance(): using instance %p\n", m_instance); >- } >-#endif // USE_OPENXR >-} >- >-Instance::Impl::~Impl() >-{ >-} >- >-#if USE_OPENXR >- >-Optional<Vector<SessionMode>> Instance::Impl::collectSupportedSessionModes(Device& device, XrSystemId systemId) >-{ >- uint32_t viewConfigurationCount; >- XrResult result = xrEnumerateViewConfigurations(m_instance, systemId, 0, &viewConfigurationCount, nullptr); >- if (result != XR_SUCCESS) { >- WTFLogAlways("xrEnumerateViewConfigurations(): error %s\n", resultToString(result, m_instance).utf8().data()); >- return WTF::nullopt; >- } >- >- XrViewConfigurationType viewConfigurations[viewConfigurationCount]; >- result = xrEnumerateViewConfigurations(m_instance, systemId, viewConfigurationCount, &viewConfigurationCount, viewConfigurations); >- if (result != XR_SUCCESS) { >- WTFLogAlways("xrEnumerateViewConfigurations(): error %s\n", resultToString(result, m_instance).utf8().data()); >- WTFLogAlways("xrEnumerateViewConfigurations(): error %s\n", resultToString(result, m_instance).utf8().data()); >- return WTF::nullopt; >- } >- >- Vector<SessionMode> supportedModes; >- for (uint32_t i = 0; i < viewConfigurationCount; ++i) { >- auto viewConfigurationProperties = createStructure<XrViewConfigurationProperties, XR_TYPE_VIEW_CONFIGURATION_PROPERTIES>(); >- result = xrGetViewConfigurationProperties(m_instance, systemId, viewConfigurations[i], &viewConfigurationProperties); >- if (result != XR_SUCCESS) { >- WTFLogAlways("xrGetViewConfigurationProperties(): error %s\n", resultToString(result, m_instance).utf8().data()); >- return WTF::nullopt; >- } >- if (viewConfigurationProperties.viewConfigurationType == XR_VIEW_CONFIGURATION_TYPE_PRIMARY_MONO) >- supportedModes.append(SessionMode::ImmersiveAr); >- else if (viewConfigurationProperties.viewConfigurationType == XR_VIEW_CONFIGURATION_TYPE_PRIMARY_STEREO) >- supportedModes.append(SessionMode::ImmersiveVr); >- } >- return supportedModes; >-} >- >-#endif // USE_OPENXR >- >-Instance& Instance::singleton() >-{ >- static LazyNeverDestroyed<Instance> s_instance; >- static std::once_flag s_onceFlag; >- std::call_once(s_onceFlag, >- [&] { >- s_instance->m_impl = makeUnique<Impl>(); >- }); >- return s_instance.get(); >-} >- >-Instance::Instance() = default; >-Instance::~Instance() = default; >- >-void Instance::enumerateImmersiveXRDevices() >-{ >-#if USE_OPENXR >- if (m_impl->m_instance == XR_NULL_HANDLE) { >- WTFLogAlways("%s Unable to enumerate XR devices. No XrInstance present\n", __FUNCTION__); >- return; >- } >- >- auto systemGetInfo = createStructure<XrSystemGetInfo, XR_TYPE_SYSTEM_GET_INFO>(); >- systemGetInfo.formFactor = XR_FORM_FACTOR_HEAD_MOUNTED_DISPLAY; >- >- XrSystemId systemId; >- XrResult result = xrGetSystem(m_impl->m_instance, &systemGetInfo, &systemId); >- if (result != XR_SUCCESS) { >- WTFLogAlways("xrGetSystem(): error %s\n", resultToString(result, m_impl->m_instance).utf8().data()); >- return; >- } >- >- auto device = makeUnique<Device>(); >- auto sessionModes = m_impl->collectSupportedSessionModes(*device, systemId); >- if (sessionModes) { >- for (auto& mode : sessionModes.value()) { >- // TODO: fill in features >- device->setEnabledFeatures(mode, { }); >- } >- } >- >- m_immersiveXRDevices.append(WTFMove(device)); >-#endif // USE_OPENXR >-} >- >-} // namespace PlatformXR >- >-#endif // ENABLE(WEBXR) >diff --git a/Source/WebCore/platform/xr/openxr/PlatformXROpenXR.cpp b/Source/WebCore/platform/xr/openxr/PlatformXROpenXR.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..a7f36667e869cdc2b8abfa6ed51bd077308f2b00 >--- /dev/null >+++ b/Source/WebCore/platform/xr/openxr/PlatformXROpenXR.cpp >@@ -0,0 +1,235 @@ >+/* >+ * Copyright (C) 2020 Igalia, S.L. >+ * >+ * 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 >+ * aint 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 "PlatformXROpenXR.h" >+ >+#if ENABLE(WEBXR) >+ >+#if USE_OPENXR >+#include <wtf/Optional.h> >+#include <wtf/text/StringConcatenateNumbers.h> >+#include <wtf/text/WTFString.h> >+#endif // USE_OPENXR >+#include <wtf/NeverDestroyed.h> >+ >+namespace PlatformXR { >+ >+#if USE_OPENXR >+ >+template<typename T, XrStructureType StructureType> >+T createStructure() >+{ >+ T object; >+ std::memset(&object, 0, sizeof(T)); >+ object.type = StructureType; >+ object.next = nullptr; >+ return object; >+} >+ >+String resultToString(XrResult value, XrInstance instance) >+{ >+ char buffer[XR_MAX_RESULT_STRING_SIZE]; >+ XrResult result = xrResultToString(instance, value, buffer); >+ if (result == XR_SUCCESS) >+ return String(buffer); >+ return makeString("<unknown ", int(value), ">"); >+} >+ >+#define RETURN_IF_FAILED(result, call, instance) \ >+ if (XR_FAILED(result)) { \ >+ WTFLogAlways("%s %s: %s\n", __func__, call, resultToString(result, instance).utf8().data()); \ >+ return; \ >+ } \ >+ >+#endif // USE_OPENXR >+ >+struct Instance::Impl { >+ WTF_MAKE_FAST_ALLOCATED; >+public: >+ Impl(); >+ ~Impl(); >+ >+#if USE_OPENXR >+ Optional<Vector<SessionMode>> collectSupportedSessionModes(Device&, XrSystemId); >+ XrInstance m_instance { XR_NULL_HANDLE }; >+#endif // USE_OPENXR >+}; >+ >+Instance::Impl::Impl() >+{ >+#if USE_OPENXR >+ WTFLogAlways("OpenXR: initializing\n"); >+ >+ [&] { >+ uint32_t propertyCountOutput { 0 }; >+ XrResult result = xrEnumerateApiLayerProperties(0, &propertyCountOutput, nullptr); >+ RETURN_IF_FAILED(result, "xrEnumerateApiLayerProperties()", m_instance); >+ >+ if (!propertyCountOutput) { >+ WTFLogAlways("xrEnumerateApiLayerProperties(): no properties\n"); >+ return; >+ } >+ >+ Vector<XrApiLayerProperties> properties(propertyCountOutput); >+ result = xrEnumerateApiLayerProperties(propertyCountOutput, nullptr, properties.data()); >+ RETURN_IF_FAILED(result, "xrEnumerateApiLayerProperties()", m_instance); >+ >+ WTFLogAlways("xrEnumerateApiLayerProperties(): %zu properties\n", properties.size()); >+ }(); >+ >+ [&] { >+ uint32_t propertyCountOutput { 0 }; >+ XrResult result = xrEnumerateInstanceExtensionProperties(nullptr, 0, &propertyCountOutput, nullptr); >+ RETURN_IF_FAILED(result, "xrEnumerateInstanceExtensionProperties()", m_instance); >+ >+ if (!propertyCountOutput) { >+ WTFLogAlways("xrEnumerateInstanceExtensionProperties(): no properties\n"); >+ return; >+ } >+ >+ Vector<XrExtensionProperties> properties(propertyCountOutput, >+ [] { >+ XrExtensionProperties object; >+ std::memset(&object, 0, sizeof(XrExtensionProperties)); >+ object.type = XR_TYPE_EXTENSION_PROPERTIES; >+ return object; >+ }()); >+ uint32_t propertyCountWritten { 0 }; >+ result = xrEnumerateInstanceExtensionProperties(nullptr, propertyCountOutput, &propertyCountWritten, properties.data()); >+ RETURN_IF_FAILED(result, "xrEnumerateInstanceExtensionProperties()", m_instance); >+ >+ WTFLogAlways("xrEnumerateInstanceExtensionProperties(): %zu extension properties\n", properties.size()); >+ for (auto& property : properties) { >+ WTFLogAlways(" extension '%s', version %u\n", >+ property.extensionName, property.extensionVersion); >+ } >+ }(); >+ >+ static const char* s_applicationName = "WebXR (WebKit)"; >+ static const uint32_t s_applicationVersion = 1; >+ >+ { >+ auto createInfo = createStructure<XrInstanceCreateInfo, XR_TYPE_INSTANCE_CREATE_INFO>(); >+ createInfo.createFlags = 0; >+ std::memcpy(createInfo.applicationInfo.applicationName, s_applicationName, XR_MAX_APPLICATION_NAME_SIZE); >+ createInfo.applicationInfo.apiVersion = XR_CURRENT_API_VERSION; >+ createInfo.applicationInfo.applicationVersion = s_applicationVersion; >+ createInfo.enabledApiLayerCount = 0; >+ createInfo.enabledExtensionCount = 0; >+ >+ XrInstance instance; >+ XrResult result = xrCreateInstance(&createInfo, &instance); >+ RETURN_IF_FAILED(result, "xrCreateInstance()", m_instance); >+ >+ m_instance = instance; >+ WTFLogAlways("xrCreateInstance(): using instance %p\n", m_instance); >+ } >+#endif // USE_OPENXR >+} >+ >+Instance::Impl::~Impl() >+{ >+} >+ >+#if USE_OPENXR >+ >+Optional<Vector<SessionMode>> Instance::Impl::collectSupportedSessionModes(Device& device, XrSystemId systemId) >+{ >+ uint32_t viewConfigurationCount; >+ XrResult result = xrEnumerateViewConfigurations(m_instance, systemId, 0, &viewConfigurationCount, nullptr); >+ if (result != XR_SUCCESS) { >+ WTFLogAlways("xrEnumerateViewConfigurations(): error %s\n", resultToString(result, m_instance).utf8().data()); >+ return WTF::nullopt; >+ } >+ >+ XrViewConfigurationType viewConfigurations[viewConfigurationCount]; >+ result = xrEnumerateViewConfigurations(m_instance, systemId, viewConfigurationCount, &viewConfigurationCount, viewConfigurations); >+ if (result != XR_SUCCESS) { >+ WTFLogAlways("xrEnumerateViewConfigurations(): error %s\n", resultToString(result, m_instance).utf8().data()); >+ WTFLogAlways("xrEnumerateViewConfigurations(): error %s\n", resultToString(result, m_instance).utf8().data()); >+ return WTF::nullopt; >+ } >+ >+ Vector<SessionMode> supportedModes; >+ for (uint32_t i = 0; i < viewConfigurationCount; ++i) { >+ auto viewConfigurationProperties = createStructure<XrViewConfigurationProperties, XR_TYPE_VIEW_CONFIGURATION_PROPERTIES>(); >+ result = xrGetViewConfigurationProperties(m_instance, systemId, viewConfigurations[i], &viewConfigurationProperties); >+ if (result != XR_SUCCESS) { >+ WTFLogAlways("xrGetViewConfigurationProperties(): error %s\n", resultToString(result, m_instance).utf8().data()); >+ return WTF::nullopt; >+ } >+ if (viewConfigurationProperties.viewConfigurationType == XR_VIEW_CONFIGURATION_TYPE_PRIMARY_MONO) >+ supportedModes.append(SessionMode::ImmersiveAr); >+ else if (viewConfigurationProperties.viewConfigurationType == XR_VIEW_CONFIGURATION_TYPE_PRIMARY_STEREO) >+ supportedModes.append(SessionMode::ImmersiveVr); >+ } >+ return supportedModes; >+} >+ >+#endif // USE_OPENXR >+ >+Instance& Instance::singleton() >+{ >+ static LazyNeverDestroyed<Instance> s_instance; >+ static std::once_flag s_onceFlag; >+ std::call_once(s_onceFlag, >+ [&] { >+ s_instance->m_impl = makeUnique<Impl>(); >+ }); >+ return s_instance.get(); >+} >+ >+Instance::Instance() = default; >+Instance::~Instance() = default; >+ >+void Instance::enumerateImmersiveXRDevices() >+{ >+#if USE_OPENXR >+ if (m_impl->m_instance == XR_NULL_HANDLE) { >+ WTFLogAlways("%s Unable to enumerate XR devices. No XrInstance present\n", __FUNCTION__); >+ return; >+ } >+ >+ auto systemGetInfo = createStructure<XrSystemGetInfo, XR_TYPE_SYSTEM_GET_INFO>(); >+ systemGetInfo.formFactor = XR_FORM_FACTOR_HEAD_MOUNTED_DISPLAY; >+ >+ XrSystemId systemId; >+ XrResult result = xrGetSystem(m_impl->m_instance, &systemGetInfo, &systemId); >+ if (result != XR_SUCCESS) { >+ WTFLogAlways("xrGetSystem(): error %s\n", resultToString(result, m_impl->m_instance).utf8().data()); >+ return; >+ } >+ >+ auto device = makeUnique<OpenXRDevice>(); >+ auto sessionModes = m_impl->collectSupportedSessionModes(*device, systemId); >+ if (sessionModes) { >+ for (auto& mode : sessionModes.value()) { >+ // TODO: fill in features >+ device->setEnabledFeatures(mode, { }); >+ } >+ } >+ >+ m_immersiveXRDevices.append(WTFMove(device)); >+#endif // USE_OPENXR >+} >+ >+} // namespace PlatformXR >+ >+#endif // ENABLE(WEBXR) >diff --git a/Source/WebCore/platform/xr/openxr/PlatformXROpenXR.h b/Source/WebCore/platform/xr/openxr/PlatformXROpenXR.h >new file mode 100644 >index 0000000000000000000000000000000000000000..dc0f104b7324348c2ad579e5f519a893ae54e54a >--- /dev/null >+++ b/Source/WebCore/platform/xr/openxr/PlatformXROpenXR.h >@@ -0,0 +1,58 @@ >+/* >+ * Copyright (C) 2020 Igalia, S.L. >+ * >+ * 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 >+ * aint 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 ENABLE(WEBXR) >+#include "PlatformXR.h" >+ >+#if USE_OPENXR >+#include <openxr/openxr.h> >+ >+namespace PlatformXR { >+ >+// https://www.khronos.org/registry/OpenXR/specs/1.0/html/xrspec.html#system >+// A system represents a collection of related devices in the runtime, often made up of several individual >+// hardware components working together to enable XR experiences. >+// >+// WebXR talks about XR devices, is a physical unit of hardware that can present imagery to the user, so >+// there is not direct correspondence between an OpenXR system and a WebXR device because the system API >+// is an abstraction for a collection of devices while the WebXR device is mostly one physical unit, >+// usually an HMD or a phone/tablet. >+// >+// It's important also not to try to associate OpenXR system with WebXR's XRSystem because they're totally >+// different concepts. The system in OpenXR was defined above as a collection of related devices. In WebXR, >+// the XRSystem is basically the entry point for the WebXR API available via the Navigator object. >+class OpenXRDevice final : public Device { >+public: >+ >+ bool operator==(const Device& other) const final >+ { >+ ASSERT(is<OpenXRDevice>(other)); >+ return m_systemId == downcast<OpenXRDevice>(other).m_systemId; >+ } >+ >+private: >+ XrSystemId m_systemId; >+}; >+ >+} // namespace PlatformXR >+ >+#endif // USE_OPENXR >+#endif // ENABLE(WEBXR) >diff --git a/Source/WebCore/testing/WebFakeXRDevice.h b/Source/WebCore/testing/WebFakeXRDevice.h >index b4c584d54caf3deb5e8b70bf11d8cd3c370c93be..5354ade847d5ea5c4dc356eefd35062e8219b51c 100644 >--- a/Source/WebCore/testing/WebFakeXRDevice.h >+++ b/Source/WebCore/testing/WebFakeXRDevice.h >@@ -68,6 +68,10 @@ public: > void setFloorOrigin(RefPtr<WebXRRigidTransform>&& origin) { m_floorOrigin = WTFMove(origin); } > void setEmulatedPosition(bool emulated) { m_emulatedPosition = emulated; } > Vector<Ref<FakeXRView>>& views() { return m_views; } >+ >+ // There musn't be another simulated XR device >+ bool operator==(const Device& other) const final { return this == &other ? true : false; } >+ > private: > Optional<Vector<FakeXRBoundsPoint>> m_nativeBoundsGeometry; > RefPtr<WebXRRigidTransform> m_viewerOrigin;
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 212470
:
400466
|
400468
|
401135