Add a dummy implementation of all the XR Layer types

This commit is contained in:
Alan Jeffrey 2020-08-04 15:10:01 -05:00
parent 754019f6bc
commit d255dc9f7b
18 changed files with 337 additions and 85 deletions

View file

@ -599,6 +599,10 @@ pub mod xmlhttprequest;
pub mod xmlhttprequesteventtarget;
pub mod xmlhttprequestupload;
pub mod xmlserializer;
pub mod xrcompositionlayer;
pub mod xrcubelayer;
pub mod xrcylinderlayer;
pub mod xrequirectlayer;
pub mod xrframe;
pub mod xrhand;
pub mod xrhittestresult;
@ -612,6 +616,8 @@ pub mod xrjointspace;
pub mod xrlayer;
pub mod xrmediabinding;
pub mod xrpose;
pub mod xrprojectionlayer;
pub mod xrquadlayer;
pub mod xrray;
pub mod xrreferencespace;
pub mod xrrenderstate;

View file

@ -0,0 +1,20 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
// TODO: Implement the layer types
// https://github.com/servo/servo/issues/27493
// https://immersive-web.github.io/layers/#xrcompositionlayer
[SecureContext, Exposed=Window, Pref="dom.webxr.layers.enabled"]
interface XRCompositionLayer : XRLayer {
// readonly attribute XRLayerLayout layout;
//
// attribute boolean blendTextureSourceAlpha;
// attribute boolean? chromaticAberrationCorrection;
// attribute float? fixedFoveation;
//
// readonly attribute boolean needsRedraw;
//
// void destroy();
};

View file

@ -0,0 +1,17 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
// TODO: Implement the layer types
// https://github.com/servo/servo/issues/27493
// https://immersive-web.github.io/layers/#xrcubelayer
[SecureContext, Exposed=Window, Pref="dom.webxr.layers.enabled"]
interface XRCubeLayer : XRCompositionLayer {
// attribute XRSpace space;
// attribute DOMPointReadOnly orientation;
//
// // Events
// attribute EventHandler onredraw;
};

View file

@ -0,0 +1,20 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
// TODO: Implement the layer types
// https://github.com/servo/servo/issues/27493
// https://immersive-web.github.io/layers/#xrcylinderlayer
[SecureContext, Exposed=Window, Pref="dom.webxr.layers.enabled"]
interface XRCylinderLayer : XRCompositionLayer {
// attribute XRSpace space;
// attribute XRRigidTransform transform;
//
// attribute float radius;
// attribute float centralAngle;
// attribute float aspectRatio;
//
// // Events
// attribute EventHandler onredraw;
};

View file

@ -0,0 +1,21 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
// TODO: Implement the layer types
// https://github.com/servo/servo/issues/27493
// https://immersive-web.github.io/layers/#xrequirectlayer
[SecureContext, Exposed=Window, Pref="dom.webxr.layers.enabled"]
interface XREquirectLayer : XRCompositionLayer {
// attribute XRSpace space;
// attribute XRRigidTransform transform;
//
// attribute float radius;
// attribute float centralHorizontalAngle;
// attribute float upperVerticalAngle;
// attribute float lowerVerticalAngle;
//
// // Events
// attribute EventHandler onredraw;
};

View file

@ -5,71 +5,3 @@
// https://immersive-web.github.io/webxr/#xrlayer
[SecureContext, Exposed=Window, Pref="dom.webxr.enabled"]
interface XRLayer : EventTarget {};
// TODO: Implement the layer types
//
// [SecureContext, Exposed=Window, Pref="dom.webxr.layers.enabled"]
// interface XRCompositionLayer : XRLayer {
// readonly attribute XRLayerLayout layout;
//
// attribute boolean blendTextureSourceAlpha;
// attribute boolean? chromaticAberrationCorrection;
// attribute float? fixedFoveation;
//
// readonly attribute boolean needsRedraw;
//
// void destroy();
// };
//
// [SecureContext, Exposed=Window, Pref="dom.webxr.layers.enabled"]
// interface XRProjectionLayer : XRCompositionLayer {
// readonly attribute boolean ignoreDepthValues;
// };
//
// [SecureContext, Exposed=Window, Pref="dom.webxr.layers.enabled"]
// interface XRQuadLayer : XRCompositionLayer {
// attribute XRSpace space;
// attribute XRRigidTransform transform;
//
// attribute float width;
// attribute float height;
//
// // Events
// attribute EventHandler onredraw;
// };
//
// [SecureContext, Exposed=Window, Pref="dom.webxr.layers.enabled"]
// interface XRCylinderLayer : XRCompositionLayer {
// attribute XRSpace space;
// attribute XRRigidTransform transform;
//
// attribute float radius;
// attribute float centralAngle;
// attribute float aspectRatio;
//
// // Events
// attribute EventHandler onredraw;
// };
//
// [SecureContext, Exposed=Window, Pref="dom.webxr.layers.enabled"]
// interface XREquirectLayer : XRCompositionLayer {
// attribute XRSpace space;
// attribute XRRigidTransform transform;
//
// attribute float radius;
// attribute float centralHorizontalAngle;
// attribute float upperVerticalAngle;
// attribute float lowerVerticalAngle;
//
// // Events
// attribute EventHandler onredraw;
// };
//
// [SecureContext, Exposed=Window, Pref="dom.webxr.layers.enabled"]
// interface XRCubeLayer : XRCompositionLayer {
// attribute XRSpace space;
// attribute DOMPointReadOnly orientation;
//
// // Events
// attribute EventHandler onredraw;
// };

