mirror of
https://github.com/servo/servo.git
synced 2025-08-07 06:25:32 +01:00
Finish the integration of webxr
into the Cargo workspace (#35229)
- Run `cargo fmt` on `webxr` and `webxr-api` - Fix clippy warnings in the existing `webxr` code - Integrate the new crates into the workspace - Expose `webxr` via the libservo API rather than requiring embedders to depend on it explicitly. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
parent
a4c6c205d2
commit
5466c27f6f
41 changed files with 448 additions and 649 deletions
|
@ -53,7 +53,7 @@ tracing-hitrace = ["tracing", "dep:hitrace"]
|
|||
tracing-perfetto = ["tracing", "dep:tracing-perfetto"]
|
||||
webdriver = ["libservo/webdriver"]
|
||||
webgl_backtrace = ["libservo/webgl_backtrace"]
|
||||
webxr = ["dep:webxr", "libservo/webxr"]
|
||||
webxr = ["libservo/webxr"]
|
||||
webgpu = ["libservo/webgpu"]
|
||||
|
||||
[dependencies]
|
||||
|
@ -101,7 +101,6 @@ xcomponent-sys = { version = "0.3.1", features = ["api-12", "keyboard-types"] }
|
|||
nix = { workspace = true, features = ["fs"] }
|
||||
surfman = { workspace = true, features = ["sm-angle-default"] }
|
||||
serde_json = { workspace = true }
|
||||
webxr = { workspace = true, optional = true }
|
||||
|
||||
[target.'cfg(not(any(target_os = "android", target_env = "ohos")))'.dependencies]
|
||||
# For optional feature servo_allocator/use-system-allocator
|
||||
|
@ -123,7 +122,6 @@ serde_json = { workspace = true }
|
|||
shellwords = "1.0.0"
|
||||
surfman = { workspace = true, features = ["sm-x11", "sm-raw-window-handle-06"] }
|
||||
tinyfiledialogs = "3.0"
|
||||
webxr = { workspace = true, features = ["ipc", "glwindow", "headless"] }
|
||||
winit = "0.30.8"
|
||||
|
||||
[target.'cfg(any(all(target_os = "linux", not(target_env = "ohos")), target_os = "windows"))'.dependencies]
|
||||
|
@ -133,6 +131,5 @@ image = { workspace = true }
|
|||
sig = "1.0"
|
||||
|
||||
[target.'cfg(target_os = "windows")'.dependencies]
|
||||
webxr = { workspace = true, features = ["ipc", "glwindow", "headless", "openxr-api"] }
|
||||
windows-sys = { workspace = true, features = ["Win32_Graphics_Gdi"] }
|
||||
libservo = { path = "../../components/servo", features = ["no-wgl"] }
|
||||
|
|
|
@ -20,12 +20,12 @@ use servo::config::prefs::Preferences;
|
|||
use servo::servo_config::pref;
|
||||
use servo::servo_url::ServoUrl;
|
||||
use servo::webrender_traits::SurfmanRenderingContext;
|
||||
use servo::webxr::glwindow::GlWindowDiscovery;
|
||||
#[cfg(target_os = "windows")]
|
||||
use servo::webxr::openxr::{AppInfo, OpenXrDiscovery};
|
||||
use servo::{EventLoopWaker, Servo};
|
||||
use surfman::Connection;
|
||||
use url::Url;
|
||||
use webxr::glwindow::GlWindowDiscovery;
|
||||
#[cfg(target_os = "windows")]
|
||||
use webxr::openxr::{AppInfo, OpenXrDiscovery};
|
||||
use winit::application::ApplicationHandler;
|
||||
use winit::event::WindowEvent;
|
||||
use winit::event_loop::{ActiveEventLoop, ControlFlow};
|
||||
|
|
|
@ -7,10 +7,10 @@
|
|||
use net::protocols::ProtocolRegistry;
|
||||
use servo::compositing::windowing::EmbedderMethods;
|
||||
use servo::servo_config::pref;
|
||||
use servo::{EmbedderProxy, EventLoopWaker};
|
||||
use webxr::glwindow::GlWindowDiscovery;
|
||||
use servo::webxr::glwindow::GlWindowDiscovery;
|
||||
#[cfg(target_os = "windows")]
|
||||
use webxr::openxr::OpenXrDiscovery;
|
||||
use servo::webxr::openxr::OpenXrDiscovery;
|
||||
use servo::{EmbedderProxy, EventLoopWaker};
|
||||
|
||||
use crate::desktop::protocols::{resource, servo as servo_handler, urlinfo};
|
||||
|
||||
|
@ -45,11 +45,13 @@ impl EmbedderMethods for EmbedderCallbacks {
|
|||
#[cfg(feature = "webxr")]
|
||||
fn register_webxr(
|
||||
&mut self,
|
||||
xr: &mut webxr::MainThreadRegistry,
|
||||
xr: &mut servo::webxr::MainThreadRegistry,
|
||||
_embedder_proxy: EmbedderProxy,
|
||||
) {
|
||||
use servo::webxr::headless::HeadlessMockDiscovery;
|
||||
|
||||
if pref!(dom_webxr_test) {
|
||||
xr.register_mock(webxr::headless::HeadlessMockDiscovery::new());
|
||||
xr.register_mock(HeadlessMockDiscovery::default());
|
||||
} else if let Some(xr_discovery) = self.xr_discovery.take() {
|
||||
match xr_discovery {
|
||||
XrDiscovery::GlWindow(discovery) => xr.register(discovery),
|
||||
|
|
|
@ -636,7 +636,7 @@ impl WindowPortsMethods for Window {
|
|||
fn new_glwindow(
|
||||
&self,
|
||||
event_loop: &winit::event_loop::ActiveEventLoop,
|
||||
) -> Rc<dyn webxr::glwindow::GlWindow> {
|
||||
) -> Rc<dyn servo::webxr::glwindow::GlWindow> {
|
||||
let size = self.winit_window.outer_size();
|
||||
|
||||
let window_attr = winit::window::Window::default_attributes()
|
||||
|
@ -734,12 +734,12 @@ struct XRWindowPose {
|
|||
xr_translation: Cell<Vector3D<f32, UnknownUnit>>,
|
||||
}
|
||||
|
||||
impl webxr::glwindow::GlWindow for XRWindow {
|
||||
impl servo::webxr::glwindow::GlWindow for XRWindow {
|
||||
fn get_render_target(
|
||||
&self,
|
||||
device: &mut Device,
|
||||
_context: &mut Context,
|
||||
) -> webxr::glwindow::GlWindowRenderTarget {
|
||||
) -> servo::webxr::glwindow::GlWindowRenderTarget {
|
||||
self.winit_window.set_visible(true);
|
||||
let window_handle = self
|
||||
.winit_window
|
||||
|
@ -751,7 +751,7 @@ impl webxr::glwindow::GlWindow for XRWindow {
|
|||
.connection()
|
||||
.create_native_widget_from_window_handle(window_handle, size)
|
||||
.expect("Failed to create native widget");
|
||||
webxr::glwindow::GlWindowRenderTarget::NativeWidget(native_widget)
|
||||
servo::webxr::glwindow::GlWindowRenderTarget::NativeWidget(native_widget)
|
||||
}
|
||||
|
||||
fn get_rotation(&self) -> Rotation3D<f32, UnknownUnit, UnknownUnit> {
|
||||
|
@ -762,17 +762,17 @@ impl webxr::glwindow::GlWindow for XRWindow {
|
|||
self.pose.xr_translation.get()
|
||||
}
|
||||
|
||||
fn get_mode(&self) -> webxr::glwindow::GlWindowMode {
|
||||
fn get_mode(&self) -> servo::webxr::glwindow::GlWindowMode {
|
||||
if pref!(dom_webxr_glwindow_red_cyan) {
|
||||
webxr::glwindow::GlWindowMode::StereoRedCyan
|
||||
servo::webxr::glwindow::GlWindowMode::StereoRedCyan
|
||||
} else if pref!(dom_webxr_glwindow_left_right) {
|
||||
webxr::glwindow::GlWindowMode::StereoLeftRight
|
||||
servo::webxr::glwindow::GlWindowMode::StereoLeftRight
|
||||
} else if pref!(dom_webxr_glwindow_spherical) {
|
||||
webxr::glwindow::GlWindowMode::Spherical
|
||||
servo::webxr::glwindow::GlWindowMode::Spherical
|
||||
} else if pref!(dom_webxr_glwindow_cubemap) {
|
||||
webxr::glwindow::GlWindowMode::Cubemap
|
||||
servo::webxr::glwindow::GlWindowMode::Cubemap
|
||||
} else {
|
||||
webxr::glwindow::GlWindowMode::Blit
|
||||
servo::webxr::glwindow::GlWindowMode::Blit
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -123,7 +123,7 @@ impl WindowPortsMethods for Window {
|
|||
fn new_glwindow(
|
||||
&self,
|
||||
_events_loop: &winit::event_loop::ActiveEventLoop,
|
||||
) -> Rc<dyn webxr::glwindow::GlWindow> {
|
||||
) -> Rc<dyn servo::webxr::glwindow::GlWindow> {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ pub trait WindowPortsMethods: WindowMethods {
|
|||
fn new_glwindow(
|
||||
&self,
|
||||
event_loop: &winit::event_loop::ActiveEventLoop,
|
||||
) -> Rc<dyn webxr::glwindow::GlWindow>;
|
||||
) -> Rc<dyn servo::webxr::glwindow::GlWindow>;
|
||||
fn winit_window(&self) -> Option<&winit::window::Window>;
|
||||
fn toolbar_height(&self) -> Length<f32, DeviceIndependentPixel>;
|
||||
fn set_toolbar_height(&self, height: Length<f32, DeviceIndependentPixel>);
|
||||
|
|
|
@ -35,7 +35,7 @@ pub struct InitOptions {
|
|||
pub coordinates: Coordinates,
|
||||
pub density: f32,
|
||||
#[cfg(feature = "webxr")]
|
||||
pub xr_discovery: Option<webxr::Discovery>,
|
||||
pub xr_discovery: Option<servo::webxr::Discovery>,
|
||||
pub surfman_integration: SurfmanIntegration,
|
||||
}
|
||||
|
||||
|
|
|
@ -681,13 +681,13 @@ impl ServoGlue {
|
|||
pub(super) struct ServoEmbedderCallbacks {
|
||||
waker: Box<dyn EventLoopWaker>,
|
||||
#[cfg(feature = "webxr")]
|
||||
xr_discovery: Option<webxr::Discovery>,
|
||||
xr_discovery: Option<servo::webxr::Discovery>,
|
||||
}
|
||||
|
||||
impl ServoEmbedderCallbacks {
|
||||
pub(super) fn new(
|
||||
waker: Box<dyn EventLoopWaker>,
|
||||
#[cfg(feature = "webxr")] xr_discovery: Option<webxr::Discovery>,
|
||||
#[cfg(feature = "webxr")] xr_discovery: Option<servo::webxr::Discovery>,
|
||||
) -> Self {
|
||||
Self {
|
||||
waker,
|
||||
|
@ -706,7 +706,7 @@ impl EmbedderMethods for ServoEmbedderCallbacks {
|
|||
#[cfg(feature = "webxr")]
|
||||
fn register_webxr(
|
||||
&mut self,
|
||||
registry: &mut webxr::MainThreadRegistry,
|
||||
registry: &mut servo::webxr::MainThreadRegistry,
|
||||
_embedder_proxy: EmbedderProxy,
|
||||
) {
|
||||
debug!("EmbedderMethods::register_xr");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue