aboutsummaryrefslogtreecommitdiffstats
path: root/components/webvr/webvr_thread.rs
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2017-08-16 09:45:13 -0500
committerGitHub <noreply@github.com>2017-08-16 09:45:13 -0500
commit4d10d39e8fe841c5fe2ac58da2daaa13c10c140e (patch)
treef77d68b734a6327898cc8c01505b0723bf45ed4a /components/webvr/webvr_thread.rs
parentee94e2b7c0bd327abe8f9545b2a1f792f67a2bdd (diff)
parentcfe22e3979b7270833a4b450b25fb2157deb1da2 (diff)
downloadservo-4d10d39e8fe841c5fe2ac58da2daaa13c10c140e.tar.gz
servo-4d10d39e8fe841c5fe2ac58da2daaa13c10c140e.zip
Auto merge of #18114 - emilio:revert-webgl-refactor, r=nox
Revert "Auto merge of #17891 - MortimerGoro:webgl_move, r=glennw,emilio" This reverts commit 90f55ea4580e2a15f7d70d0491444f18b972d450, reversing changes made to 2e60b27a2186a8cba4b952960155dfcf3f47d7db. Doing that per Josh's request, since it's causing very frequent intermittent OOMs on the android builders. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/18114) <!-- Reviewable:end -->
Diffstat (limited to 'components/webvr/webvr_thread.rs')
-rw-r--r--components/webvr/webvr_thread.rs32
1 files changed, 15 insertions, 17 deletions
diff --git a/components/webvr/webvr_thread.rs b/components/webvr/webvr_thread.rs
index 77f42a6b39e..ec550153870 100644
--- a/components/webvr/webvr_thread.rs
+++ b/components/webvr/webvr_thread.rs
@@ -2,8 +2,6 @@
* 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;
@@ -13,6 +11,8 @@ 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 WebVRCommands for more details.
+/// is used instead. See WebVRCompositorHandler and the VRCompositorCommanda for more details.
pub struct WebVRThread {
receiver: IpcReceiver<WebVRMsg>,
sender: IpcSender<WebVRMsg>,
@@ -66,17 +66,15 @@ impl WebVRThread {
}
}
- pub fn spawn(vr_compositor_chan: WebVRCompositorSender)
- -> (IpcSender<WebVRMsg>, Sender<Sender<ConstellationMsg>>) {
+ pub fn spawn(constellation_chan: Sender<ConstellationMsg>,
+ vr_compositor_chan: WebVRCompositorSender)
+ -> IpcSender<WebVRMsg> {
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, constellation_sender)
+ sender
}
fn start(&mut self) {
@@ -307,7 +305,7 @@ impl WebVRThread {
pub struct WebVRCompositor(*mut VRDisplay);
pub struct WebVRCompositorHandler {
- compositors: HashMap<webgl::WebVRDeviceId, WebVRCompositor>,
+ compositors: HashMap<webrender_api::VRCompositorId, WebVRCompositor>,
webvr_thread_receiver: Receiver<Option<WebVRCompositor>>,
webvr_thread_sender: Option<IpcSender<WebVRMsg>>
}
@@ -330,14 +328,14 @@ impl WebVRCompositorHandler {
}
}
-impl webgl::WebVRRenderHandler for WebVRCompositorHandler {
+impl webrender_api::VRCompositorHandler for WebVRCompositorHandler {
#[allow(unsafe_code)]
- fn handle(&mut self, cmd: webgl::WebVRCommand, texture: Option<(u32, Size2D<i32>)>) {
+ fn handle(&mut self, cmd: webrender_api::VRCompositorCommand, texture: Option<(u32, DeviceIntSize)>) {
match cmd {
- webgl::WebVRCommand::Create(compositor_id) => {
+ webrender_api::VRCompositorCommand::Create(compositor_id) => {
self.create_compositor(compositor_id);
}
- webgl::WebVRCommand::SyncPoses(compositor_id, near, far, sender) => {
+ webrender_api::VRCompositorCommand::SyncPoses(compositor_id, near, far, sender) => {
if let Some(compositor) = self.compositors.get(&compositor_id) {
let pose = unsafe {
(*compositor.0).sync_poses();
@@ -348,7 +346,7 @@ impl webgl::WebVRRenderHandler for WebVRCompositorHandler {
let _ = sender.send(Err(()));
}
}
- webgl::WebVRCommand::SubmitFrame(compositor_id, left_bounds, right_bounds) => {
+ webrender_api::VRCompositorCommand::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 {
@@ -363,7 +361,7 @@ impl webgl::WebVRRenderHandler for WebVRCompositorHandler {
}
}
}
- webgl::WebVRCommand::Release(compositor_id) => {
+ webrender_api::VRCompositorCommand::Release(compositor_id) => {
self.compositors.remove(&compositor_id);
}
}
@@ -372,7 +370,7 @@ impl webgl::WebVRRenderHandler for WebVRCompositorHandler {
impl WebVRCompositorHandler {
#[allow(unsafe_code)]
- fn create_compositor(&mut self, display_id: webgl::WebVRDeviceId) {
+ fn create_compositor(&mut self, display_id: webrender_api::VRCompositorId) {
let sender = match self.webvr_thread_sender {
Some(ref s) => s,
None => return,