View file

@ -5,11 +5,11 @@
// https://immersive-web.github.io/layers/#xrmediabindingtype
[SecureContext, Exposed=Window, Pref="dom.webxr.layers.enabled"]
interface XRMediaBinding {
constructor(XRSession session);
[Throws] constructor(XRSession session);
// XRQuadLayer createQuadVideoLayer(HTMLVideoElement video, optional XRMediaLayerInit init = {});
// XRCylinderLayer createCylinderVideoLayer(HTMLVideoElement video, optional XRMediaLayerInit init = {});
// XREquirectLayer createEquirectVideoLayer(HTMLVideoElement video, optional XRMediaLayerInit init = {});
[Throws] XRQuadLayer createQuadLayer(HTMLVideoElement video, XRMediaLayerInit init);
[Throws] XRCylinderLayer createCylinderLayer(HTMLVideoElement video, XRMediaLayerInit init);
[Throws] XREquirectLayer createEquirectLayer(HTMLVideoElement video, XRMediaLayerInit init);
};
dictionary XRMediaLayerInit {

View file

@ -0,0 +1,12 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
// TODO: Implement the layer types
// https://github.com/servo/servo/issues/27493
// https://immersive-web.github.io/layers/#xrprojectionlayer
[SecureContext, Exposed=Window, Pref="dom.webxr.layers.enabled"]
interface XRProjectionLayer : XRCompositionLayer {
// readonly attribute boolean ignoreDepthValues;
};

View file

@ -0,0 +1,19 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
// TODO: Implement the layer types
// https://github.com/servo/servo/issues/27493
// https://immersive-web.github.io/layers/#xrquadlayer
[SecureContext, Exposed=Window, Pref="dom.webxr.layers.enabled"]
interface XRQuadLayer : XRCompositionLayer {
// attribute XRSpace space;
// attribute XRRigidTransform transform;
//
// attribute float width;
// attribute float height;
//
// // Events
// attribute EventHandler onredraw;
};

View file

@ -9,18 +9,18 @@ interface XRWebGLBinding {
// readonly attribute double nativeProjectionScaleFactor;
// XRProjectionLayer createProjectionLayer(XRTextureType textureType,
// optional XRProjectionLayerInit init);
// XRQuadLayer createQuadLayer(XRTextureType textureType,
// optional XRQuadLayerInit init);
// XRCylinderLayer createCylinderLayer(XRTextureType textureType,
// optional XRCylinderLayerInit init);
// XREquirectLayer createEquirectLayer(XRTextureType textureType,
// optional XREquirectLayerInit init);
// XRCubeLayer createCubeLayer(optional XRCubeLayerInit init);
[Throws] XRProjectionLayer createProjectionLayer(XRTextureType textureType,
optional XRProjectionLayerInit init = {});
[Throws] XRQuadLayer createQuadLayer(XRTextureType textureType,
optional XRQuadLayerInit init);
[Throws] XRCylinderLayer createCylinderLayer(XRTextureType textureType,
optional XRCylinderLayerInit init);
[Throws] XREquirectLayer createEquirectLayer(XRTextureType textureType,
optional XREquirectLayerInit init);
[Throws] XRCubeLayer createCubeLayer(optional XRCubeLayerInit init);
// XRWebGLSubImage getSubImage(XRCompositionLayer layer, XRFrame frame, optional XREye eye = "none");
// XRWebGLSubImage getViewSubImage(XRProjectionLayer layer, XRView view);
[Throws] XRWebGLSubImage getSubImage(XRCompositionLayer layer, XRFrame frame, optional XREye eye = "none");
[Throws] XRWebGLSubImage getViewSubImage(XRProjectionLayer layer, XRView view);
};
dictionary XRProjectionLayerInit {

View file

@ -0,0 +1,11 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use crate::dom::xrlayer::XRLayer;
use dom_struct::dom_struct;
#[dom_struct]
pub struct XRCompositionLayer {
xr_layer: XRLayer,
}

View file

@ -0,0 +1,11 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use crate::dom::xrcompositionlayer::XRCompositionLayer;
use dom_struct::dom_struct;
#[dom_struct]
pub struct XRCubeLayer {
composition_layer: XRCompositionLayer,
}

View file

@ -0,0 +1,11 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use crate::dom::xrcompositionlayer::XRCompositionLayer;
use dom_struct::dom_struct;
#[dom_struct]
pub struct XRCylinderLayer {
composition_layer: XRCompositionLayer,
}

View file

@ -0,0 +1,11 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use crate::dom::xrcompositionlayer::XRCompositionLayer;
use dom_struct::dom_struct;
#[dom_struct]
pub struct XREquirectLayer {
composition_layer: XRCompositionLayer,
}

View file

@ -2,11 +2,19 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use crate::dom::bindings::codegen::Bindings::XRMediaBindingBinding::XRMediaBindingBinding::XRMediaBindingMethods;
use crate::dom::bindings::codegen::Bindings::XRMediaBindingBinding::XRMediaLayerInit;
use crate::dom::bindings::error::Error;
use crate::dom::bindings::error::Fallible;
use crate::dom::bindings::reflector::reflect_dom_object;
use crate::dom::bindings::reflector::Reflector;
use crate::dom::bindings::root::Dom;
use crate::dom::bindings::root::DomRoot;
use crate::dom::htmlvideoelement::HTMLVideoElement;
use crate::dom::window::Window;
use crate::dom::xrcylinderlayer::XRCylinderLayer;
use crate::dom::xrequirectlayer::XREquirectLayer;
use crate::dom::xrquadlayer::XRQuadLayer;
use crate::dom::xrsession::XRSession;
use dom_struct::dom_struct;
@ -29,7 +37,50 @@ impl XRMediaBinding {
}
#[allow(non_snake_case)]
pub fn Constructor(global: &Window, session: &XRSession) -> DomRoot<XRMediaBinding> {
XRMediaBinding::new(global, session)
pub fn Constructor(global: &Window, session: &XRSession) -> Fallible<DomRoot<XRMediaBinding>> {
// Step 1.
if session.is_ended() {
return Err(Error::InvalidState);
}
// Step 2.
if !session.is_immersive() {
return Err(Error::InvalidState);
}
// Steps 3-5.
Ok(XRMediaBinding::new(global, session))
}
}
impl XRMediaBindingMethods for XRMediaBinding {
/// https://immersive-web.github.io/layers/#dom-xrmediabinding-createquadlayer
fn CreateQuadLayer(
&self,
_: &HTMLVideoElement,
_: &XRMediaLayerInit,
) -> Fallible<DomRoot<XRQuadLayer>> {
// https://github.com/servo/servo/issues/27493
Err(Error::NotSupported)
}
/// https://immersive-web.github.io/layers/#dom-xrmediabinding-createcylinderlayer
fn CreateCylinderLayer(
&self,
_: &HTMLVideoElement,
_: &XRMediaLayerInit,
) -> Fallible<DomRoot<XRCylinderLayer>> {
// https://github.com/servo/servo/issues/27493
Err(Error::NotSupported)
}
/// https://immersive-web.github.io/layers/#dom-xrmediabinding-createequirectlayer
fn CreateEquirectLayer(
&self,
_: &HTMLVideoElement,
_: &XRMediaLayerInit,
) -> Fallible<DomRoot<XREquirectLayer>> {
// https://github.com/servo/servo/issues/27493
Err(Error::NotSupported)
}
}

View file

@ -0,0 +1,11 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use crate::dom::xrcompositionlayer::XRCompositionLayer;
use dom_struct::dom_struct;
#[dom_struct]
pub struct XRProjectionLayer {
composition_layer: XRCompositionLayer,
}

View file

@ -0,0 +1,11 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use crate::dom::xrcompositionlayer::XRCompositionLayer;
use dom_struct::dom_struct;
#[dom_struct]
pub struct XRQuadLayer {
composition_layer: XRCompositionLayer,
}

View file

@ -2,14 +2,33 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use crate::dom::bindings::codegen::Bindings::XRViewBinding::XREye;
use crate::dom::bindings::codegen::Bindings::XRWebGLBindingBinding::XRCubeLayerInit;
use crate::dom::bindings::codegen::Bindings::XRWebGLBindingBinding::XRCylinderLayerInit;
use crate::dom::bindings::codegen::Bindings::XRWebGLBindingBinding::XREquirectLayerInit;
use crate::dom::bindings::codegen::Bindings::XRWebGLBindingBinding::XRProjectionLayerInit;
use crate::dom::bindings::codegen::Bindings::XRWebGLBindingBinding::XRQuadLayerInit;
use crate::dom::bindings::codegen::Bindings::XRWebGLBindingBinding::XRTextureType;
use crate::dom::bindings::codegen::Bindings::XRWebGLBindingBinding::XRWebGLBindingBinding::XRWebGLBindingMethods;
use crate::dom::bindings::codegen::UnionTypes::WebGLRenderingContextOrWebGL2RenderingContext;
use crate::dom::bindings::error::Error;
use crate::dom::bindings::error::Fallible;
use crate::dom::bindings::reflector::reflect_dom_object;
use crate::dom::bindings::reflector::Reflector;
use crate::dom::bindings::root::Dom;
use crate::dom::bindings::root::DomRoot;
use crate::dom::webglrenderingcontext::WebGLRenderingContext;
use crate::dom::window::Window;
use crate::dom::xrcompositionlayer::XRCompositionLayer;
use crate::dom::xrcubelayer::XRCubeLayer;
use crate::dom::xrcylinderlayer::XRCylinderLayer;
use crate::dom::xrequirectlayer::XREquirectLayer;
use crate::dom::xrframe::XRFrame;
use crate::dom::xrprojectionlayer::XRProjectionLayer;
use crate::dom::xrquadlayer::XRQuadLayer;
use crate::dom::xrsession::XRSession;
use crate::dom::xrview::XRView;
use crate::dom::xrwebglsubimage::XRWebGLSubImage;
use dom_struct::dom_struct;
#[dom_struct]
@ -54,3 +73,72 @@ impl XRWebGLBinding {
XRWebGLBinding::new(global, session, &context)
}
}
impl XRWebGLBindingMethods for XRWebGLBinding {
/// https://immersive-web.github.io/layers/#dom-xrwebglbinding-createprojectionlayer
fn CreateProjectionLayer(
&self,
_: XRTextureType,
_: &XRProjectionLayerInit,
) -> Fallible<DomRoot<XRProjectionLayer>> {
// https://github.com/servo/servo/issues/27468
Err(Error::NotSupported)
}
/// https://immersive-web.github.io/layers/#dom-xrwebglbinding-createquadlayer
fn CreateQuadLayer(
&self,
_: XRTextureType,
_: &Option<XRQuadLayerInit>,
) -> Fallible<DomRoot<XRQuadLayer>> {
// https://github.com/servo/servo/issues/27493
Err(Error::NotSupported)
}
/// https://immersive-web.github.io/layers/#dom-xrwebglbinding-createcylinderlayer
fn CreateCylinderLayer(
&self,
_: XRTextureType,
_: &Option<XRCylinderLayerInit>,
) -> Fallible<DomRoot<XRCylinderLayer>> {
// https://github.com/servo/servo/issues/27493
Err(Error::NotSupported)
}
/// https://immersive-web.github.io/layers/#dom-xrwebglbinding-createequirectlayer
fn CreateEquirectLayer(
&self,
_: XRTextureType,
_: &Option<XREquirectLayerInit>,
) -> Fallible<DomRoot<XREquirectLayer>> {
// https://github.com/servo/servo/issues/27493
Err(Error::NotSupported)
}
/// https://immersive-web.github.io/layers/#dom-xrwebglbinding-createcubelayer
fn CreateCubeLayer(&self, _: &Option<XRCubeLayerInit>) -> Fallible<DomRoot<XRCubeLayer>> {
// https://github.com/servo/servo/issues/27493
Err(Error::NotSupported)
}
/// https://immersive-web.github.io/layers/#dom-xrwebglbinding-getsubimage
fn GetSubImage(
&self,
_: &XRCompositionLayer,
_: &XRFrame,
_: XREye,
) -> Fallible<DomRoot<XRWebGLSubImage>> {
// https://github.com/servo/servo/issues/27468
Err(Error::NotSupported)
}
/// https://immersive-web.github.io/layers/#dom-xrwebglbinding-getviewsubimage
fn GetViewSubImage(
&self,
_: &XRProjectionLayer,
_: &XRView,
) -> Fallible<DomRoot<XRWebGLSubImage>> {
// https://github.com/servo/servo/issues/27468
Err(Error::NotSupported)
}
}