Pass events loop to glwindow test webvr implementation

This commit is contained in:
Alan Jeffrey 2019-06-14 14:39:20 -05:00
parent 18477d1e1e
commit 1e5e3c95c9
7 changed files with 24 additions and 16 deletions

20
Cargo.lock generated
View file

@ -2434,7 +2434,7 @@ dependencies = [
"libc 0.2.53 (registry+https://github.com/rust-lang/crates.io-index)",
"libservo 0.0.1",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"rust-webvr 0.11.5 (registry+https://github.com/rust-lang/crates.io-index)",
"rust-webvr 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)",
"servo-egl 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"simpleservo 0.0.1",
"smallvec 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)",
@ -3626,7 +3626,7 @@ dependencies = [
[[package]]
name = "rust-webvr"
version = "0.11.5"
version = "0.12.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"bindgen 0.49.0 (registry+https://github.com/rust-lang/crates.io-index)",
@ -3639,12 +3639,12 @@ dependencies = [
"libloading 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"ovr-mobile-sys 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rust-webvr-api 0.11.4 (registry+https://github.com/rust-lang/crates.io-index)",
"rust-webvr-api 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "rust-webvr-api"
version = "0.11.4"
version = "0.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"android_injected_glue 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
@ -3977,7 +3977,7 @@ dependencies = [
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"osmesa-src 0.1.0 (git+https://github.com/servo/osmesa-src)",
"osmesa-sys 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"rust-webvr 0.11.5 (registry+https://github.com/rust-lang/crates.io-index)",
"rust-webvr 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)",
"sig 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"tinyfiledialogs 3.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
@ -5309,8 +5309,8 @@ dependencies = [
"ipc-channel 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"msg 0.0.1",
"rust-webvr 0.11.5 (registry+https://github.com/rust-lang/crates.io-index)",
"rust-webvr-api 0.11.4 (registry+https://github.com/rust-lang/crates.io-index)",
"rust-webvr 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)",
"rust-webvr-api 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)",
"script_traits 0.0.1",
"servo_config 0.0.1",
"webvr_traits 0.0.1",
@ -5322,7 +5322,7 @@ version = "0.0.1"
dependencies = [
"ipc-channel 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)",
"msg 0.0.1",
"rust-webvr-api 0.11.4 (registry+https://github.com/rust-lang/crates.io-index)",
"rust-webvr-api 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)",
]
@ -5843,8 +5843,8 @@ dependencies = [
"checksum regex-syntax 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)" = "dcfd8681eebe297b81d98498869d4aae052137651ad7b96822f09ceb690d0a96"
"checksum remove_dir_all 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4a83fa3702a688b9359eccba92d153ac33fd2e8462f9e0e3fdf155239ea7792e"
"checksum ron 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "da06feaa07f69125ab9ddc769b11de29090122170b402547f64b86fe16ebc399"
"checksum rust-webvr 0.11.5 (registry+https://github.com/rust-lang/crates.io-index)" = "08ab7221a7ed14bfb24d8cbbec61926b9a54881a66e32f24f3a0b2efbe56fa02"
"checksum rust-webvr-api 0.11.4 (registry+https://github.com/rust-lang/crates.io-index)" = "c8eb1d528c0d05ebf44126775b38eb3ec543f35a24275bb0360e45e3e3e8da73"
"checksum rust-webvr 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)" = "db3a145f737e4bf51cd4f7d29262f2b2e46e76b116070cbbfc0959553b2e8006"
"checksum rust-webvr-api 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7b4f3a81b1acf3c6295f9c180e8ade671858865ee4e11d114ecf60974e86b2e0"
"checksum rustc-demangle 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "3058a43ada2c2d0b92b3ae38007a2d0fa5e9db971be260e0171408a4ff471c95"
"checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a"
"checksum rusttype 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b8eb11f5b0a98c8eca2fb1483f42646d8c340e83e46ab416f8a063a0fd0eeb20"

View file

@ -22,8 +22,8 @@ gleam = "0.6"
ipc-channel = "0.11.2"
log = "0.4"
msg = {path = "../msg"}
rust-webvr = {version = "0.11.4", features = ["mock", "openvr", "vrexternal"]}
rust-webvr-api = "0.11.4"
rust-webvr = {version = "0.12", features = ["mock", "openvr", "vrexternal"]}
rust-webvr-api = "0.12"
script_traits = {path = "../script_traits"}
servo_config = {path = "../config"}
webvr_traits = {path = "../webvr_traits" }

View file

@ -13,5 +13,5 @@ path = "lib.rs"
[dependencies]
ipc-channel = "0.11"
msg = {path = "../msg"}
rust-webvr-api = {version = "0.11.4", features = ["ipc"]}
rust-webvr-api = {version = "0.12", features = ["ipc"]}
serde = "1.0"

View file

@ -54,7 +54,7 @@ lazy_static = "1"
libservo = {path = "../../components/servo"}
libc = "0.2"
log = "0.4"
rust-webvr = { version = "0.11", features = ["glwindow"] }
rust-webvr = { version = "0.12", features = ["glwindow"] }
tinyfiledialogs = "3.0"
[target.'cfg(any(target_os = "linux", target_os = "windows"))'.dependencies]

View file

@ -8,6 +8,7 @@ use crate::app;
use crate::events_loop::EventsLoop;
use gleam::gl;
use glutin;
use glutin::EventsLoopClosed;
use glutin::dpi::LogicalSize;
use rust_webvr::GlWindowVRService;
use servo::compositing::windowing::EmbedderMethods;
@ -46,6 +47,10 @@ impl EmbedderMethods for EmbedderCallbacks {
let name = String::from("Test VR Display");
let size = opts::get().initial_window_size.to_f64();
let size = LogicalSize::new(size.width, size.height);
let events_loop_clone = self.events_loop.clone();
let events_loop_factory = Box::new(move || {
events_loop_clone.borrow_mut().take().ok_or(EventsLoopClosed)
});
let window_builder = glutin::WindowBuilder::new()
.with_title(name.clone())
.with_dimensions(size)
@ -57,7 +62,7 @@ impl EmbedderMethods for EmbedderCallbacks {
.build_windowed(window_builder, &*self.events_loop.borrow().as_winit())
.expect("Failed to create window.");
let gl = self.gl.clone();
let (service, heartbeat) = GlWindowVRService::new(name, context, gl);
let (service, heartbeat) = GlWindowVRService::new(name, context, events_loop_factory, gl);
services.register(Box::new(service));
heartbeats.push(Box::new(heartbeat));

View file

@ -44,6 +44,9 @@ impl EventsLoop {
pub fn as_winit(&self) -> &glutin::EventsLoop {
&self.0.as_ref().expect("Can't access winit event loop while using the fake headless event loop")
}
pub fn take(&mut self) -> Option<glutin::EventsLoop> {
self.0.take()
}
pub fn poll_events<F>(&mut self, callback: F) where F: FnMut(glutin::Event) {
if let Some(ref mut events_loop) = self.0 {
events_loop.poll_events(callback);

View file

@ -19,7 +19,7 @@ raqote_backend = ["simpleservo/raqote_backend"]
[dependencies]
libservo = { path = "../../components/servo", features = ["no_static_freetype"] }
simpleservo = { path = "../libsimpleservo/api", features = ["no_static_freetype"] }
rust-webvr = { version = "0.11", features = ["magicleap"] }
rust-webvr = { version = "0.12", features = ["magicleap"] }
libc = "0.2"
log = "0.4"
servo-egl = "0.2"