mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Added framebuffer and related attributes to XRWebGLLayer
This commit is contained in:
parent
dc1da02aa4
commit
aa0a72df0f
10 changed files with 158 additions and 46 deletions
|
@ -8,36 +8,26 @@ use crate::dom::bindings::reflector::{reflect_dom_object, Reflector};
|
|||
use crate::dom::bindings::root::DomRoot;
|
||||
use crate::dom::globalscope::GlobalScope;
|
||||
use dom_struct::dom_struct;
|
||||
use euclid::TypedRect;
|
||||
use webxr_api::Viewport;
|
||||
|
||||
#[dom_struct]
|
||||
pub struct XRViewport {
|
||||
reflector_: Reflector,
|
||||
x: u32,
|
||||
y: u32,
|
||||
width: u32,
|
||||
height: u32,
|
||||
viewport: TypedRect<i32, Viewport>,
|
||||
}
|
||||
|
||||
impl XRViewport {
|
||||
fn new_inherited(x: u32, y: u32, width: u32, height: u32) -> XRViewport {
|
||||
fn new_inherited(viewport: TypedRect<i32, Viewport>) -> XRViewport {
|
||||
XRViewport {
|
||||
reflector_: Reflector::new(),
|
||||
x,
|
||||
y,
|
||||
width,
|
||||
height,
|
||||
viewport,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new(
|
||||
global: &GlobalScope,
|
||||
x: u32,
|
||||
y: u32,
|
||||
width: u32,
|
||||
height: u32,
|
||||
) -> DomRoot<XRViewport> {
|
||||
pub fn new(global: &GlobalScope, viewport: TypedRect<i32, Viewport>) -> DomRoot<XRViewport> {
|
||||
reflect_dom_object(
|
||||
Box::new(XRViewport::new_inherited(x, y, width, height)),
|
||||
Box::new(XRViewport::new_inherited(viewport)),
|
||||
global,
|
||||
XRViewportBinding::Wrap,
|
||||
)
|
||||
|
@ -47,21 +37,21 @@ impl XRViewport {
|
|||
impl XRViewportMethods for XRViewport {
|
||||
/// https://immersive-web.github.io/webxr/#dom-xrviewport-x
|
||||
fn X(&self) -> i32 {
|
||||
self.x as i32
|
||||
self.viewport.origin.x
|
||||
}
|
||||
|
||||
/// https://immersive-web.github.io/webxr/#dom-xrviewport-y
|
||||
fn Y(&self) -> i32 {
|
||||
self.y as i32
|
||||
self.viewport.origin.y
|
||||
}
|
||||
|
||||
/// https://immersive-web.github.io/webxr/#dom-xrviewport-width
|
||||
fn Width(&self) -> i32 {
|
||||
self.width as i32
|
||||
self.viewport.size.width
|
||||
}
|
||||
|
||||
/// https://immersive-web.github.io/webxr/#dom-xrviewport-height
|
||||
fn Height(&self) -> i32 {
|
||||
self.height as i32
|
||||
self.viewport.size.height
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue