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>
This commit is contained in:
Daniel Adams 2024-08-21 16:18:58 -10:00 committed by GitHub
parent cde10241c3
commit 562d32c051
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 22 additions and 14 deletions

View file

@ -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 {

View file

@ -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))

View file

@ -20,9 +20,6 @@
[XRBoundedReferenceSpace interface object length]
expected: FAIL
[XRWebGLLayer interface: operation getNativeFramebufferScaleFactor(XRSession)]
expected: FAIL
[XRRay interface: attribute matrix]
expected: FAIL
@ -314,9 +311,6 @@
[XRSession interface: calling cancelAnimationFrame(unsigned long) on xrSession with too few arguments must throw TypeError]
expected: FAIL
[XRWebGLLayer interface: attribute fixedFoveation]
expected: FAIL
[XRWebGLLayer interface: xrWebGLLayer must inherit property "fixedFoveation" with the proper type]
expected: FAIL

View file

@ -56,9 +56,6 @@
[XRBoundedReferenceSpace interface object length]
expected: FAIL
[XRWebGLLayer interface: operation getNativeFramebufferScaleFactor(XRSession)]
expected: FAIL
[XRWebGLLayer interface: xrWebGLLayer must inherit property "framebuffer" with the proper type]
expected: FAIL
@ -257,9 +254,6 @@
[XRSession interface: calling cancelAnimationFrame(unsigned long) on xrSession with too few arguments must throw TypeError]
expected: FAIL
[XRWebGLLayer interface: attribute fixedFoveation]
expected: FAIL
[XRWebGLLayer interface: xrWebGLLayer must inherit property "fixedFoveation" with the proper type]
expected: FAIL