aboutsummaryrefslogtreecommitdiffstats
path: root/components
diff options
context:
space:
mode:
Diffstat (limited to 'components')
-rw-r--r--components/canvas_traits/Cargo.toml1
-rw-r--r--components/canvas_traits/webgl.rs19
-rw-r--r--components/compositing/Cargo.toml1
-rw-r--r--components/compositing/windowing.rs3
-rw-r--r--components/servo/Cargo.toml1
-rw-r--r--components/servo/lib.rs7
6 files changed, 32 insertions, 0 deletions
diff --git a/components/canvas_traits/Cargo.toml b/components/canvas_traits/Cargo.toml
index 6334f4f53ca..c477e3c8c06 100644
--- a/components/canvas_traits/Cargo.toml
+++ b/components/canvas_traits/Cargo.toml
@@ -27,3 +27,4 @@ serde_bytes = "0.10"
servo_config = {path = "../config"}
webrender_api = {git = "https://github.com/servo/webrender", features = ["ipc"]}
webvr_traits = {path = "../webvr_traits"}
+webxr-api = {git = "https://github.com/servo/webxr"}
diff --git a/components/canvas_traits/webgl.rs b/components/canvas_traits/webgl.rs
index a36e8d0e659..f07cd99fb46 100644
--- a/components/canvas_traits/webgl.rs
+++ b/components/canvas_traits/webgl.rs
@@ -4,6 +4,8 @@
use euclid::{Rect, Size2D};
use gleam::gl;
+use gleam::gl::GLsync;
+use gleam::gl::GLuint;
use gleam::gl::Gl;
use ipc_channel::ipc::{IpcBytesReceiver, IpcBytesSender, IpcSharedMemory};
use pixels::PixelFormat;
@@ -175,6 +177,23 @@ impl WebGLMsgSender {
}
}
+impl webxr_api::WebGLExternalImageApi for WebGLMsgSender {
+ fn lock(&self) -> Result<(GLuint, Size2D<i32>, GLsync), webxr_api::Error> {
+ let (sender, receiver) = webgl_channel().or(Err(webxr_api::Error::CommunicationError))?;
+ self.sender
+ .send(WebGLMsg::Lock(self.ctx_id, sender))
+ .or(Err(webxr_api::Error::CommunicationError))?;
+ let (texture, size, sync) = receiver
+ .recv()
+ .or(Err(webxr_api::Error::CommunicationError))?;
+ Ok((texture, size, sync as GLsync))
+ }
+
+ fn unlock(&self) {
+ let _ = self.sender.send(WebGLMsg::Unlock(self.ctx_id));
+ }
+}
+
#[derive(Deserialize, Serialize)]
pub struct TruncatedDebug<T>(T);
diff --git a/components/compositing/Cargo.toml b/components/compositing/Cargo.toml
index cc2fadb2ca1..6ac076e3362 100644
--- a/components/compositing/Cargo.toml
+++ b/components/compositing/Cargo.toml
@@ -40,6 +40,7 @@ webrender = {git = "https://github.com/servo/webrender", features = ["capture"]}
webrender_api = {git = "https://github.com/servo/webrender", features = ["ipc"]}
webvr_traits = {path = "../webvr_traits"}
webvr = {path = "../webvr"}
+webxr-api = {git = "https://github.com/servo/webxr"}
[build-dependencies]
toml = "0.4.5"
diff --git a/components/compositing/windowing.rs b/components/compositing/windowing.rs
index f925c2f5473..9db0286bd5a 100644
--- a/components/compositing/windowing.rs
+++ b/components/compositing/windowing.rs
@@ -169,6 +169,9 @@ pub trait EmbedderMethods {
_: &mut Vec<Box<dyn WebVRMainThreadHeartbeat>>,
) {
}
+
+ /// Register services with a WebXR Registry.
+ fn register_webxr(&mut self, _: &mut webxr_api::Registry) {}
}
#[derive(Clone, Copy, Debug)]
diff --git a/components/servo/Cargo.toml b/components/servo/Cargo.toml
index 0b959ad2ef1..7d03959d767 100644
--- a/components/servo/Cargo.toml
+++ b/components/servo/Cargo.toml
@@ -78,6 +78,7 @@ webrender_api = {git = "https://github.com/servo/webrender", features = ["ipc"]}
webdriver_server = {path = "../webdriver_server", optional = true}
webvr = {path = "../webvr"}
webvr_traits = {path = "../webvr_traits"}
+webxr-api = {git = "https://github.com/servo/webxr"}
[target.'cfg(all(not(target_os = "windows"), not(target_os = "ios"), not(target_os="android"), not(target_arch="arm"), not(target_arch="aarch64")))'.dependencies]
gaol = {git = "https://github.com/servo/gaol"}
diff --git a/components/servo/lib.rs b/components/servo/lib.rs
index 0e5ccf2c2ad..545d3645306 100644
--- a/components/servo/lib.rs
+++ b/components/servo/lib.rs
@@ -285,6 +285,13 @@ where
// can't defer it after `create_constellation` has started.
script::init();
+ // For the moment, we enable use both the webxr crate and the rust-webvr crate,
+ // but we are migrating over to just using webxr.
+ let mut webxr_registry = webxr_api::Registry::new();
+ if pref!(dom.webvr.enabled) || pref!(dom.webxr.enabled) {
+ embedder.register_webxr(&mut webxr_registry);
+ }
+
let mut webvr_heartbeats = Vec::new();
let webvr_services = if pref!(dom.webvr.enabled) || pref!(dom.webxr.enabled) {
let mut services = VRServiceManager::new();