Skip to content

Commit

Permalink
Init XR present on XR::RequestSession() with empty context
Browse files Browse the repository at this point in the history
  • Loading branch information
Manishearth committed Jan 7, 2019
1 parent 121cbd0 commit 90e87b9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
6 changes: 3 additions & 3 deletions components/script/dom/vrdisplay.rs
Expand Up @@ -688,12 +688,12 @@ impl VRDisplay {
// XR stuff
// XXXManishearth eventually we should share as much logic as possible
impl VRDisplay {
pub fn xr_present(&self, session: &XRSession, ctx: &WebGLRenderingContext) {
pub fn xr_present(&self, session: &XRSession, ctx: Option<&WebGLRenderingContext>) {
let layer_bounds = WebVRLayer::default();
self.xr_session.set(Some(session));
if self.presenting.get() {
*self.layer.borrow_mut() = layer_bounds;
self.layer_ctx.set(Some(&ctx));
self.layer_ctx.set(ctx);
return;
}

Expand All @@ -709,7 +709,7 @@ impl VRDisplay {

if let Ok(()) = receiver.recv().unwrap() {
*self.layer.borrow_mut() = layer_bounds;
self.layer_ctx.set(Some(&ctx));
self.layer_ctx.set(ctx);
self.init_present();
}
}
Expand Down
5 changes: 2 additions & 3 deletions components/script/dom/xr.rs
Expand Up @@ -95,10 +95,9 @@ impl XRMethods for XR {
}

let session = XRSession::new(&self.global(), &displays[0]);
// XXXManishearth we should actually xr_present() here instead of
// in XRSession::new, and resolve a promise based on it
promise.resolve_native(&session);
// whether or not we should initiate presentation is unclear
// https://github.com/immersive-web/webxr/issues/453

promise
}
}
Expand Down
8 changes: 5 additions & 3 deletions components/script/dom/xrsession.rs
Expand Up @@ -37,11 +37,13 @@ impl XRSession {
}

pub fn new(global: &GlobalScope, display: &VRDisplay) -> DomRoot<XRSession> {
reflect_dom_object(
let ret = reflect_dom_object(
Box::new(XRSession::new_inherited(display)),
global,
XRSessionBinding::Wrap,
)
);
ret.display.xr_present(&ret, None);
ret
}
}

Expand Down Expand Up @@ -76,7 +78,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, &layer.Context());
self.display.xr_present(&self, Some(&layer.Context()));
} else {
// steps unknown
// https://github.com/immersive-web/webxr/issues/453
Expand Down

0 comments on commit 90e87b9

Please sign in to comment.