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-222737-20210304184337.patch (text/plain), 32.96 KB, created by
Imanol Fernandez
on 2021-03-04 09:43:38 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Imanol Fernandez
Created:
2021-03-04 09:43:38 PST
Size:
32.96 KB
patch
obsolete
>Subversion Revision: 273891 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 59bf5ce928ef355a7c3d3e21099e9415a2411e9b..6c1c73c929c19180c22135f6bb2bd151ac1f336e 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,57 @@ >+2021-03-04 Imanol Fernandez <ifernandez@igalia.com> >+ >+ Implement WebXRBoundedReferenceSpace bounds geometry >+ https://bugs.webkit.org/show_bug.cgi?id=222737 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Having bounds geometry in WebXRBoundedReferenceSpace enables WebXR room-scale applications. XR systems may have limited >+ real world spatial ranges in which users can freely move around while remaining tracked. WebXR Applications can query >+ these boundaries and alter application behavior or content placement to ensure the user can complete the experience while >+ remaining within the boundary. >+ >+ Tested by WebXR WPT tests. >+ >+ * Modules/webxr/WebXRBoundedReferenceSpace.cpp: >+ (WebCore::WebXRBoundedReferenceSpace::boundsGeometry): Call updateIfNeeded >+ (WebCore::WebXRBoundedReferenceSpace::getOffsetReferenceSpace): Use Exception instead of null RefPtr<> >+ (WebCore::WebXRBoundedReferenceSpace::updateIfNeeded): Updates boundsGeometry vector when data changed. >+ (WebCore::WebXRBoundedReferenceSpace::quantize): Utility method to avoid fingerprinting. >+ * Modules/webxr/WebXRBoundedReferenceSpace.h: >+ >+ * Modules/webxr/WebXRBoundedReferenceSpace.idl: Add CustomToJSObject >+ >+ * Modules/webxr/WebXRReferenceSpace.cpp: >+ (WebCore::WebXRReferenceSpace::getOffsetReferenceSpace): Use Exception instead of null RefPtr<> >+ * Modules/webxr/WebXRReferenceSpace.h: >+ * Modules/webxr/WebXRReferenceSpace.idl: Add CustomToJSObject >+ * Modules/webxr/WebXRSpace.idl: Add CustomToJSObject >+ >+ * Sources.txt: Add CustomToJSObject implementations >+ * bindings/js/JSWebXRReferenceSpaceCustom.cpp: Added. >+ (WebCore::toJSNewlyCreated): >+ (WebCore::toJS): >+ * bindings/js/JSWebXRSpaceCustom.cpp: Added. >+ (WebCore::toJSNewlyCreated): >+ (WebCore::toJS): >+ >+ * platform/xr/PlatformXR.h: Add StageParameters to FrameData. >+ >+ * platform/xr/openxr/PlatformXROpenXR.cpp: Implement boundsGeometry using OpenXR. >+ (PlatformXR::OpenXRDevice::initializeReferenceSpace): >+ (PlatformXR::OpenXRDevice::requestFrame): >+ (PlatformXR::OpenXRDevice::collectEnabledFeatures): >+ (PlatformXR::OpenXRDevice::pollEvents): >+ (PlatformXR::OpenXRDevice::resetSession): >+ (PlatformXR::OpenXRDevice::updateStageParameters): >+ * platform/xr/openxr/PlatformXROpenXR.h: >+ >+ * testing/WebFakeXRDevice.cpp: Implement boundsGeometry for tests. >+ (WebCore::SimulatedXRDevice::setNativeBoundsGeometry): >+ (WebCore::SimulatedXRDevice::frameTimerFired): >+ (WebCore::WebFakeXRDevice::setBoundsGeometry): >+ * testing/WebFakeXRDevice.h: >+ > 2021-03-04 Youenn Fablet <youenn@apple.com> > > Update camera and microphone capture state control WKWebView API >diff --git a/Source/WebCore/Modules/webxr/WebXRBoundedReferenceSpace.cpp b/Source/WebCore/Modules/webxr/WebXRBoundedReferenceSpace.cpp >index 94d89c2b53222b643c1c80289a24296933d516e9..0a1abea883d7cce64c87f3ca6871ea6a2996f070 100644 >--- a/Source/WebCore/Modules/webxr/WebXRBoundedReferenceSpace.cpp >+++ b/Source/WebCore/Modules/webxr/WebXRBoundedReferenceSpace.cpp >@@ -36,6 +36,12 @@ > > namespace WebCore { > >+// https://immersive-web.github.io/webxr/#xrboundedreferencespace-native-bounds-geometry >+// It is suggested that points of the native bounds geometry be quantized to the nearest 5cm. >+static constexpr float BoundsPrecisionInMeters = 0.05; >+// A valid polygon has at least 3 vertices. >+static constexpr int MinimumBoundsVertices = 3; >+ > WTF_MAKE_ISO_ALLOCATED_IMPL(WebXRBoundedReferenceSpace); > > Ref<WebXRBoundedReferenceSpace> WebXRBoundedReferenceSpace::create(Document& document, Ref<WebXRSession>&& session, XRReferenceSpaceType type) >@@ -43,13 +49,11 @@ Ref<WebXRBoundedReferenceSpace> WebXRBoundedReferenceSpace::create(Document& doc > return adoptRef(*new WebXRBoundedReferenceSpace(document, WTFMove(session), WebXRRigidTransform::create(), type)); > } > >- > Ref<WebXRBoundedReferenceSpace> WebXRBoundedReferenceSpace::create(Document& document, Ref<WebXRSession>&& session, Ref<WebXRRigidTransform>&& offset, XRReferenceSpaceType type) > { > return adoptRef(*new WebXRBoundedReferenceSpace(document, WTFMove(session), WTFMove(offset), type)); > } > >- > WebXRBoundedReferenceSpace::WebXRBoundedReferenceSpace(Document& document, Ref<WebXRSession>&& session, Ref<WebXRRigidTransform>&& offset, XRReferenceSpaceType type) > : WebXRReferenceSpace(document, WTFMove(session), WTFMove(offset), type) > { >@@ -64,24 +68,52 @@ TransformationMatrix WebXRBoundedReferenceSpace::nativeOrigin() const > return floorOriginTransform(); > } > >-const Vector<Ref<DOMPointReadOnly>>& WebXRBoundedReferenceSpace::boundsGeometry() const >+const Vector<Ref<DOMPointReadOnly>>& WebXRBoundedReferenceSpace::boundsGeometry() > { >- // FIXME: get data from device >+ updateIfNeeded(); > return m_boundsGeometry; > } > >-RefPtr<WebXRReferenceSpace> WebXRBoundedReferenceSpace::getOffsetReferenceSpace(const WebXRRigidTransform& offsetTransform) >+ExceptionOr<Ref<WebXRReferenceSpace>> WebXRBoundedReferenceSpace::getOffsetReferenceSpace(const WebXRRigidTransform& offsetTransform) > { > auto* document = downcast<Document>(scriptExecutionContext()); > if (!document) >- return nullptr; >+ return Exception { InvalidStateError }; > > // https://immersive-web.github.io/webxr/#dom-xrreferencespace-getoffsetreferencespace > // Set offsetSpaceâs origin offset to the result of multiplying baseâs origin offset by originOffset in the relevant realm of base. > auto offset = WebXRRigidTransform::create(originOffset().rawTransform() * offsetTransform.rawTransform()); > >- // FIXME: set offsetSpaceâs boundsGeometry to baseâs boundsGeometry, with each point multiplied by the inverse of originOffset. >- return create(*document, m_session.copyRef(), WTFMove(offset), m_type); >+ return { create(*document, m_session.copyRef(), WTFMove(offset), m_type) }; >+} >+ >+// https://immersive-web.github.io/webxr/#dom-xrboundedreferencespace-boundsgeometry >+void WebXRBoundedReferenceSpace::updateIfNeeded() >+{ >+ auto& frameData = m_session->frameData(); >+ if (frameData.stageParameters.id == m_lastUpdateId) >+ return; >+ m_lastUpdateId = frameData.stageParameters.id; >+ >+ m_boundsGeometry.clear(); >+ >+ if (frameData.stageParameters.bounds.size() >= MinimumBoundsVertices) { >+ // Each point has to multiplied by the inverse of originOffset. >+ auto transform = originOffset().rawTransform().inverse().valueOr(TransformationMatrix()); >+ for (auto& point : frameData.stageParameters.bounds) { >+ auto mappedPoint = transform.mapPoint(point); >+ // The y value of each point MUST be 0. >+ m_boundsGeometry.append(DOMPointReadOnly::create(quantize(mappedPoint.x()), 0.0, quantize(mappedPoint.y()), 1.0)); >+ } >+ } >+} >+ >+// https://immersive-web.github.io/webxr/#quantization >+float WebXRBoundedReferenceSpace::quantize(float value) >+{ >+ // Each point in the native bounds geometry MUST also be quantized sufficiently to prevent fingerprinting. >+ // For userâs safety, quantized points values MUST NOT fall outside the bounds reported by the platform. >+ return std::floor(value / BoundsPrecisionInMeters) * BoundsPrecisionInMeters; > } > > } // namespace WebCore >diff --git a/Source/WebCore/Modules/webxr/WebXRBoundedReferenceSpace.h b/Source/WebCore/Modules/webxr/WebXRBoundedReferenceSpace.h >index 71485201b7d7a9506b9dfb3f9ade474a5bb1957a..76e096aa9cc7d46c4d804103e57aec4fccbba78e 100644 >--- a/Source/WebCore/Modules/webxr/WebXRBoundedReferenceSpace.h >+++ b/Source/WebCore/Modules/webxr/WebXRBoundedReferenceSpace.h >@@ -45,19 +45,26 @@ public: > virtual ~WebXRBoundedReferenceSpace(); > > TransformationMatrix nativeOrigin() const final; >- const Vector<Ref<DOMPointReadOnly>>& boundsGeometry() const; >- RefPtr<WebXRReferenceSpace> getOffsetReferenceSpace(const WebXRRigidTransform&) final; >+ const Vector<Ref<DOMPointReadOnly>>& boundsGeometry(); >+ ExceptionOr<Ref<WebXRReferenceSpace>> getOffsetReferenceSpace(const WebXRRigidTransform&) final; > > private: > WebXRBoundedReferenceSpace(Document&, Ref<WebXRSession>&&, Ref<WebXRRigidTransform>&&, XRReferenceSpaceType); > > bool isBoundedReferenceSpace() const final { return true; } > >+ void updateIfNeeded(); >+ float quantize(float); >+ > Vector<Ref<DOMPointReadOnly>> m_boundsGeometry; >+ int m_lastUpdateId { -1 }; > }; > > } // namespace WebCore > >-SPECIALIZE_TYPE_TRAITS_WEBXRSPACE(WebXRBoundedReferenceSpace, isBoundedReferenceSpace()) >+SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::WebXRBoundedReferenceSpace) >+ static bool isType(const WebCore::WebXRReferenceSpace& element) { return element.isBoundedReferenceSpace(); } >+ static bool isType(const WebCore::WebXRSpace& element) { return is<WebCore::WebXRReferenceSpace>(element) && isType(downcast<WebCore::WebXRReferenceSpace>(element)); } >+SPECIALIZE_TYPE_TRAITS_END() > > #endif // ENABLE(WEBXR) >diff --git a/Source/WebCore/Modules/webxr/WebXRBoundedReferenceSpace.idl b/Source/WebCore/Modules/webxr/WebXRBoundedReferenceSpace.idl >index d5b88337423d06aa9fa4d5541b6c5104f0e47e4d..4394ce4f81ec4b3542187a488012971a00ec430d 100644 >--- a/Source/WebCore/Modules/webxr/WebXRBoundedReferenceSpace.idl >+++ b/Source/WebCore/Modules/webxr/WebXRBoundedReferenceSpace.idl >@@ -27,6 +27,8 @@ > EnabledAtRuntime=WebXR, > Conditional=WEBXR, > SecureContext, >+ CustomToJSObject, >+ JSGenerateToNativeObject, > Exposed=Window, > InterfaceName=XRBoundedReferenceSpace > ] interface WebXRBoundedReferenceSpace : WebXRReferenceSpace { >diff --git a/Source/WebCore/Modules/webxr/WebXRReferenceSpace.cpp b/Source/WebCore/Modules/webxr/WebXRReferenceSpace.cpp >index 9520e5e7b0e3f2dd2384b0053ce83846472fc1aa..8083d3de1d204a9f78564f209f30c2f2e8685df8 100644 >--- a/Source/WebCore/Modules/webxr/WebXRReferenceSpace.cpp >+++ b/Source/WebCore/Modules/webxr/WebXRReferenceSpace.cpp >@@ -95,11 +95,11 @@ TransformationMatrix WebXRReferenceSpace::nativeOrigin() const > return identity; > } > >-RefPtr<WebXRReferenceSpace> WebXRReferenceSpace::getOffsetReferenceSpace(const WebXRRigidTransform& offsetTransform) >+ExceptionOr<Ref<WebXRReferenceSpace>> WebXRReferenceSpace::getOffsetReferenceSpace(const WebXRRigidTransform& offsetTransform) > { > auto* document = downcast<Document>(scriptExecutionContext()); > if (!document) >- return nullptr; >+ return Exception { InvalidStateError }; > > // https://immersive-web.github.io/webxr/#dom-xrreferencespace-getoffsetreferencespace > // Set offsetSpaceâs origin offset to the result of multiplying baseâs origin offset by originOffset in the relevant realm of base. >diff --git a/Source/WebCore/Modules/webxr/WebXRReferenceSpace.h b/Source/WebCore/Modules/webxr/WebXRReferenceSpace.h >index d50229b925326ff8e739cc58e838e38dfa3b9924..93495641d1430dfcca332890e8c1d39cfc5840df 100644 >--- a/Source/WebCore/Modules/webxr/WebXRReferenceSpace.h >+++ b/Source/WebCore/Modules/webxr/WebXRReferenceSpace.h >@@ -50,7 +50,7 @@ public: > > WebXRSession& session() const final { return m_session.get(); } > TransformationMatrix nativeOrigin() const override; >- virtual RefPtr<WebXRReferenceSpace> getOffsetReferenceSpace(const WebXRRigidTransform&); >+ virtual ExceptionOr<Ref<WebXRReferenceSpace>> getOffsetReferenceSpace(const WebXRRigidTransform&); > XRReferenceSpaceType type() const { return m_type; } > > protected: >diff --git a/Source/WebCore/Modules/webxr/WebXRReferenceSpace.idl b/Source/WebCore/Modules/webxr/WebXRReferenceSpace.idl >index 81e44d34da167b8fe6db234c240c93856352590d..af539da4823dfcf9ccff69a05d6698c6986c8b86 100644 >--- a/Source/WebCore/Modules/webxr/WebXRReferenceSpace.idl >+++ b/Source/WebCore/Modules/webxr/WebXRReferenceSpace.idl >@@ -28,12 +28,12 @@ > Conditional=WEBXR, > SecureContext, > Exposed=Window, >- JSGenerateToJSObject, >+ CustomToJSObject, > JSGenerateToNativeObject, > SkipVTableValidation, > InterfaceName=XRReferenceSpace > ] interface WebXRReferenceSpace : WebXRSpace { >- [NewObject] WebXRReferenceSpace getOffsetReferenceSpace(WebXRRigidTransform originOffset); >+ [NewObject, MayThrowException] WebXRReferenceSpace getOffsetReferenceSpace(WebXRRigidTransform originOffset); > > attribute EventHandler onreset; > }; >diff --git a/Source/WebCore/Modules/webxr/WebXRSpace.idl b/Source/WebCore/Modules/webxr/WebXRSpace.idl >index bb794f18b233170676d1d5499b9a17116aee7cb1..e34b7127afd4e9bee69c3ff23de7b614df82a6e8 100644 >--- a/Source/WebCore/Modules/webxr/WebXRSpace.idl >+++ b/Source/WebCore/Modules/webxr/WebXRSpace.idl >@@ -26,6 +26,7 @@ > [ > EnabledAtRuntime=WebXR, > Conditional=WEBXR, >+ CustomToJSObject, > SecureContext, > Exposed=Window, > InterfaceName=XRSpace >diff --git a/Source/WebCore/Sources.txt b/Source/WebCore/Sources.txt >index 72de6d16d8f4bda7c4972dd80fa9d10e70850dd4..b4b656b4f6258e06b6d802a9b414a0ca6ff56b0e 100644 >--- a/Source/WebCore/Sources.txt >+++ b/Source/WebCore/Sources.txt >@@ -618,6 +618,8 @@ bindings/js/JSVideoTrackListCustom.cpp > bindings/js/JSWebAnimationCustom.cpp > bindings/js/JSWebGL2RenderingContextCustom.cpp > bindings/js/JSWebGLRenderingContextCustom.cpp >+bindings/js/JSWebXRReferenceSpaceCustom.cpp >+bindings/js/JSWebXRSpaceCustom.cpp > bindings/js/JSWindowProxy.cpp > bindings/js/JSWorkerGlobalScopeBase.cpp > bindings/js/JSWorkerGlobalScopeCustom.cpp >diff --git a/Source/WebCore/WebCore.xcodeproj/project.pbxproj b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >index f944476aed74ca8b8125290b2f11bead6f9808b6..0c909b8b9dc3339a2f7b56a8622e7118e94d2dc5 100644 >--- a/Source/WebCore/WebCore.xcodeproj/project.pbxproj >+++ b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >@@ -6350,6 +6350,8 @@ > 11CB2786203BA570004A1DC9 /* RenderTreeBuilderFullScreen.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = RenderTreeBuilderFullScreen.cpp; sourceTree = "<group>"; }; > 11CB2787203BA570004A1DC9 /* RenderTreeBuilderFullScreen.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RenderTreeBuilderFullScreen.h; sourceTree = "<group>"; }; > 11D19C2E23159BAE008F24D3 /* TableFormattingContextGeometry.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = TableFormattingContextGeometry.cpp; sourceTree = "<group>"; }; >+ 11E6CF1B25F140E30013D3D5 /* JSWebXRReferenceSpaceCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSWebXRReferenceSpaceCustom.cpp; sourceTree = "<group>"; }; >+ 11E6CF1D25F140E40013D3D5 /* JSWebXRSpaceCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSWebXRSpaceCustom.cpp; sourceTree = "<group>"; }; > 11FF02D520BA3C810083F25B /* Verification.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = Verification.cpp; sourceTree = "<group>"; }; > 12F75A9A86EA03DAF24B7971 /* ISOProtectionSystemSpecificHeaderBox.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ISOProtectionSystemSpecificHeaderBox.h; sourceTree = "<group>"; }; > 1400D7A717136EA70077CE05 /* ScriptWrappableInlines.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScriptWrappableInlines.h; sourceTree = "<group>"; }; >@@ -22876,6 +22878,8 @@ > 715DA5D3201BB902002EF2B0 /* JSWebAnimationCustom.cpp */, > D3F3D3591A69A3B00059FC2B /* JSWebGL2RenderingContextCustom.cpp */, > 49EED14C1051971A00099FAB /* JSWebGLRenderingContextCustom.cpp */, >+ 11E6CF1B25F140E30013D3D5 /* JSWebXRReferenceSpaceCustom.cpp */, >+ 11E6CF1D25F140E40013D3D5 /* JSWebXRSpaceCustom.cpp */, > E18258AB0EF3CD7000933242 /* JSWorkerGlobalScopeCustom.cpp */, > 46F91BC91FCDD0FE001599C3 /* JSWorkerNavigatorCustom.cpp */, > 83A4A9F81CE7FD7E00709B00 /* JSXMLDocumentCustom.cpp */, >diff --git a/Source/WebCore/bindings/js/JSWebXRReferenceSpaceCustom.cpp b/Source/WebCore/bindings/js/JSWebXRReferenceSpaceCustom.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..5d0e3984ed071ff4902219c446261e666d7dd3f9 >--- /dev/null >+++ b/Source/WebCore/bindings/js/JSWebXRReferenceSpaceCustom.cpp >@@ -0,0 +1,51 @@ >+/* >+ * Copyright (C) 2021 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. ``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 >+ * 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" >+ >+#if ENABLE(WEBXR) >+#include "JSWebXRReferenceSpace.h" >+ >+#include "JSWebXRBoundedReferenceSpace.h" >+#include "WebXRBoundedReferenceSpace.h" >+ >+namespace WebCore { >+using namespace JSC; >+ >+JSValue toJSNewlyCreated(JSGlobalObject*, JSDOMGlobalObject* globalObject, Ref<WebXRReferenceSpace>&& space) >+{ >+ if (space->isBoundedReferenceSpace()) >+ return createWrapper<WebXRBoundedReferenceSpace>(globalObject, WTFMove(space)); >+ return createWrapper<WebXRReferenceSpace>(globalObject, WTFMove(space)); >+} >+ >+JSValue toJS(JSGlobalObject* lexicalGlobalObject, JSDOMGlobalObject* globalObject, WebXRReferenceSpace& space) >+{ >+ return wrap(lexicalGlobalObject, globalObject, space); >+} >+ >+} // namespace WebCore >+ >+#endif // ENABLE(WEBXR) >diff --git a/Source/WebCore/bindings/js/JSWebXRSpaceCustom.cpp b/Source/WebCore/bindings/js/JSWebXRSpaceCustom.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..d4fe2134bcecf0031bf3fbaf921de01a8bc53766 >--- /dev/null >+++ b/Source/WebCore/bindings/js/JSWebXRSpaceCustom.cpp >@@ -0,0 +1,50 @@ >+/* >+ * Copyright (C) 2021 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. ``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 >+ * 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" >+ >+#if ENABLE(WEBXR) >+#include "JSWebXRSpace.h" >+ >+#include "WebXRReferenceSpace.h" >+ >+namespace WebCore { >+using namespace JSC; >+ >+JSValue toJSNewlyCreated(JSGlobalObject* lexicalGlobalObject, JSDOMGlobalObject* globalObject, Ref<WebXRSpace>&& space) >+{ >+ if (is<WebXRReferenceSpace>(space)) >+ return toJSNewlyCreated(lexicalGlobalObject, globalObject, static_reference_cast<WebXRReferenceSpace>(WTFMove(space))); >+ return createWrapper<WebXRSpace>(globalObject, WTFMove(space)); >+} >+ >+JSValue toJS(JSGlobalObject* lexicalGlobalObject, JSDOMGlobalObject* globalObject, WebXRSpace& space) >+{ >+ return wrap(lexicalGlobalObject, globalObject, space); >+} >+ >+} // namespace WebCore >+ >+#endif // ENABLE(WEBXR) >diff --git a/Source/WebCore/platform/xr/PlatformXR.h b/Source/WebCore/platform/xr/PlatformXR.h >index 7e00df07be5e1ee547f42348a797f9ff145cd676..d97d4f181b13d269892dbf5ebc33f55933e25676 100644 >--- a/Source/WebCore/platform/xr/PlatformXR.h >+++ b/Source/WebCore/platform/xr/PlatformXR.h >@@ -114,12 +114,18 @@ public: > Projection projection = { nullptr }; > }; > >+ struct StageParameters { >+ int id { 0 }; >+ Vector<WebCore::FloatPoint> bounds; >+ }; >+ > bool isTrackingValid { false }; > bool isPositionValid { false }; > bool isPositionEmulated { false }; > long predictedDisplayTime { 0 }; > Pose origin; > Optional<Pose> floorTransform; >+ StageParameters stageParameters; > Vector<View> views; > }; > >diff --git a/Source/WebCore/platform/xr/openxr/PlatformXROpenXR.cpp b/Source/WebCore/platform/xr/openxr/PlatformXROpenXR.cpp >index cb26c30b5349e5747db75034ed8822c732123eef..205e783bfbd5d007633d6e56871e5869f7545e12 100644 >--- a/Source/WebCore/platform/xr/openxr/PlatformXROpenXR.cpp >+++ b/Source/WebCore/platform/xr/openxr/PlatformXROpenXR.cpp >@@ -143,6 +143,8 @@ void OpenXRDevice::initializeReferenceSpace(PlatformXR::ReferenceSpaceType space > { > if ((spaceType == ReferenceSpaceType::LocalFloor || spaceType == ReferenceSpaceType::BoundedFloor) && m_stageSpace == XR_NULL_HANDLE) > m_stageSpace = createReferenceSpace(XR_REFERENCE_SPACE_TYPE_STAGE); >+ if (spaceType == ReferenceSpaceType::BoundedFloor) >+ updateStageParameters(); > } > > void OpenXRDevice::requestFrame(RequestFrameCallback&& callback) >@@ -169,7 +171,7 @@ void OpenXRDevice::requestFrame(RequestFrameCallback&& callback) > > Device::FrameData frameData; > frameData.predictedDisplayTime = frameState.predictedDisplayTime; >- >+ frameData.stageParameters = m_stageParameters; > > ASSERT(m_configurationViews.contains(m_currentViewConfigurationType)); > const auto& configurationView = m_configurationViews.get(m_currentViewConfigurationType); >@@ -256,8 +258,9 @@ Device::ListOfEnabledFeatures OpenXRDevice::collectEnabledFeatures() > // The spec uses a estimated height if we don't provide a floor transform in frameData. > features.append(ReferenceSpaceType::LocalFloor); > >- // FIXME: Enable BoundedFloor when we implement xrGetReferenceSpaceBoundsRect and the related bits in the DOM. >- // enabledFeatures.append(ReferenceSpaceType::BoundedFloor); >+ // Mark BoundedFloor as supported regardless if XR_REFERENCE_SPACE_TYPE_STAGE is available. >+ // The spec allows reporting an empty array if xrGetReferenceSpaceBoundsRect fails. >+ features.append(ReferenceSpaceType::BoundedFloor); > > if (m_extensions.isExtensionSupported(XR_MSFT_UNBOUNDED_REFERENCE_SPACE_EXTENSION_NAME)) > features.append(ReferenceSpaceType::Unbounded); >@@ -354,14 +357,19 @@ void OpenXRDevice::pollEvents() > while (xrPollEvent(m_instance, &runtimeEvent) == XR_SUCCESS) { > switch (runtimeEvent.type) { > case XR_TYPE_EVENT_DATA_SESSION_STATE_CHANGED: { >- auto* event = (XrEventDataSessionStateChanged*)&runtimeEvent; >+ auto* event = reinterpret_cast<XrEventDataSessionStateChanged*>(&runtimeEvent); > m_sessionState = event->state; > handleSessionStateChange(); > break; > } > case XR_TYPE_EVENT_DATA_EVENTS_LOST: > case XR_TYPE_EVENT_DATA_INSTANCE_LOSS_PENDING: >- case XR_TYPE_EVENT_DATA_REFERENCE_SPACE_CHANGE_PENDING: >+ case XR_TYPE_EVENT_DATA_REFERENCE_SPACE_CHANGE_PENDING: { >+ auto* event = reinterpret_cast<XrEventDataReferenceSpaceChangePending*>(&runtimeEvent); >+ if (event->referenceSpaceType == XR_REFERENCE_SPACE_TYPE_STAGE) >+ updateStageParameters(); >+ break; >+ } > case XR_TYPE_EVENT_DATA_INTERACTION_PROFILE_CHANGED: > case XR_TYPE_EVENT_DATA_MAIN_SESSION_VISIBILITY_CHANGED_EXTX: > case XR_TYPE_EVENT_DATA_VISIBILITY_MASK_CHANGED_KHR: >@@ -413,6 +421,10 @@ void OpenXRDevice::resetSession() > m_session = XR_NULL_HANDLE; > } > m_sessionState = XR_SESSION_STATE_UNKNOWN; >+ m_localSpace = XR_NULL_HANDLE; >+ m_viewSpace = XR_NULL_HANDLE; >+ m_stageSpace = XR_NULL_HANDLE; >+ m_stageParameters = { }; > > // deallocate graphic resources > m_egl.reset(); >@@ -430,7 +442,6 @@ void OpenXRDevice::handleSessionStateChange() > } > } > >- > void OpenXRDevice::waitUntilStopping() > { > ASSERT(&RunLoop::current() == &m_queue.runLoop()); >@@ -442,6 +453,32 @@ void OpenXRDevice::waitUntilStopping() > }); > } > >+void OpenXRDevice::updateStageParameters() >+{ >+ ASSERT(&RunLoop::current() == &m_queue.runLoop()); >+ if (m_stageSpace == XR_NULL_HANDLE) >+ return; // Stage space not requested. >+ >+ m_stageParameters.id++; >+ >+ XrExtent2Df bounds; >+ if (XR_SUCCEEDED(xrGetReferenceSpaceBoundsRect(m_session, XR_REFERENCE_SPACE_TYPE_STAGE, &bounds))) { >+ // https://immersive-web.github.io/webxr/#xrboundedreferencespace-native-bounds-geometry >+ // Points MUST be given in a clockwise order as viewed from above, looking towards the negative end of the Y axis. >+ m_stageParameters.bounds = Vector<WebCore::FloatPoint> { >+ { bounds.width * 0.5f, -bounds.height * 0.5f }, >+ { bounds.width * 0.5f, bounds.height * 0.5f }, >+ { -bounds.width * 0.5f, bounds.height * 0.5f }, >+ { -bounds.width * 0.5f, -bounds.height * 0.5f } >+ }; >+ } else { >+ // https://immersive-web.github.io/webxr/#dom-xrboundedreferencespace-boundsgeometry >+ // If the native bounds geometry is temporarily unavailable, which may occur for several reasons such as during XR device initialization, >+ // extended periods of tracking loss, or movement between pre-configured spaces, the boundsGeometry MUST report an empty array. >+ m_stageParameters.bounds.clear(); >+ } >+} >+ > } // namespace PlatformXR > > #endif // ENABLE(WEBXR) && USE(OPENXR) >diff --git a/Source/WebCore/platform/xr/openxr/PlatformXROpenXR.h b/Source/WebCore/platform/xr/openxr/PlatformXROpenXR.h >index 31783691f4a93bbbd4807916bd569bc6607c914c..e6ab184f12e4f57658bd8d66f9961b69afddd55b 100644 >--- a/Source/WebCore/platform/xr/openxr/PlatformXROpenXR.h >+++ b/Source/WebCore/platform/xr/openxr/PlatformXROpenXR.h >@@ -69,6 +69,7 @@ private: > void resetSession(); > void handleSessionStateChange(); > void waitUntilStopping(); >+ void updateStageParameters(); > > XrInstance m_instance; > XrSystemId m_systemId; >@@ -87,6 +88,7 @@ private: > XrSpace m_localSpace { XR_NULL_HANDLE }; > XrSpace m_viewSpace { XR_NULL_HANDLE }; > XrSpace m_stageSpace { XR_NULL_HANDLE }; >+ Device::FrameData::StageParameters m_stageParameters; > }; > > } // namespace PlatformXR >diff --git a/Source/WebCore/testing/WebFakeXRDevice.cpp b/Source/WebCore/testing/WebFakeXRDevice.cpp >index 7e4a9dccf31d9aa43cc9ba4fc63d5394bff45423..81490129dcba0eb26d5a327077cbd4765cb8d8cd 100644 >--- a/Source/WebCore/testing/WebFakeXRDevice.cpp >+++ b/Source/WebCore/testing/WebFakeXRDevice.cpp >@@ -59,6 +59,14 @@ SimulatedXRDevice::~SimulatedXRDevice() > stopTimer(); > } > >+void SimulatedXRDevice::setNativeBoundsGeometry(const Vector<FakeXRBoundsPoint>& geometry) >+{ >+ m_stageParameters.id++; >+ m_stageParameters.bounds.clear(); >+ for (auto& point : geometry) >+ m_stageParameters.bounds.append({ static_cast<float>(point.x), static_cast<float>(point.z) }); >+} >+ > void SimulatedXRDevice::simulateShutdownCompleted() > { > if (m_trackingAndRenderingClient) >@@ -100,6 +108,8 @@ void SimulatedXRDevice::frameTimerFired() > if (m_floorOrigin) > data.floorTransform = { *m_floorOrigin }; > >+ data.stageParameters = m_stageParameters; >+ > for (auto& fakeView : m_views) { > FrameData::View view; > view.offset = fakeView->offset(); >@@ -182,9 +192,12 @@ void WebFakeXRDevice::simulateVisibilityChange(XRVisibilityState) > { > } > >-void WebFakeXRDevice::setBoundsGeometry(Vector<FakeXRBoundsPoint>&&) >+void WebFakeXRDevice::setBoundsGeometry(Vector<FakeXRBoundsPoint>&& bounds) > { >-} >+ m_device.scheduleOnNextFrame([this, bounds = WTFMove(bounds)]() { >+ m_device.setNativeBoundsGeometry(bounds); >+ }); >+} > > void WebFakeXRDevice::setFloorOrigin(FakeXRRigidTransformInit origin) > { >diff --git a/Source/WebCore/testing/WebFakeXRDevice.h b/Source/WebCore/testing/WebFakeXRDevice.h >index c5a5d144d012f5f02be2238ab2ae20304a29e1ce..e127c059d31864b4c8d08263fd1d29fca4351c79 100644 >--- a/Source/WebCore/testing/WebFakeXRDevice.h >+++ b/Source/WebCore/testing/WebFakeXRDevice.h >@@ -71,7 +71,7 @@ public: > SimulatedXRDevice(); > ~SimulatedXRDevice(); > void setViews(Vector<Ref<FakeXRView>>&& views) { m_views = WTFMove(views); } >- void setNativeBoundsGeometry(const Vector<FakeXRBoundsPoint>& geometry) { m_nativeBoundsGeometry = geometry; } >+ void setNativeBoundsGeometry(const Vector<FakeXRBoundsPoint>&); > void setViewerOrigin(Optional<FrameData::Pose>&& origin) { m_viewerOrigin = WTFMove(origin); } > void setFloorOrigin(Optional<FrameData::Pose>&& origin) { m_floorOrigin = WTFMove(origin); } > void setEmulatedPosition(bool emulated) { m_emulatedPosition = emulated; } >@@ -100,6 +100,7 @@ private: > Timer m_frameTimer; > RequestFrameCallback m_FrameCallback; > Vector<Function<void()>> m_pendingUpdates; >+ FrameData::StageParameters m_stageParameters; > }; > > class WebFakeXRDevice final : public RefCounted<WebFakeXRDevice> { >diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog >index 60720cc416620bcd4f13aeb66d69df862b32f710..cdddc6882c98ea4218e76c15d79b12c5ad15e12f 100644 >--- a/LayoutTests/ChangeLog >+++ b/LayoutTests/ChangeLog >@@ -1,3 +1,14 @@ >+2021-03-04 Imanol Fernandez <ifernandez@igalia.com> >+ >+ Implement WebXRBoundedReferenceSpace bounds geometry >+ https://bugs.webkit.org/show_bug.cgi?id=222737 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Update WebXRBoundedReferenceSpace test expectations. >+ >+ * platform/wpe/TestExpectations: >+ > 2021-03-04 Youenn Fablet <youenn@apple.com> > > Handle the case of synchronous failure in loading blob. >diff --git a/LayoutTests/imported/w3c/ChangeLog b/LayoutTests/imported/w3c/ChangeLog >index a4809a6c103a601c885a0a27c22a5ba4b49eca9e..b4300e842acffd905828c1393f54adfd11043955 100644 >--- a/LayoutTests/imported/w3c/ChangeLog >+++ b/LayoutTests/imported/w3c/ChangeLog >@@ -1,3 +1,14 @@ >+2021-03-04 Imanol Fernandez <ifernandez@igalia.com> >+ >+ Implement WebXRBoundedReferenceSpace bounds geometry >+ https://bugs.webkit.org/show_bug.cgi?id=222737 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Update WebXRBoundedReferenceSpace test expectations. >+ >+ * web-platform-tests/webxr/xrBoundedReferenceSpace_updates.https-expected.txt: Added. >+ > 2021-03-04 Antoine Quint <graouts@webkit.org> > > initial value for border-image-outset should be 0 >diff --git a/LayoutTests/imported/w3c/web-platform-tests/webxr/xrBoundedReferenceSpace_updates.https-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/webxr/xrBoundedReferenceSpace_updates.https-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..29101dda105e8d07f93a79ba2c6a3bd2cc5fe01e >--- /dev/null >+++ b/LayoutTests/imported/w3c/web-platform-tests/webxr/xrBoundedReferenceSpace_updates.https-expected.txt >@@ -0,0 +1,3 @@ >+ >+PASS 'XRBoundedReferenceSpace updates properly when the changes are applied >+ >diff --git a/LayoutTests/platform/wpe/TestExpectations b/LayoutTests/platform/wpe/TestExpectations >index cb9fd86df128f58362c01c76b07ed731cd45613b..2bce00483e6aaaa74f0ad0e86159810ccda3185f 100644 >--- a/LayoutTests/platform/wpe/TestExpectations >+++ b/LayoutTests/platform/wpe/TestExpectations >@@ -606,6 +606,7 @@ webkit.org/b/213131 http/tests/misc/gamepads-insecure.html [ Skip ] > > # WebXR > webkit.org/b/212897 imported/w3c/web-platform-tests/webxr/idlharness.https.window.html [ Failure ] >+imported/w3c/web-platform-tests/webxr/xrBoundedReferenceSpace_updates.https.html [ Pass ] > webkit.org/b/209859 imported/w3c/web-platform-tests/webxr/webGLCanvasContext_create_xrcompatible.https.html [ Pass ] > webkit.org/b/209859 imported/w3c/web-platform-tests/webxr/webGLCanvasContext_makecompatible_contextlost.https.html [ Pass ] > webkit.org/b/209859 imported/w3c/web-platform-tests/webxr/webGLCanvasContext_makecompatible_reentrant.https.html [ Pass ]
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 222737
:
422234
|
422241
| 422242