script/dom/webxr/
xrwebglsubimage.rs1use dom_struct::dom_struct;
6use euclid::Size2D;
7use webxr_api::Viewport;
8
9use crate::dom::bindings::codegen::Bindings::XRWebGLSubImageBinding::XRWebGLSubImage_Binding::XRWebGLSubImageMethods;
10use crate::dom::bindings::root::{Dom, DomRoot};
11use crate::dom::webgl::webgltexture::WebGLTexture;
12use crate::dom::xrsubimage::XRSubImage;
13
14#[dom_struct]
15pub(crate) struct XRWebGLSubImage {
16 xr_sub_image: XRSubImage,
17 color_texture: Dom<WebGLTexture>,
18 depth_stencil_texture: Option<Dom<WebGLTexture>>,
19 image_index: Option<u32>,
20 #[no_trace]
21 size: Size2D<u32, Viewport>,
22}
23
24impl XRWebGLSubImageMethods<crate::DomTypeHolder> for XRWebGLSubImage {
25 fn ColorTexture(&self) -> DomRoot<WebGLTexture> {
27 DomRoot::from_ref(&self.color_texture)
28 }
29
30 fn GetDepthStencilTexture(&self) -> Option<DomRoot<WebGLTexture>> {
32 self.depth_stencil_texture.as_deref().map(DomRoot::from_ref)
33 }
34
35 fn GetImageIndex(&self) -> Option<u32> {
37 self.image_index
38 }
39
40 fn TextureWidth(&self) -> u32 {
42 self.size.width
43 }
44
45 fn TextureHeight(&self) -> u32 {
47 self.size.height
48 }
49}