feat: webxr feature flag (#34241)

* Add webxr feature flag

Add webxr feature flag to embedder_traits

Add webxr flag to constellation

Add webxr flag to compositor

Add webxr flag to canvas

Turn registry into optional

Add webxr flag to servo lib

Signed-off-by: Wu Yu Wei <yuweiwu@pm.me>
Co-authored-by: august kline <me@augustkline.com>

* Cargo fmt

Signed-off-by: Wu Yu Wei <yuweiwu@pm.me>

* Add missing license

Signed-off-by: Wu Yu Wei <yuweiwu@pm.me>

* Cargo clippy

Signed-off-by: Wu Yu Wei <yuweiwu@pm.me>

---------

Signed-off-by: Wu Yu Wei <yuweiwu@pm.me>
Co-authored-by: august kline <me@augustkline.com>
This commit is contained in:
Ngo Iok Ui (Wu Yu Wei) 2024-11-14 02:16:58 +09:00 committed by GitHub
parent 91f96cc9dd
commit 47a243614f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
21 changed files with 456 additions and 374 deletions

View file

@ -11,6 +11,9 @@ rust-version.workspace = true
name = "embedder_traits"
path = "lib.rs"
[features]
webxr = ["dep:webxr-api"]
[dependencies]
base = { workspace = true }
cfg-if = { workspace = true }
@ -23,4 +26,4 @@ num-traits = { workspace = true }
serde = { workspace = true }
servo_url = { path = "../../url" }
webrender_api = { workspace = true }
webxr-api = { workspace = true, features = ["ipc"] }
webxr-api = { workspace = true, features = ["ipc"], optional = true }

View file

@ -15,7 +15,6 @@ use num_derive::FromPrimitive;
use serde::{Deserialize, Serialize};
use servo_url::ServoUrl;
use webrender_api::units::{DeviceIntPoint, DeviceIntRect, DeviceIntSize};
pub use webxr_api::MainThreadWaker as EventLoopWaker;
/// A cursor for the window. This is different from a CSS cursor (see
/// `CursorKind`) in that it has no `Auto` value.
@ -59,6 +58,21 @@ pub enum Cursor {
ZoomOut,
}
#[cfg(feature = "webxr")]
pub use webxr_api::MainThreadWaker as EventLoopWaker;
#[cfg(not(feature = "webxr"))]
pub trait EventLoopWaker: 'static + Send {
fn clone_box(&self) -> Box<dyn EventLoopWaker>;
fn wake(&self);
}
#[cfg(not(feature = "webxr"))]
impl Clone for Box<dyn EventLoopWaker> {
fn clone(&self) -> Self {
EventLoopWaker::clone_box(self.as_ref())
}
}
/// Sends messages to the embedder.
pub struct EmbedderProxy {
pub sender: Sender<(Option<TopLevelBrowsingContextId>, EmbedderMsg)>,

View file

@ -658,7 +658,7 @@ pub struct InitialScriptState {
/// A channel to the WebGL thread used in this pipeline.
pub webgl_chan: Option<WebGLPipeline>,
/// The XR device registry
pub webxr_registry: webxr_api::Registry,
pub webxr_registry: Option<webxr_api::Registry>,
/// The Webrender document ID associated with this thread.
pub webrender_document: DocumentId,
/// Access to the compositor across a process boundary.