mirror of
https://github.com/servo/servo.git
synced 2025-08-13 01:15:34 +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
|
@ -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>);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue