aboutsummaryrefslogtreecommitdiffstats
path: root/components/webvr/webvr_thread.rs
diff options
context:
space:
mode:
authorAnthony Ramine <n.oxyde@gmail.com>2017-08-16 23:23:18 +0200
committerAnthony Ramine <n.oxyde@gmail.com>2017-08-16 23:23:18 +0200
commit676f2c8acf6fec8ad77d4daa51bef5bdcae101c5 (patch)
treed212209744e3b10a315dc79da754a70d7543e428 /components/webvr/webvr_thread.rs
parent4d10d39e8fe841c5fe2ac58da2daaa13c10c140e (diff)
downloadservo-676f2c8acf6fec8ad77d4daa51bef5bdcae101c5.tar.gz
servo-676f2c8acf6fec8ad77d4daa51bef5bdcae101c5.zip
Revert "Auto merge of #18114 - emilio:revert-webgl-refactor, r=nox"
This reverts commit 4d10d39e8fe841c5fe2ac58da2daaa13c10c140e, reversing changes made to ee94e2b7c0bd327abe8f9545b2a1f792f67a2bdd.
Diffstat (limited to 'components/webvr/webvr_thread.rs')
-rw-r--r--components/webvr/webvr_thread.rs32
1 files changed, 17 insertions, 15 deletions
diff --git a/components/webvr/webvr_thread.rs b/components/webvr/webvr_thread.rs
index ec550153870..77f42a6b39e 100644
--- a/components/webvr/webvr_thread.rs
+++ b/components/webvr/webvr_thread.rs
@@ -2,6 +2,8 @@
* 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;
+use euclid::Size2D;
use ipc_channel::ipc;
use ipc_channel::ipc::{IpcReceiver, IpcSender};
use msg::constellation_msg::PipelineId;
@@ -11,8 +13,6 @@ use std::{thread, time};
use std::collections::{HashMap, HashSet};
use std::sync::mpsc;
use std::sync::mpsc::{Receiver, Sender};
-use webrender_api;
-use webrender_api::DeviceIntSize;
use webvr_traits::{WebVRMsg, WebVRResult};
use webvr_traits::webvr::*;
@@ -34,7 +34,7 @@ use webvr_traits::webvr::*;
/// ids using the WebVR APIs. These ids are used to implement privacy guidelines defined in the WebVR Spec.
/// * When a JavaScript thread gains access to present to a headset, WebVRThread is not used as a intermediary in
/// the VRDisplay.requestAnimationFrame loop in order to minimize latency. A direct communication with WebRender
-/// is used instead. See WebVRCompositorHandler and the VRCompositorCommanda for more details.
+/// is used instead. See WebVRCompositorHandler and the WebVRCommands for more details.
pub struct WebVRThread {
receiver: IpcReceiver<WebVRMsg>,
sender: IpcSender<WebVRMsg>,
@@ -66,15 +66,17 @@ impl WebVRThread {
}
}
- pub fn spawn(constellation_chan: Sender<ConstellationMsg>,
- vr_compositor_chan: WebVRCompositorSender)
- -> IpcSender<WebVRMsg> {
+ pub fn spawn(vr_compositor_chan: WebVRCompositorSender)
+ -> (IpcSender<WebVRMsg>, Sender<Sender<ConstellationMsg>>) {
let (sender, receiver) = ipc::channel().unwrap();
+ let (constellation_sender, constellation_receiver) = mpsc::channel();
let sender_clone = sender.clone();
thread::Builder::new().name("WebVRThread".into()).spawn(move || {
+ let constellation_chan = constellation_receiver.recv().unwrap();
WebVRThread::new(receiver, sender_clone, constellation_chan, vr_compositor_chan).start();
}).expect("Thread spawning failed");
- sender
+
+ (sender, constellation_sender)
}
fn start(&mut self) {
@@ -305,7 +307,7 @@ impl WebVRThread {
pub struct WebVRCompositor(*mut VRDisplay);
pub struct WebVRCompositorHandler {
- compositors: HashMap<webrender_api::VRCompositorId, WebVRCompositor>,
+ compositors: HashMap<webgl::WebVRDeviceId, WebVRCompositor>,
webvr_thread_receiver: Receiver<Option<WebVRCompositor>>,
webvr_thread_sender: Option<IpcSender<WebVRMsg>>
}
@@ -328,14 +330,14 @@ impl WebVRCompositorHandler {
}
}
-impl webrender_api::VRCompositorHandler for WebVRCompositorHandler {
+impl webgl::WebVRRenderHandler for WebVRCompositorHandler {
#[allow(unsafe_code)]
- fn handle(&mut self, cmd: webrender_api::VRCompositorCommand, texture: Option<(u32, DeviceIntSize)>) {
+ fn handle(&mut self, cmd: webgl::WebVRCommand, texture: Option<(u32, Size2D<i32>)>) {
match cmd {
- webrender_api::VRCompositorCommand::Create(compositor_id) => {
+ webgl::WebVRCommand::Create(compositor_id) => {
self.create_compositor(compositor_id);
}
- webrender_api::VRCompositorCommand::SyncPoses(compositor_id, near, far, sender) => {
+ webgl::WebVRCommand::SyncPoses(compositor_id, near, far, sender) => {
if let Some(compositor) = self.compositors.get(&compositor_id) {
let pose = unsafe {
(*compositor.0).sync_poses();
@@ -346,7 +348,7 @@ impl webrender_api::VRCompositorHandler for WebVRCompositorHandler {
let _ = sender.send(Err(()));
}
}
- webrender_api::VRCompositorCommand::SubmitFrame(compositor_id, left_bounds, right_bounds) => {
+ webgl::WebVRCommand::SubmitFrame(compositor_id, left_bounds, right_bounds) => {
if let Some(compositor) = self.compositors.get(&compositor_id) {
if let Some((texture_id, size)) = texture {
let layer = VRLayer {
@@ -361,7 +363,7 @@ impl webrender_api::VRCompositorHandler for WebVRCompositorHandler {
}
}
}
- webrender_api::VRCompositorCommand::Release(compositor_id) => {
+ webgl::WebVRCommand::Release(compositor_id) => {
self.compositors.remove(&compositor_id);
}
}
@@ -370,7 +372,7 @@ impl webrender_api::VRCompositorHandler for WebVRCompositorHandler {
impl WebVRCompositorHandler {
#[allow(unsafe_code)]
- fn create_compositor(&mut self, display_id: webrender_api::VRCompositorId) {
+ fn create_compositor(&mut self, display_id: webgl::WebVRDeviceId) {
let sender = match self.webvr_thread_sender {
Some(ref s) => s,
None => return,