mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Simple presentation
This commit is contained in:
parent
70e8a19200
commit
e259ff727e
3 changed files with 43 additions and 1 deletions
|
@ -664,6 +664,35 @@ impl VRDisplay {
|
|||
}
|
||||
}
|
||||
|
||||
// XR stuff
|
||||
// XXXManishearth eventually we should share as much logic as possible
|
||||
impl VRDisplay {
|
||||
pub fn xr_present(&self, ctx: &WebGLRenderingContext) {
|
||||
let layer_bounds = WebVRLayer::default();
|
||||
self.xr.set(true);
|
||||
if self.presenting.get() {
|
||||
*self.layer.borrow_mut() = layer_bounds;
|
||||
self.layer_ctx.set(Some(&ctx));
|
||||
return;
|
||||
}
|
||||
|
||||
// Request Present
|
||||
let (sender, receiver) = ipc::channel(self.global().time_profiler_chan().clone()).unwrap();
|
||||
self.webvr_thread()
|
||||
.send(WebVRMsg::RequestPresent(
|
||||
self.global().pipeline_id(),
|
||||
self.display.borrow().display_id,
|
||||
sender,
|
||||
)).unwrap();
|
||||
|
||||
if let Ok(()) = receiver.recv().unwrap() {
|
||||
*self.layer.borrow_mut() = layer_bounds;
|
||||
self.layer_ctx.set(Some(&ctx));
|
||||
self.init_present();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// WebVR Spec: If the number of values in the leftBounds/rightBounds arrays
|
||||
// is not 0 or 4 for any of the passed layers the promise is rejected
|
||||
fn parse_bounds(src: &Option<Vec<Finite<f32>>>, dst: &mut [f32; 4]) -> Result<(), &'static str> {
|
||||
|
|
|
@ -89,12 +89,15 @@ impl XRMethods for XR {
|
|||
},
|
||||
};
|
||||
|
||||
// XXXManishearth filter for displays which can_present
|
||||
if displays.is_empty() {
|
||||
promise.reject_error(Error::Security);
|
||||
}
|
||||
|
||||
let session = XRSession::new(&self.global(), &displays[0]);
|
||||
promise.resolve_native(&session);
|
||||
// whether or not we should initiate presentation is unclear
|
||||
// https://github.com/immersive-web/webxr/issues/453
|
||||
|
||||
promise
|
||||
}
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
use crate::dom::bindings::codegen::Bindings::XRBinding::XRSessionMode;
|
||||
use crate::dom::bindings::codegen::Bindings::XRSessionBinding;
|
||||
use crate::dom::bindings::codegen::Bindings::XRSessionBinding::XRSessionMethods;
|
||||
use crate::dom::bindings::codegen::Bindings::XRWebGLLayerBinding::XRWebGLLayerMethods;
|
||||
use crate::dom::bindings::inheritance::Castable;
|
||||
use crate::dom::bindings::num::Finite;
|
||||
use crate::dom::bindings::reflector::reflect_dom_object;
|
||||
use crate::dom::bindings::root::{Dom, DomRoot, MutNullableDom};
|
||||
|
@ -12,6 +14,7 @@ use crate::dom::eventtarget::EventTarget;
|
|||
use crate::dom::globalscope::GlobalScope;
|
||||
use crate::dom::vrdisplay::VRDisplay;
|
||||
use crate::dom::xrlayer::XRLayer;
|
||||
use crate::dom::xrwebgllayer::XRWebGLLayer;
|
||||
use dom_struct::dom_struct;
|
||||
use std::cell::Cell;
|
||||
|
||||
|
@ -66,7 +69,14 @@ impl XRSessionMethods for XRSession {
|
|||
}
|
||||
|
||||
fn SetBaseLayer(&self, layer: Option<&XRLayer>) {
|
||||
self.base_layer.set(layer)
|
||||
self.base_layer.set(layer);
|
||||
if let Some(layer) = layer {
|
||||
let layer = layer.downcast::<XRWebGLLayer>().unwrap();
|
||||
self.display.xr_present(&layer.Context());
|
||||
} else {
|
||||
// steps unknown
|
||||
// https://github.com/immersive-web/webxr/issues/453
|
||||
}
|
||||
}
|
||||
|
||||
fn GetBaseLayer(&self) -> Option<DomRoot<XRLayer>> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue