Enable OpenXR backend from the WebXR crate (#32817)

* Enable OpenXR backend from the WebXR crate

Signed-off-by: Daniel Adams <msub2official@gmail.com>

* Ensure openxr feature is only included on windows

Signed-off-by: Daniel Adams <msub2official@gmail.com>

* Add cfgs for OpenXR usages

Signed-off-by: Daniel Adams <msub2official@gmail.com>

---------

Signed-off-by: Daniel Adams <msub2official@gmail.com>
This commit is contained in:
Daniel Adams 2024-07-19 20:24:40 -10:00 committed by GitHub
parent a29e5c8115
commit 9212ed203a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 56 additions and 6 deletions

View file

@ -19,6 +19,8 @@ use servo::servo_config::pref;
use servo::Servo;
use surfman::GLApi;
use webxr::glwindow::GlWindowDiscovery;
#[cfg(target_os = "windows")]
use webxr::openxr::OpenXrDiscovery;
use winit::event::WindowEvent;
use winit::event_loop::EventLoopWindowTarget;
use winit::window::WindowId;
@ -27,7 +29,7 @@ use super::events_loop::{EventsLoop, WakerEvent};
use super::minibrowser::Minibrowser;
use super::webview::WebViewManager;
use super::{headed_window, headless_window};
use crate::desktop::embedder::EmbedderCallbacks;
use crate::desktop::embedder::{EmbedderCallbacks, XrDiscovery};
use crate::desktop::tracing::trace_winit_event;
use crate::desktop::window_trait::WindowPortsMethods;
use crate::parser::get_default_url;
@ -153,12 +155,19 @@ impl App {
>(w.unwrap())
};
let factory = Box::new(move || Ok(window.new_glwindow(w)));
Some(GlWindowDiscovery::new(
Some(XrDiscovery::GlWindow(GlWindowDiscovery::new(
surfman.connection(),
surfman.adapter(),
surfman.context_attributes(),
factory,
))
)))
} else if pref!(dom.webxr.openxr.enabled) && !opts::get().headless {
#[cfg(target_os = "windows")]
let openxr = Some(XrDiscovery::OpenXr(OpenXrDiscovery::new(None)));
#[cfg(not(target_os = "windows"))]
let openxr = None;
openxr
} else {
None
};