Pass the event loop waker into WebXR

This commit is contained in:
Alan Jeffrey 2019-07-24 13:48:25 -05:00
parent c9dde3a4bb
commit 701256d837
9 changed files with 17 additions and 19 deletions

View file

@ -23,3 +23,4 @@ serde = "1.0"
servo_url = {path = "../url"}
style_traits = {path = "../style_traits", features = ["servo"]}
webrender_api = {git = "https://github.com/servo/webrender", features = ["ipc"]}
webxr-api = {git = "https://github.com/servo/webxr", features = ["ipc"]}

View file

@ -21,6 +21,8 @@ use servo_url::ServoUrl;
use std::fmt::{Debug, Error, Formatter};
use webrender_api::units::{DeviceIntPoint, DeviceIntSize};
pub use webxr_api::MainThreadWaker as EventLoopWaker;
/// A cursor for the window. This is different from a CSS cursor (see
/// `CursorKind`) in that it has no `Auto` value.
#[repr(u8)]
@ -63,12 +65,6 @@ pub enum Cursor {
ZoomOut,
}
/// Used to wake up the event loop, provided by the servo port/embedder.
pub trait EventLoopWaker: 'static + Send {
fn clone(&self) -> Box<dyn EventLoopWaker + Send>;
fn wake(&self);
}
/// Sends messages to the embedder.
pub struct EmbedderProxy {
pub sender: Sender<(Option<TopLevelBrowsingContextId>, EmbedderMsg)>,

View file

@ -67,7 +67,7 @@ fn create_embedder_proxy() -> EmbedderProxy {
}
impl EventLoopWaker for DummyEventLoopWaker {
fn wake(&self) {}
fn clone(&self) -> Box<dyn EventLoopWaker + Send> {
fn clone_box(&self) -> Box<dyn EventLoopWaker> {
Box::new(DummyEventLoopWaker {})
}
}

View file

@ -289,10 +289,10 @@ where
// the client window and the compositor. This channel is unique because
// messages to client may need to pump a platform-specific event loop
// to deliver the message.
let event_loop_waker = embedder.create_event_loop_waker();
let (compositor_proxy, compositor_receiver) =
create_compositor_channel(embedder.create_event_loop_waker());
let (embedder_proxy, embedder_receiver) =
create_embedder_channel(embedder.create_event_loop_waker());
create_compositor_channel(event_loop_waker.clone());
let (embedder_proxy, embedder_receiver) = create_embedder_channel(event_loop_waker.clone());
let time_profiler_chan = profile_time::Profiler::create(
&opts.time_profiling,
opts.time_profiler_trace_path.clone(),
@ -368,8 +368,8 @@ where
// For the moment, we enable use both the webxr crate and the rust-webvr crate,
// but we are migrating over to just using webxr.
let mut webxr_main_thread =
webxr_api::MainThreadRegistry::new().expect("Failed to create WebXR device registry");
let mut webxr_main_thread = webxr_api::MainThreadRegistry::new(event_loop_waker)
.expect("Failed to create WebXR device registry");
if pref!(dom.webvr.enabled) || pref!(dom.webxr.enabled) {
embedder.register_webxr(&mut webxr_main_thread);
}