mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Use webxr IPC to get a WebXR device registry to each script thread
This commit is contained in:
parent
fee1418b43
commit
9eb75d4ea6
12 changed files with 148 additions and 35 deletions
|
@ -25,6 +25,7 @@ pixels = {path = "../pixels"}
|
|||
serde = "1.0"
|
||||
serde_bytes = "0.10"
|
||||
servo_config = {path = "../config"}
|
||||
typetag = "0.1"
|
||||
webrender_api = {git = "https://github.com/servo/webrender", features = ["ipc"]}
|
||||
webvr_traits = {path = "../webvr_traits"}
|
||||
webxr-api = {git = "https://github.com/servo/webxr"}
|
||||
|
|
|
@ -177,6 +177,7 @@ impl WebGLMsgSender {
|
|||
}
|
||||
}
|
||||
|
||||
#[typetag::serde]
|
||||
impl webxr_api::WebGLExternalImageApi for WebGLMsgSender {
|
||||
fn lock(&self) -> Result<(GLuint, Size2D<i32>, GLsync), webxr_api::Error> {
|
||||
let (sender, receiver) = webgl_channel().or(Err(webxr_api::Error::CommunicationError))?;
|
||||
|
|
|
@ -50,6 +50,7 @@ servo_remutex = {path = "../remutex"}
|
|||
servo_url = {path = "../url"}
|
||||
webvr_traits = {path = "../webvr_traits"}
|
||||
webrender_api = {git = "https://github.com/servo/webrender", features = ["ipc"]}
|
||||
webxr-api = {git = "https://github.com/servo/webxr", features = ["ipc"]}
|
||||
|
||||
[target.'cfg(all(not(target_os = "windows"), not(target_os = "ios"), not(target_os="android"), not(target_arch="arm"), not(target_arch="aarch64")))'.dependencies]
|
||||
gaol = {git = "https://github.com/servo/gaol"}
|
||||
|
|
|
@ -390,6 +390,9 @@ pub struct Constellation<Message, LTF, STF> {
|
|||
/// A channel through which messages can be sent to the webvr thread.
|
||||
webvr_chan: Option<IpcSender<WebVRMsg>>,
|
||||
|
||||
/// The XR device registry
|
||||
webxr_registry: webxr_api::Registry,
|
||||
|
||||
/// A channel through which messages can be sent to the canvas paint thread.
|
||||
canvas_chan: IpcSender<CanvasMsg>,
|
||||
|
||||
|
@ -455,6 +458,9 @@ pub struct InitialConstellationState {
|
|||
|
||||
/// A channel to the webgl thread.
|
||||
pub webvr_chan: Option<IpcSender<WebVRMsg>>,
|
||||
|
||||
/// The XR device registry
|
||||
pub webxr_registry: webxr_api::Registry,
|
||||
}
|
||||
|
||||
/// Data needed for webdriver
|
||||
|
@ -751,6 +757,7 @@ where
|
|||
}),
|
||||
webgl_threads: state.webgl_threads,
|
||||
webvr_chan: state.webvr_chan,
|
||||
webxr_registry: state.webxr_registry,
|
||||
canvas_chan: CanvasPaintThread::start(),
|
||||
pending_approval_navigations: HashMap::new(),
|
||||
pressed_mouse_buttons: 0,
|
||||
|
@ -997,6 +1004,7 @@ where
|
|||
.as_ref()
|
||||
.map(|threads| threads.pipeline()),
|
||||
webvr_chan: self.webvr_chan.clone(),
|
||||
webxr_registry: self.webxr_registry.clone(),
|
||||
});
|
||||
|
||||
let pipeline = match result {
|
||||
|
|
|
@ -188,6 +188,9 @@ pub struct InitialPipelineState {
|
|||
|
||||
/// A channel to the webvr thread.
|
||||
pub webvr_chan: Option<IpcSender<WebVRMsg>>,
|
||||
|
||||
/// The XR device registry
|
||||
pub webxr_registry: webxr_api::Registry,
|
||||
}
|
||||
|
||||
pub struct NewPipeline {
|
||||
|
@ -305,6 +308,7 @@ impl Pipeline {
|
|||
webrender_document: state.webrender_document,
|
||||
webgl_chan: state.webgl_chan,
|
||||
webvr_chan: state.webvr_chan,
|
||||
webxr_registry: state.webxr_registry,
|
||||
};
|
||||
|
||||
// Spawn the child process.
|
||||
|
@ -510,6 +514,7 @@ pub struct UnprivilegedPipelineContent {
|
|||
webrender_document: webrender_api::DocumentId,
|
||||
webgl_chan: Option<WebGLPipeline>,
|
||||
webvr_chan: Option<IpcSender<WebVRMsg>>,
|
||||
webxr_registry: webxr_api::Registry,
|
||||
}
|
||||
|
||||
impl UnprivilegedPipelineContent {
|
||||
|
@ -554,6 +559,7 @@ impl UnprivilegedPipelineContent {
|
|||
content_process_shutdown_chan: self.script_content_process_shutdown_chan,
|
||||
webgl_chan: self.webgl_chan,
|
||||
webvr_chan: self.webvr_chan,
|
||||
webxr_registry: self.webxr_registry,
|
||||
webrender_document: self.webrender_document,
|
||||
webrender_api_sender: self.webrender_api_sender.clone(),
|
||||
layout_is_busy: layout_thread_busy_flag.clone(),
|
||||
|
|
|
@ -111,6 +111,7 @@ uuid = {version = "0.7", features = ["v4"]}
|
|||
xml5ever = {version = "0.14"}
|
||||
webrender_api = {git = "https://github.com/servo/webrender", features = ["ipc"]}
|
||||
webvr_traits = {path = "../webvr_traits"}
|
||||
webxr-api = {git = "https://github.com/servo/webxr", features = ["ipc"]}
|
||||
|
||||
[target.'cfg(not(target_os = "ios"))'.dependencies]
|
||||
mozangle = "0.2"
|
||||
|
|
|
@ -485,6 +485,7 @@ unsafe_no_jsmanaged_fields!(WebGLVersion);
|
|||
unsafe_no_jsmanaged_fields!(WebGLSLVersion);
|
||||
unsafe_no_jsmanaged_fields!(MediaList);
|
||||
unsafe_no_jsmanaged_fields!(WebVRGamepadData, WebVRGamepadState, WebVRGamepadHand);
|
||||
unsafe_no_jsmanaged_fields!(webxr_api::Registry);
|
||||
unsafe_no_jsmanaged_fields!(ScriptToConstellationChan);
|
||||
unsafe_no_jsmanaged_fields!(InteractiveMetrics);
|
||||
unsafe_no_jsmanaged_fields!(InteractiveWindow);
|
||||
|
|
|
@ -626,6 +626,9 @@ pub struct ScriptThread {
|
|||
/// A handle to the webvr thread, if available
|
||||
webvr_chan: Option<IpcSender<WebVRMsg>>,
|
||||
|
||||
/// The WebXR device registry
|
||||
webxr_registry: webxr_api::Registry,
|
||||
|
||||
/// The worklet thread pool
|
||||
worklet_thread_pool: DomRefCell<Option<Rc<WorkletThreadPool>>>,
|
||||
|
||||
|
@ -1212,6 +1215,7 @@ impl ScriptThread {
|
|||
|
||||
webgl_chan: state.webgl_chan,
|
||||
webvr_chan: state.webvr_chan,
|
||||
webxr_registry: state.webxr_registry,
|
||||
|
||||
worklet_thread_pool: Default::default(),
|
||||
|
||||
|
|
|
@ -39,3 +39,4 @@ time = "0.1.12"
|
|||
url = "1.2"
|
||||
webrender_api = {git = "https://github.com/servo/webrender", features = ["ipc"]}
|
||||
webvr_traits = {path = "../webvr_traits"}
|
||||
webxr-api = {git = "https://github.com/servo/webxr", features = ["ipc"]}
|
||||
|
|
|
@ -628,6 +628,8 @@ pub struct InitialScriptState {
|
|||
pub webgl_chan: Option<WebGLPipeline>,
|
||||
/// A channel to the webvr thread, if available.
|
||||
pub webvr_chan: Option<IpcSender<WebVRMsg>>,
|
||||
/// The XR device registry
|
||||
pub webxr_registry: webxr_api::Registry,
|
||||
/// The Webrender document ID associated with this thread.
|
||||
pub webrender_document: DocumentId,
|
||||
/// FIXME(victor): The Webrender API sender in this constellation's pipeline
|
||||
|
|
|
@ -287,7 +287,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_registry = webxr_api::Registry::new();
|
||||
let mut webxr_registry =
|
||||
webxr_api::Registry::new().expect("Failed to create WebXR device registry");
|
||||
if pref!(dom.webvr.enabled) || pref!(dom.webxr.enabled) {
|
||||
embedder.register_webxr(&mut webxr_registry);
|
||||
}
|
||||
|
@ -319,6 +320,7 @@ where
|
|||
webrender_api_sender,
|
||||
window.gl(),
|
||||
webvr_services,
|
||||
webxr_registry,
|
||||
);
|
||||
|
||||
// Send the constellation's swmanager sender to service worker manager thread
|
||||
|
@ -628,6 +630,7 @@ fn create_constellation(
|
|||
webrender_api_sender: webrender_api::RenderApiSender,
|
||||
window_gl: Rc<dyn gl::Gl>,
|
||||
webvr_services: Option<VRServiceManager>,
|
||||
webxr_registry: webxr_api::Registry,
|
||||
) -> (Sender<ConstellationMsg>, SWManagerSenders) {
|
||||
// Global configuration options, parsed from the command line.
|
||||
let opts = opts::get();
|
||||
|
@ -708,6 +711,7 @@ fn create_constellation(
|
|||
webrender_api_sender,
|
||||
webgl_threads,
|
||||
webvr_chan,
|
||||
webxr_registry,
|
||||
};
|
||||
let (constellation_chan, from_swmanager_sender) = Constellation::<
|
||||
script_layout_interface::message::Msg,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue