mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
Pass the event loop waker into WebXR
This commit is contained in:
parent
c9dde3a4bb
commit
701256d837
9 changed files with 17 additions and 19 deletions
5
Cargo.lock
generated
5
Cargo.lock
generated
|
@ -1086,6 +1086,7 @@ dependencies = [
|
||||||
"servo_url 0.0.1",
|
"servo_url 0.0.1",
|
||||||
"style_traits 0.0.1",
|
"style_traits 0.0.1",
|
||||||
"webrender_api 0.60.0 (git+https://github.com/servo/webrender)",
|
"webrender_api 0.60.0 (git+https://github.com/servo/webrender)",
|
||||||
|
"webxr-api 0.0.1 (git+https://github.com/servo/webxr)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -5492,7 +5493,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "webxr"
|
name = "webxr"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
source = "git+https://github.com/servo/webxr#43a54f4cbe0ed3037e5e2bf34769241a5bd3da60"
|
source = "git+https://github.com/servo/webxr#0418277175dbccf83e575c99d6b9c778bfdbe70b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"gleam 0.6.18 (registry+https://github.com/rust-lang/crates.io-index)",
|
"gleam 0.6.18 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -5504,7 +5505,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "webxr-api"
|
name = "webxr-api"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
source = "git+https://github.com/servo/webxr#43a54f4cbe0ed3037e5e2bf34769241a5bd3da60"
|
source = "git+https://github.com/servo/webxr#0418277175dbccf83e575c99d6b9c778bfdbe70b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"gleam 0.6.18 (registry+https://github.com/rust-lang/crates.io-index)",
|
"gleam 0.6.18 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
|
|
@ -23,3 +23,4 @@ serde = "1.0"
|
||||||
servo_url = {path = "../url"}
|
servo_url = {path = "../url"}
|
||||||
style_traits = {path = "../style_traits", features = ["servo"]}
|
style_traits = {path = "../style_traits", features = ["servo"]}
|
||||||
webrender_api = {git = "https://github.com/servo/webrender", features = ["ipc"]}
|
webrender_api = {git = "https://github.com/servo/webrender", features = ["ipc"]}
|
||||||
|
webxr-api = {git = "https://github.com/servo/webxr", features = ["ipc"]}
|
||||||
|
|
|
@ -21,6 +21,8 @@ use servo_url::ServoUrl;
|
||||||
use std::fmt::{Debug, Error, Formatter};
|
use std::fmt::{Debug, Error, Formatter};
|
||||||
use webrender_api::units::{DeviceIntPoint, DeviceIntSize};
|
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
|
/// A cursor for the window. This is different from a CSS cursor (see
|
||||||
/// `CursorKind`) in that it has no `Auto` value.
|
/// `CursorKind`) in that it has no `Auto` value.
|
||||||
#[repr(u8)]
|
#[repr(u8)]
|
||||||
|
@ -63,12 +65,6 @@ pub enum Cursor {
|
||||||
ZoomOut,
|
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.
|
/// Sends messages to the embedder.
|
||||||
pub struct EmbedderProxy {
|
pub struct EmbedderProxy {
|
||||||
pub sender: Sender<(Option<TopLevelBrowsingContextId>, EmbedderMsg)>,
|
pub sender: Sender<(Option<TopLevelBrowsingContextId>, EmbedderMsg)>,
|
||||||
|
|
|
@ -67,7 +67,7 @@ fn create_embedder_proxy() -> EmbedderProxy {
|
||||||
}
|
}
|
||||||
impl EventLoopWaker for DummyEventLoopWaker {
|
impl EventLoopWaker for DummyEventLoopWaker {
|
||||||
fn wake(&self) {}
|
fn wake(&self) {}
|
||||||
fn clone(&self) -> Box<dyn EventLoopWaker + Send> {
|
fn clone_box(&self) -> Box<dyn EventLoopWaker> {
|
||||||
Box::new(DummyEventLoopWaker {})
|
Box::new(DummyEventLoopWaker {})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -289,10 +289,10 @@ where
|
||||||
// the client window and the compositor. This channel is unique because
|
// the client window and the compositor. This channel is unique because
|
||||||
// messages to client may need to pump a platform-specific event loop
|
// messages to client may need to pump a platform-specific event loop
|
||||||
// to deliver the message.
|
// to deliver the message.
|
||||||
|
let event_loop_waker = embedder.create_event_loop_waker();
|
||||||
let (compositor_proxy, compositor_receiver) =
|
let (compositor_proxy, compositor_receiver) =
|
||||||
create_compositor_channel(embedder.create_event_loop_waker());
|
create_compositor_channel(event_loop_waker.clone());
|
||||||
let (embedder_proxy, embedder_receiver) =
|
let (embedder_proxy, embedder_receiver) = create_embedder_channel(event_loop_waker.clone());
|
||||||
create_embedder_channel(embedder.create_event_loop_waker());
|
|
||||||
let time_profiler_chan = profile_time::Profiler::create(
|
let time_profiler_chan = profile_time::Profiler::create(
|
||||||
&opts.time_profiling,
|
&opts.time_profiling,
|
||||||
opts.time_profiler_trace_path.clone(),
|
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,
|
// For the moment, we enable use both the webxr crate and the rust-webvr crate,
|
||||||
// but we are migrating over to just using webxr.
|
// but we are migrating over to just using webxr.
|
||||||
let mut webxr_main_thread =
|
let mut webxr_main_thread = webxr_api::MainThreadRegistry::new(event_loop_waker)
|
||||||
webxr_api::MainThreadRegistry::new().expect("Failed to create WebXR device registry");
|
.expect("Failed to create WebXR device registry");
|
||||||
if pref!(dom.webvr.enabled) || pref!(dom.webxr.enabled) {
|
if pref!(dom.webvr.enabled) || pref!(dom.webxr.enabled) {
|
||||||
embedder.register_webxr(&mut webxr_main_thread);
|
embedder.register_webxr(&mut webxr_main_thread);
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,7 +87,7 @@ impl EventLoopWaker for HeadedEventLoopWaker {
|
||||||
warn!("Failed to wake up event loop ({}).", err);
|
warn!("Failed to wake up event loop ({}).", err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn clone(&self) -> Box<dyn EventLoopWaker + Send> {
|
fn clone_box(&self) -> Box<dyn EventLoopWaker> {
|
||||||
Box::new(HeadedEventLoopWaker {
|
Box::new(HeadedEventLoopWaker {
|
||||||
proxy: self.proxy.clone(),
|
proxy: self.proxy.clone(),
|
||||||
})
|
})
|
||||||
|
@ -97,5 +97,5 @@ impl EventLoopWaker for HeadedEventLoopWaker {
|
||||||
struct HeadlessEventLoopWaker;
|
struct HeadlessEventLoopWaker;
|
||||||
impl EventLoopWaker for HeadlessEventLoopWaker {
|
impl EventLoopWaker for HeadlessEventLoopWaker {
|
||||||
fn wake(&self) {}
|
fn wake(&self) {}
|
||||||
fn clone(&self) -> Box<dyn EventLoopWaker + Send> { Box::new(HeadlessEventLoopWaker) }
|
fn clone_box(&self) -> Box<dyn EventLoopWaker> { Box::new(HeadlessEventLoopWaker) }
|
||||||
}
|
}
|
||||||
|
|
|
@ -403,7 +403,7 @@ enum ScrollState {
|
||||||
struct EventLoopWakerInstance;
|
struct EventLoopWakerInstance;
|
||||||
|
|
||||||
impl EventLoopWaker for EventLoopWakerInstance {
|
impl EventLoopWaker for EventLoopWakerInstance {
|
||||||
fn clone(&self) -> Box<dyn EventLoopWaker + Send> {
|
fn clone_box(&self) -> Box<dyn EventLoopWaker> {
|
||||||
Box::new(EventLoopWakerInstance)
|
Box::new(EventLoopWakerInstance)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -373,7 +373,7 @@ impl WakeupCallback {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl EventLoopWaker for WakeupCallback {
|
impl EventLoopWaker for WakeupCallback {
|
||||||
fn clone(&self) -> Box<dyn EventLoopWaker + Send> {
|
fn clone_box(&self) -> Box<dyn EventLoopWaker> {
|
||||||
Box::new(WakeupCallback(self.0))
|
Box::new(WakeupCallback(self.0))
|
||||||
}
|
}
|
||||||
fn wake(&self) {
|
fn wake(&self) {
|
||||||
|
|
|
@ -339,7 +339,7 @@ impl WakeupCallback {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl EventLoopWaker for WakeupCallback {
|
impl EventLoopWaker for WakeupCallback {
|
||||||
fn clone(&self) -> Box<dyn EventLoopWaker + Send> {
|
fn clone_box(&self) -> Box<dyn EventLoopWaker> {
|
||||||
Box::new(WakeupCallback {
|
Box::new(WakeupCallback {
|
||||||
callback: self.callback.clone(),
|
callback: self.callback.clone(),
|
||||||
jvm: self.jvm.clone(),
|
jvm: self.jvm.clone(),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue