mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Fill in some of XRWebGLLayer
This commit is contained in:
parent
682c89a18c
commit
70e8a19200
2 changed files with 69 additions and 17 deletions
|
@ -4,29 +4,30 @@
|
||||||
|
|
||||||
// https://immersive-web.github.io/webxr/#xrwebgllayer-interface
|
// https://immersive-web.github.io/webxr/#xrwebgllayer-interface
|
||||||
|
|
||||||
typedef (WebGLRenderingContext or
|
// typedef (WebGLRenderingContext or
|
||||||
WebGL2RenderingContext) XRWebGLRenderingContext;
|
// WebGL2RenderingContext) XRWebGLRenderingContext;
|
||||||
|
|
||||||
|
typedef WebGLRenderingContext XRWebGLRenderingContext;
|
||||||
|
|
||||||
dictionary XRWebGLLayerInit {
|
dictionary XRWebGLLayerInit {
|
||||||
boolean antialias = true;
|
boolean antialias = true;
|
||||||
boolean depth = true;
|
boolean depth = true;
|
||||||
boolean stencil = false;
|
boolean stencil = false;
|
||||||
boolean alpha = true;
|
boolean alpha = true;
|
||||||
double framebufferScaleFactor = 1.0;
|
// double framebufferScaleFactor = 1.0;
|
||||||
};
|
};
|
||||||
|
|
||||||
[SecureContext, Exposed=Window]
|
[SecureContext, Exposed=Window, Constructor(XRSession session,
|
||||||
// [Constructor(XRSession session,
|
XRWebGLRenderingContext context,
|
||||||
// XRWebGLRenderingContext context,
|
optional XRWebGLLayerInit layerInit)]
|
||||||
// optional XRWebGLLayerInit layerInit)]
|
|
||||||
interface XRWebGLLayer : XRLayer {
|
interface XRWebGLLayer : XRLayer {
|
||||||
// // Attributes
|
// // Attributes
|
||||||
// readonly attribute XRWebGLRenderingContext context;
|
readonly attribute XRWebGLRenderingContext context;
|
||||||
|
|
||||||
// readonly attribute boolean antialias;
|
readonly attribute boolean antialias;
|
||||||
// readonly attribute boolean depth;
|
readonly attribute boolean depth;
|
||||||
// readonly attribute boolean stencil;
|
readonly attribute boolean stencil;
|
||||||
// readonly attribute boolean alpha;
|
readonly attribute boolean alpha;
|
||||||
|
|
||||||
// readonly attribute WebGLFramebuffer framebuffer;
|
// readonly attribute WebGLFramebuffer framebuffer;
|
||||||
// readonly attribute unsigned long framebufferWidth;
|
// readonly attribute unsigned long framebufferWidth;
|
||||||
|
|
|
@ -3,29 +3,80 @@
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use crate::dom::bindings::codegen::Bindings::XRWebGLLayerBinding;
|
use crate::dom::bindings::codegen::Bindings::XRWebGLLayerBinding;
|
||||||
use crate::dom::bindings::reflector::reflect_dom_object;
|
use crate::dom::bindings::codegen::Bindings::XRWebGLLayerBinding::XRWebGLLayerMethods;
|
||||||
use crate::dom::bindings::root::DomRoot;
|
use crate::dom::bindings::codegen::Bindings::XRWebGLLayerBinding::XRWebGLLayerInit;
|
||||||
|
use crate::dom::bindings::error::Fallible;
|
||||||
|
use crate::dom::bindings::reflector::{DomObject, reflect_dom_object};
|
||||||
|
use crate::dom::bindings::root::{Dom, DomRoot};
|
||||||
use crate::dom::globalscope::GlobalScope;
|
use crate::dom::globalscope::GlobalScope;
|
||||||
|
use crate::dom::webglrenderingcontext::WebGLRenderingContext;
|
||||||
|
use crate::dom::window::Window;
|
||||||
use crate::dom::xrlayer::XRLayer;
|
use crate::dom::xrlayer::XRLayer;
|
||||||
|
use crate::dom::xrsession::XRSession;
|
||||||
use dom_struct::dom_struct;
|
use dom_struct::dom_struct;
|
||||||
|
|
||||||
|
use std::cell::Cell;
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
pub struct XRWebGLLayer {
|
pub struct XRWebGLLayer {
|
||||||
xrlayer: XRLayer,
|
xrlayer: XRLayer,
|
||||||
|
antialias: Cell<bool>,
|
||||||
|
depth: Cell<bool>,
|
||||||
|
stencil: Cell<bool>,
|
||||||
|
alpha: Cell<bool>,
|
||||||
|
context: Dom<WebGLRenderingContext>,
|
||||||
|
session: Dom<XRSession>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl XRWebGLLayer {
|
impl XRWebGLLayer {
|
||||||
pub fn new_inherited() -> XRWebGLLayer {
|
pub fn new_inherited(session: &XRSession, context: &WebGLRenderingContext,
|
||||||
|
init: &XRWebGLLayerInit) -> XRWebGLLayer {
|
||||||
XRWebGLLayer {
|
XRWebGLLayer {
|
||||||
xrlayer: XRLayer::new_inherited(),
|
xrlayer: XRLayer::new_inherited(),
|
||||||
|
antialias: Cell::new(init.antialias),
|
||||||
|
depth: Cell::new(init.depth),
|
||||||
|
stencil: Cell::new(init.stencil),
|
||||||
|
alpha: Cell::new(init.alpha),
|
||||||
|
context: Dom::from_ref(context),
|
||||||
|
session: Dom::from_ref(session),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(global: &GlobalScope) -> DomRoot<XRWebGLLayer> {
|
pub fn new(global: &GlobalScope, session: &XRSession, context: &WebGLRenderingContext,
|
||||||
|
init: &XRWebGLLayerInit) -> DomRoot<XRWebGLLayer> {
|
||||||
reflect_dom_object(
|
reflect_dom_object(
|
||||||
Box::new(XRWebGLLayer::new_inherited()),
|
Box::new(XRWebGLLayer::new_inherited(session, context, init)),
|
||||||
global,
|
global,
|
||||||
XRWebGLLayerBinding::Wrap,
|
XRWebGLLayerBinding::Wrap,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn Constructor(global: &Window, session: &XRSession,
|
||||||
|
context: &WebGLRenderingContext,
|
||||||
|
init: &XRWebGLLayerInit) -> Fallible<DomRoot<Self>> {
|
||||||
|
Ok(XRWebGLLayer::new(&global.global(), session, context, init))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl XRWebGLLayerMethods for XRWebGLLayer {
|
||||||
|
fn Depth(&self) -> bool {
|
||||||
|
self.depth.get()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn Stencil(&self) -> bool {
|
||||||
|
self.stencil.get()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn Antialias(&self) -> bool {
|
||||||
|
self.antialias.get()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn Alpha(&self) -> bool {
|
||||||
|
self.alpha.get()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn Context(&self) -> DomRoot<WebGLRenderingContext> {
|
||||||
|
DomRoot::from_ref(&self.context)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue