diff options
author | Alan Jeffrey <ajeffrey@mozilla.com> | 2019-07-01 11:50:25 -0500 |
---|---|---|
committer | Alan Jeffrey <ajeffrey@mozilla.com> | 2019-07-02 18:23:56 -0500 |
commit | 91d1b52b38e4e4c300a12252dc491ecebb2dfb76 (patch) | |
tree | 782d2bb4236371783e25965272bd77061be00583 | |
parent | b4ed3b6f3c6f8dedde41ac28ec3afdb117f5a44a (diff) | |
download | servo-91d1b52b38e4e4c300a12252dc491ecebb2dfb76.tar.gz servo-91d1b52b38e4e4c300a12252dc491ecebb2dfb76.zip |
Initialize a wevxr device registry from Servo
-rw-r--r-- | Cargo.lock | 26 | ||||
-rw-r--r-- | Cargo.toml | 2 | ||||
-rw-r--r-- | components/canvas_traits/Cargo.toml | 1 | ||||
-rw-r--r-- | components/canvas_traits/webgl.rs | 19 | ||||
-rw-r--r-- | components/compositing/Cargo.toml | 1 | ||||
-rw-r--r-- | components/compositing/windowing.rs | 3 | ||||
-rw-r--r-- | components/servo/Cargo.toml | 1 | ||||
-rw-r--r-- | components/servo/lib.rs | 7 | ||||
-rw-r--r-- | ports/glutin/Cargo.toml | 1 |
9 files changed, 61 insertions, 0 deletions
diff --git a/Cargo.lock b/Cargo.lock index 0942a6c41ef..ee5726ad8ad 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -429,6 +429,7 @@ dependencies = [ "servo_config 0.0.1", "webrender_api 0.60.0 (git+https://github.com/servo/webrender)", "webvr_traits 0.0.1", + "webxr-api 0.0.1 (git+https://github.com/servo/webxr.git)", ] [[package]] @@ -617,6 +618,7 @@ dependencies = [ "webrender_api 0.60.0 (git+https://github.com/servo/webrender)", "webvr 0.0.1", "webvr_traits 0.0.1", + "webxr-api 0.0.1 (git+https://github.com/servo/webxr.git)", ] [[package]] @@ -2487,6 +2489,7 @@ dependencies = [ "webrender_api 0.60.0 (git+https://github.com/servo/webrender)", "webvr 0.0.1", "webvr_traits 0.0.1", + "webxr-api 0.0.1 (git+https://github.com/servo/webxr.git)", ] [[package]] @@ -3980,6 +3983,7 @@ dependencies = [ "rust-webvr 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", "sig 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "tinyfiledialogs 3.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "webxr 0.0.1 (git+https://github.com/servo/webxr.git)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "winres 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "x11 2.17.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5327,6 +5331,26 @@ dependencies = [ ] [[package]] +name = "webxr" +version = "0.0.1" +source = "git+https://github.com/servo/webxr.git#49b9312354e322ab3cd94695af7d30f09cea8d3a" +dependencies = [ + "euclid 0.19.8 (registry+https://github.com/rust-lang/crates.io-index)", + "gleam 0.6.16 (registry+https://github.com/rust-lang/crates.io-index)", + "glutin 0.21.0 (registry+https://github.com/rust-lang/crates.io-index)", + "webxr-api 0.0.1 (git+https://github.com/servo/webxr.git)", +] + +[[package]] +name = "webxr-api" +version = "0.0.1" +source = "git+https://github.com/servo/webxr.git#49b9312354e322ab3cd94695af7d30f09cea8d3a" +dependencies = [ + "euclid 0.19.8 (registry+https://github.com/rust-lang/crates.io-index)", + "gleam 0.6.16 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] name = "weedle" version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -5961,6 +5985,8 @@ dependencies = [ "checksum webrender 0.60.0 (git+https://github.com/servo/webrender)" = "<none>" "checksum webrender_api 0.60.0 (git+https://github.com/servo/webrender)" = "<none>" "checksum webrender_build 0.0.1 (git+https://github.com/servo/webrender)" = "<none>" +"checksum webxr 0.0.1 (git+https://github.com/servo/webxr.git)" = "<none>" +"checksum webxr-api 0.0.1 (git+https://github.com/servo/webxr.git)" = "<none>" "checksum weedle 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bcc44aa200daee8b1f3a004beaf16554369746f1b4486f0cf93b0caf8a3c2d1e" "checksum which 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b57acb10231b9493c8472b20cb57317d0679a49e0bdbee44b3b803a6473af164" "checksum winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "f10e386af2b13e47c89e7236a7a14a086791a2b88ebad6df9bf42040195cf770" diff --git a/Cargo.toml b/Cargo.toml index 060be41a5d2..861c79e6d14 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,6 +15,8 @@ opt-level = 3 # lto = false [patch.crates-io] +webxr-api = { git = "https://github.com/servo/webxr.git" } +webxr = { git = "https://github.com/servo/webxr.git" } # If you need to temporarily test Servo with a local fork of some upstream # crate, add that here. Use the form: # diff --git a/components/canvas_traits/Cargo.toml b/components/canvas_traits/Cargo.toml index 6334f4f53ca..d9c9faaae6d 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 = "0.0.1" 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..57c34870f69 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 = "0.0.1" [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..0b927391f92 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 = "0.0.1" [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(); diff --git a/ports/glutin/Cargo.toml b/ports/glutin/Cargo.toml index 6bf0efa5fd8..c8fa4939951 100644 --- a/ports/glutin/Cargo.toml +++ b/ports/glutin/Cargo.toml @@ -55,6 +55,7 @@ libservo = {path = "../../components/servo"} libc = "0.2" log = "0.4" rust-webvr = { version = "0.13", features = ["glwindow"] } +webxr = { version = "0.0.1", features = ["glwindow"] } tinyfiledialogs = "3.0" [target.'cfg(any(target_os = "linux", target_os = "windows"))'.dependencies] |