Use async VR presentation code for XRSession

This commit is contained in:
Manish Goregaokar 2019-01-07 17:59:06 -08:00
parent 9ddbf68cb3
commit e2522d36ff
3 changed files with 37 additions and 42 deletions

View file

@ -14,6 +14,7 @@ use crate::dom::bindings::reflector::reflect_dom_object;
use crate::dom::bindings::root::{Dom, DomRoot, MutNullableDom};
use crate::dom::eventtarget::EventTarget;
use crate::dom::globalscope::GlobalScope;
use crate::dom::promise::Promise;
use crate::dom::vrdisplay::VRDisplay;
use crate::dom::xrlayer::XRLayer;
use crate::dom::xrwebgllayer::XRWebGLLayer;
@ -37,13 +38,15 @@ impl XRSession {
}
pub fn new(global: &GlobalScope, display: &VRDisplay) -> DomRoot<XRSession> {
let ret = reflect_dom_object(
reflect_dom_object(
Box::new(XRSession::new_inherited(display)),
global,
XRSessionBinding::Wrap,
);
ret.display.xr_present(&ret, None);
ret
)
}
pub fn xr_present(&self, p: Rc<Promise>) {
self.display.xr_present(self, None, Some(p));
}
}
@ -78,7 +81,7 @@ impl XRSessionMethods for XRSession {
self.base_layer.set(layer);
if let Some(layer) = layer {
let layer = layer.downcast::<XRWebGLLayer>().unwrap();
self.display.xr_present(&self, Some(&layer.Context()));
self.display.xr_present(&self, Some(&layer.Context()), None);
} else {
// steps unknown
// https://github.com/immersive-web/webxr/issues/453