aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/vrdisplay.rs
diff options
context:
space:
mode:
Diffstat (limited to 'components/script/dom/vrdisplay.rs')
-rw-r--r--components/script/dom/vrdisplay.rs36
1 files changed, 20 insertions, 16 deletions
diff --git a/components/script/dom/vrdisplay.rs b/components/script/dom/vrdisplay.rs
index a36bd27ad29..54f06fb928f 100644
--- a/components/script/dom/vrdisplay.rs
+++ b/components/script/dom/vrdisplay.rs
@@ -2,7 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-use canvas_traits::webgl::{webgl_channel, WebGLReceiver, WebVRCommand};
+use canvas_traits::CanvasMsg;
use core::ops::Deref;
use dom::bindings::callback::ExceptionHandling;
use dom::bindings::cell::DOMRefCell;
@@ -32,7 +32,8 @@ use dom::vrpose::VRPose;
use dom::vrstageparameters::VRStageParameters;
use dom::webglrenderingcontext::WebGLRenderingContext;
use dom_struct::dom_struct;
-use ipc_channel::ipc::{self, IpcSender};
+use ipc_channel::ipc;
+use ipc_channel::ipc::{IpcSender, IpcReceiver};
use js::jsapi::JSContext;
use script_runtime::CommonScriptMsg;
use script_runtime::ScriptThreadEventCategory::WebVREvent;
@@ -42,6 +43,7 @@ use std::mem;
use std::rc::Rc;
use std::sync::mpsc;
use std::thread;
+use webrender_api::VRCompositorCommand;
use webvr_traits::{WebVRDisplayData, WebVRDisplayEvent, WebVRFrameData, WebVRLayer, WebVRMsg};
#[dom_struct]
@@ -69,7 +71,7 @@ pub struct VRDisplay {
// Compositor VRFrameData synchonization
frame_data_status: Cell<VRFrameDataStatus>,
#[ignore_heap_size_of = "channels are hard"]
- frame_data_receiver: DOMRefCell<Option<WebGLReceiver<Result<Vec<u8>, ()>>>>,
+ frame_data_receiver: DOMRefCell<Option<IpcReceiver<Result<Vec<u8>, ()>>>>,
running_display_raf: Cell<bool>,
paused: Cell<bool>,
stopped_on_pause: Cell<bool>,
@@ -384,10 +386,11 @@ impl VRDisplayMethods for VRDisplay {
return;
}
- let display_id = self.display.borrow().display_id;
+ let api_sender = self.layer_ctx.get().unwrap().ipc_renderer();
+ let display_id = self.display.borrow().display_id as u64;
let layer = self.layer.borrow();
- let msg = WebVRCommand::SubmitFrame(display_id, layer.left_bounds, layer.right_bounds);
- self.layer_ctx.get().unwrap().send_vr_command(msg);
+ let msg = VRCompositorCommand::SubmitFrame(display_id, layer.left_bounds, layer.right_bounds);
+ api_sender.send(CanvasMsg::WebVR(msg)).unwrap();
}
// https://w3c.github.io/webvr/spec/1.1/#dom-vrdisplay-getlayers
@@ -486,11 +489,11 @@ impl VRDisplay {
fn init_present(&self) {
self.presenting.set(true);
- let (sync_sender, sync_receiver) = webgl_channel().unwrap();
+ let (sync_sender, sync_receiver) = ipc::channel().unwrap();
*self.frame_data_receiver.borrow_mut() = Some(sync_receiver);
- let display_id = self.display.borrow().display_id;
- let api_sender = self.layer_ctx.get().unwrap().webgl_sender();
+ let display_id = self.display.borrow().display_id as u64;
+ let api_sender = self.layer_ctx.get().unwrap().ipc_renderer();
let js_sender = self.global().script_chan();
let address = Trusted::new(&*self);
let near_init = self.depth_near.get();
@@ -508,7 +511,7 @@ impl VRDisplay {
let mut far = far_init;
// Initialize compositor
- api_sender.send_vr(WebVRCommand::Create(display_id)).unwrap();
+ api_sender.send(CanvasMsg::WebVR(VRCompositorCommand::Create(display_id))).unwrap();
loop {
// Run RAF callbacks on JavaScript thread
let msg = box NotifyDisplayRAF {
@@ -518,8 +521,8 @@ impl VRDisplay {
js_sender.send(CommonScriptMsg::RunnableMsg(WebVREvent, msg)).unwrap();
// Run Sync Poses in parallell on Render thread
- let msg = WebVRCommand::SyncPoses(display_id, near, far, sync_sender.clone());
- api_sender.send_vr(msg).unwrap();
+ let msg = VRCompositorCommand::SyncPoses(display_id, near, far, sync_sender.clone());
+ api_sender.send(CanvasMsg::WebVR(msg)).unwrap();
// Wait until both SyncPoses & RAF ends
if let Ok(depth) = raf_receiver.recv().unwrap() {
@@ -538,9 +541,10 @@ impl VRDisplay {
self.presenting.set(false);
*self.frame_data_receiver.borrow_mut() = None;
- let api_sender = self.layer_ctx.get().unwrap().webgl_sender();
- let display_id = self.display.borrow().display_id;
- api_sender.send_vr(WebVRCommand::Release(display_id)).unwrap();
+ let api_sender = self.layer_ctx.get().unwrap().ipc_renderer();
+ let display_id = self.display.borrow().display_id as u64;
+ let msg = VRCompositorCommand::Release(display_id);
+ api_sender.send(CanvasMsg::WebVR(msg)).unwrap();
}
// Only called when the JSContext is destroyed while presenting.
@@ -623,7 +627,7 @@ impl Runnable for NotifyDisplayRAF {
}
-// WebVR Spec: If the number of values in the leftBounds/rightBounds arrays
+// WebVR Spect: 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> {
match *src {