Skip to content

Commit

Permalink
Pass events loop to glwindow test webvr implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
Alan Jeffrey committed Jul 1, 2019
1 parent 18477d1 commit 1e5e3c9
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 16 deletions.
20 changes: 10 additions & 10 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions components/webvr/Cargo.toml
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ gleam = "0.6"
ipc-channel = "0.11.2" ipc-channel = "0.11.2"
log = "0.4" log = "0.4"
msg = {path = "../msg"} msg = {path = "../msg"}
rust-webvr = {version = "0.11.4", features = ["mock", "openvr", "vrexternal"]} rust-webvr = {version = "0.12", features = ["mock", "openvr", "vrexternal"]}
rust-webvr-api = "0.11.4" rust-webvr-api = "0.12"
script_traits = {path = "../script_traits"} script_traits = {path = "../script_traits"}
servo_config = {path = "../config"} servo_config = {path = "../config"}
webvr_traits = {path = "../webvr_traits" } webvr_traits = {path = "../webvr_traits" }
2 changes: 1 addition & 1 deletion components/webvr_traits/Cargo.toml
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ path = "lib.rs"
[dependencies] [dependencies]
ipc-channel = "0.11" ipc-channel = "0.11"
msg = {path = "../msg"} msg = {path = "../msg"}
rust-webvr-api = {version = "0.11.4", features = ["ipc"]} rust-webvr-api = {version = "0.12", features = ["ipc"]}
serde = "1.0" serde = "1.0"
2 changes: 1 addition & 1 deletion ports/glutin/Cargo.toml
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ lazy_static = "1"
libservo = {path = "../../components/servo"} libservo = {path = "../../components/servo"}
libc = "0.2" libc = "0.2"
log = "0.4" log = "0.4"
rust-webvr = { version = "0.11", features = ["glwindow"] } rust-webvr = { version = "0.12", features = ["glwindow"] }
tinyfiledialogs = "3.0" tinyfiledialogs = "3.0"


[target.'cfg(any(target_os = "linux", target_os = "windows"))'.dependencies] [target.'cfg(any(target_os = "linux", target_os = "windows"))'.dependencies]
Expand Down
7 changes: 6 additions & 1 deletion ports/glutin/embedder.rs
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use crate::app;
use crate::events_loop::EventsLoop; use crate::events_loop::EventsLoop;
use gleam::gl; use gleam::gl;
use glutin; use glutin;
use glutin::EventsLoopClosed;
use glutin::dpi::LogicalSize; use glutin::dpi::LogicalSize;
use rust_webvr::GlWindowVRService; use rust_webvr::GlWindowVRService;
use servo::compositing::windowing::EmbedderMethods; use servo::compositing::windowing::EmbedderMethods;
Expand Down Expand Up @@ -46,6 +47,10 @@ impl EmbedderMethods for EmbedderCallbacks {
let name = String::from("Test VR Display"); let name = String::from("Test VR Display");
let size = opts::get().initial_window_size.to_f64(); let size = opts::get().initial_window_size.to_f64();
let size = LogicalSize::new(size.width, size.height); 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() let window_builder = glutin::WindowBuilder::new()
.with_title(name.clone()) .with_title(name.clone())
.with_dimensions(size) .with_dimensions(size)
Expand All @@ -57,7 +62,7 @@ impl EmbedderMethods for EmbedderCallbacks {
.build_windowed(window_builder, &*self.events_loop.borrow().as_winit()) .build_windowed(window_builder, &*self.events_loop.borrow().as_winit())
.expect("Failed to create window."); .expect("Failed to create window.");
let gl = self.gl.clone(); 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)); services.register(Box::new(service));
heartbeats.push(Box::new(heartbeat)); heartbeats.push(Box::new(heartbeat));
Expand Down
3 changes: 3 additions & 0 deletions ports/glutin/events_loop.rs
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ impl EventsLoop {
pub fn as_winit(&self) -> &glutin::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") &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) { pub fn poll_events<F>(&mut self, callback: F) where F: FnMut(glutin::Event) {
if let Some(ref mut events_loop) = self.0 { if let Some(ref mut events_loop) = self.0 {
events_loop.poll_events(callback); events_loop.poll_events(callback);
Expand Down
2 changes: 1 addition & 1 deletion ports/libmlservo/Cargo.toml
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ raqote_backend = ["simpleservo/raqote_backend"]
[dependencies] [dependencies]
libservo = { path = "../../components/servo", features = ["no_static_freetype"] } libservo = { path = "../../components/servo", features = ["no_static_freetype"] }
simpleservo = { path = "../libsimpleservo/api", 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" libc = "0.2"
log = "0.4" log = "0.4"
servo-egl = "0.2" servo-egl = "0.2"
Expand Down

0 comments on commit 1e5e3c9

Please sign in to comment.