Update XRWebGLLayer to match specification.

This commit is contained in:
Josh Matthews 2020-07-17 14:13:09 -04:00
parent 9daadd03cc
commit c34e587140
59 changed files with 37 additions and 309 deletions

View file

@ -22,12 +22,8 @@ interface XRWebGLLayer {
XRWebGLRenderingContext context,
optional XRWebGLLayerInit layerInit = {});
// // Attributes
readonly attribute XRWebGLRenderingContext context;
readonly attribute boolean antialias;
readonly attribute boolean depth;
readonly attribute boolean stencil;
readonly attribute boolean alpha;
readonly attribute boolean ignoreDepthValues;
readonly attribute WebGLFramebuffer? framebuffer;
readonly attribute unsigned long framebufferWidth;
@ -35,7 +31,6 @@ interface XRWebGLLayer {
// // Methods
XRViewport? getViewport(XRView view);
// void requestViewportScaling(double viewportScaleFactor);
// // Static Methods
// static double getNativeFramebufferScaleFactor(XRSession session);

View file

@ -16,9 +16,7 @@ use crate::dom::bindings::codegen::Bindings::XRSessionBinding::XRFrameRequestCal
use crate::dom::bindings::codegen::Bindings::XRSessionBinding::XRSessionMethods;
use crate::dom::bindings::codegen::Bindings::XRSessionBinding::XRVisibilityState;
use crate::dom::bindings::codegen::Bindings::XRSystemBinding::XRSessionMode;
use crate::dom::bindings::codegen::Bindings::XRWebGLLayerBinding::{
XRWebGLLayerMethods, XRWebGLRenderingContext,
};
use crate::dom::bindings::codegen::Bindings::XRWebGLLayerBinding::XRWebGLRenderingContext;
use crate::dom::bindings::error::{Error, ErrorResult};
use crate::dom::bindings::inheritance::Castable;
use crate::dom::bindings::refcounted::Trusted;
@ -497,7 +495,7 @@ impl XRSession {
pub fn dirty_layers(&self) {
if let Some(layer) = self.RenderState().GetBaseLayer() {
match layer.Context() {
match layer.context() {
XRWebGLRenderingContext::WebGLRenderingContext(c) => c.mark_as_dirty(),
XRWebGLRenderingContext::WebGL2RenderingContext(c) => {
c.base_context().mark_as_dirty()

View file

@ -71,6 +71,7 @@ pub struct XRWebGLLayer {
depth: bool,
stencil: bool,
alpha: bool,
ignore_depth_values: bool,
context: RenderingContext,
session: Dom<XRSession>,
/// If none, this is an inline session (the composition disabled flag is true)
@ -94,6 +95,7 @@ impl XRWebGLLayer {
depth: init.depth,
stencil: init.stencil,
alpha: init.alpha,
ignore_depth_values: init.ignoreDepthValues,
layer_id,
context: match context {
XRWebGLRenderingContext::WebGLRenderingContext(ctx) => {
@ -276,31 +278,8 @@ impl XRWebGLLayer {
framebuffer.upcast::<WebGLObject>().context().Flush();
Some(())
}
}
impl XRWebGLLayerMethods for XRWebGLLayer {
/// https://immersive-web.github.io/webxr/#dom-xrwebgllayer-depth
fn Depth(&self) -> bool {
self.depth
}
/// https://immersive-web.github.io/webxr/#dom-xrwebgllayer-stencil
fn Stencil(&self) -> bool {
self.stencil
}
/// https://immersive-web.github.io/webxr/#dom-xrwebgllayer-antialias
fn Antialias(&self) -> bool {
self.antialias
}
/// https://immersive-web.github.io/webxr/#dom-xrwebgllayer-alpha
fn Alpha(&self) -> bool {
self.alpha
}
/// https://immersive-web.github.io/webxr/#dom-xrwebgllayer-context
fn Context(&self) -> XRWebGLRenderingContext {
pub(crate) fn context(&self) -> XRWebGLRenderingContext {
match self.context {
RenderingContext::WebGL1(ref ctx) => {
XRWebGLRenderingContext::WebGLRenderingContext(DomRoot::from_ref(&**ctx))
@ -310,6 +289,18 @@ impl XRWebGLLayerMethods for XRWebGLLayer {
},
}
}
}
impl XRWebGLLayerMethods for XRWebGLLayer {
/// https://immersive-web.github.io/webxr/#dom-xrwebgllayer-antialias
fn Antialias(&self) -> bool {
self.antialias
}
/// https://immersive-web.github.io/webxr/#dom-xrwebgllayer-ignoredepthvalues
fn IgnoreDepthValues(&self) -> bool {
self.ignore_depth_values
}
/// https://immersive-web.github.io/webxr/#dom-xrwebgllayer-framebuffer
fn GetFramebuffer(&self) -> Option<DomRoot<WebGLFramebuffer>> {