diff options
author | Daniel Adams <70986246+msub2@users.noreply.github.com> | 2024-08-21 16:18:58 -1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-22 02:18:58 +0000 |
commit | 562d32c0519d58052cea681a696546fd4818bd3a (patch) | |
tree | 99a4ea2c114d5d8e305473f997a978780e5d19ba /components/script | |
parent | cde10241c32208fbce0cb87f2d6a6deeca2c74a4 (diff) | |
download | servo-562d32c0519d58052cea681a696546fd4818bd3a.tar.gz servo-562d32c0519d58052cea681a696546fd4818bd3a.zip |
webxr: Update XRWebGLLayer interface to latest spec (#33157)
* Update XRWebGLLayer interface to latest spec
Signed-off-by: Daniel Adams <msub2official@gmail.com>
* Add missing spec links
Signed-off-by: Daniel Adams <msub2official@gmail.com>
---------
Signed-off-by: Daniel Adams <msub2official@gmail.com>
Diffstat (limited to 'components/script')
-rw-r--r-- | components/script/dom/webidls/XRWebGLLayer.webidl | 5 | ||||
-rw-r--r-- | components/script/dom/xrwebgllayer.rs | 19 |
2 files changed, 22 insertions, 2 deletions
diff --git a/components/script/dom/webidls/XRWebGLLayer.webidl b/components/script/dom/webidls/XRWebGLLayer.webidl index 0007b457f8e..5b26716ebd2 100644 --- a/components/script/dom/webidls/XRWebGLLayer.webidl +++ b/components/script/dom/webidls/XRWebGLLayer.webidl @@ -24,6 +24,7 @@ interface XRWebGLLayer: XRLayer { // Attributes readonly attribute boolean antialias; readonly attribute boolean ignoreDepthValues; + attribute float? fixedFoveation; [SameObject] readonly attribute WebGLFramebuffer? framebuffer; readonly attribute unsigned long framebufferWidth; @@ -32,8 +33,8 @@ interface XRWebGLLayer: XRLayer { // Methods XRViewport? getViewport(XRView view); - // // Static Methods - // static double getNativeFramebufferScaleFactor(XRSession session); + // Static Methods + static double getNativeFramebufferScaleFactor(XRSession session); }; partial interface mixin WebGLRenderingContextBase { diff --git a/components/script/dom/xrwebgllayer.rs b/components/script/dom/xrwebgllayer.rs index 933e8537f1d..6a86671ccff 100644 --- a/components/script/dom/xrwebgllayer.rs +++ b/components/script/dom/xrwebgllayer.rs @@ -17,6 +17,7 @@ use crate::dom::bindings::codegen::Bindings::XRWebGLLayerBinding::{ }; use crate::dom::bindings::error::{Error, Fallible}; use crate::dom::bindings::inheritance::Castable; +use crate::dom::bindings::num::Finite; use crate::dom::bindings::reflector::{reflect_dom_object_with_proto, DomObject}; use crate::dom::bindings::root::{Dom, DomRoot}; use crate::dom::globalscope::GlobalScope; @@ -156,6 +157,13 @@ impl XRWebGLLayer { )) } + /// <https://www.w3.org/TR/webxr/#dom-xrwebgllayer-getnativeframebufferscalefactor> + #[allow(non_snake_case)] + pub fn GetNativeFramebufferScaleFactor(_window: &Window, session: &XRSession) -> Finite<f64> { + let value: f64 = if session.is_ended() { 0.0 } else { 1.0 }; + Finite::wrap(value) + } + pub fn layer_id(&self) -> Option<LayerId> { self.xr_layer.layer_id() } @@ -292,6 +300,17 @@ impl XRWebGLLayerMethods for XRWebGLLayer { self.ignore_depth_values } + /// <https://www.w3.org/TR/webxr/#dom-xrwebgllayer-fixedfoveation> + fn GetFixedFoveation(&self) -> Option<Finite<f32>> { + // Fixed foveation is only available on Quest/Pico headset runtimes + None + } + + /// <https://www.w3.org/TR/webxr/#dom-xrwebgllayer-fixedfoveation> + fn SetFixedFoveation(&self, _value: Option<Finite<f32>>) { + // no-op until fixed foveation is supported + } + /// <https://immersive-web.github.io/webxr/#dom-xrwebgllayer-framebuffer> fn GetFramebuffer(&self) -> Option<DomRoot<WebGLFramebuffer>> { self.framebuffer.as_ref().map(|x| DomRoot::from_ref(&**x)) |