mirror of
https://github.com/servo/servo.git
synced 2025-10-04 02:29:12 +01:00
The compositor's `build.rs` script was parsing the `Cargo.lock` file in order to tag WebRender captures with the WebRender version. The embedder already knows what version of Servo we are using, which should be enough to infer the WebRender revision. This changes does that and generally does a bit of cleaning up of how captures are done. - The name of the capture directory is now `webrender-captures` - There is console output now when captures are done. Before it was hard to know if it succeeded. - Simplify the Compositor constructor a little to avoid passing arguments so much. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
72 lines
2.3 KiB
Rust
72 lines
2.3 KiB
Rust
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
|
|
//! Implements the global methods required by Servo (not window/gl/compositor related).
|
|
|
|
use net::protocols::ProtocolRegistry;
|
|
use servo::compositing::windowing::EmbedderMethods;
|
|
use servo::embedder_traits::{EmbedderProxy, EventLoopWaker};
|
|
use servo::servo_config::pref;
|
|
use webxr::glwindow::GlWindowDiscovery;
|
|
#[cfg(target_os = "windows")]
|
|
use webxr::openxr::OpenXrDiscovery;
|
|
|
|
use crate::desktop::protocols::{resource, servo as servo_handler, urlinfo};
|
|
|
|
pub enum XrDiscovery {
|
|
GlWindow(GlWindowDiscovery),
|
|
#[cfg(target_os = "windows")]
|
|
OpenXr(OpenXrDiscovery),
|
|
}
|
|
|
|
pub struct EmbedderCallbacks {
|
|
event_loop_waker: Box<dyn EventLoopWaker>,
|
|
xr_discovery: Option<XrDiscovery>,
|
|
}
|
|
|
|
impl EmbedderCallbacks {
|
|
pub fn new(
|
|
event_loop_waker: Box<dyn EventLoopWaker>,
|
|
xr_discovery: Option<XrDiscovery>,
|
|
) -> EmbedderCallbacks {
|
|
EmbedderCallbacks {
|
|
event_loop_waker,
|
|
xr_discovery,
|
|
}
|
|
}
|
|
}
|
|
|
|
impl EmbedderMethods for EmbedderCallbacks {
|
|
fn create_event_loop_waker(&mut self) -> Box<dyn EventLoopWaker> {
|
|
self.event_loop_waker.clone()
|
|
}
|
|
|
|
fn register_webxr(
|
|
&mut self,
|
|
xr: &mut webxr::MainThreadRegistry,
|
|
_embedder_proxy: EmbedderProxy,
|
|
) {
|
|
if pref!(dom.webxr.test) {
|
|
xr.register_mock(webxr::headless::HeadlessMockDiscovery::new());
|
|
} else if let Some(xr_discovery) = self.xr_discovery.take() {
|
|
match xr_discovery {
|
|
XrDiscovery::GlWindow(discovery) => xr.register(discovery),
|
|
#[cfg(target_os = "windows")]
|
|
XrDiscovery::OpenXr(discovery) => xr.register(discovery),
|
|
}
|
|
}
|
|
}
|
|
|
|
fn get_protocol_handlers(&self) -> ProtocolRegistry {
|
|
let mut registry = ProtocolRegistry::default();
|
|
registry.register("urlinfo", urlinfo::UrlInfoProtocolHander::default());
|
|
registry.register("servo", servo_handler::ServoProtocolHander::default());
|
|
registry.register("resource", resource::ResourceProtocolHander::default());
|
|
registry
|
|
}
|
|
|
|
fn get_version_string(&self) -> Option<String> {
|
|
crate::servo_version().into()
|
|
}
|
|
}
|