Initialize a wevxr device registry from Servo

This commit is contained in:
Alan Jeffrey 2019-07-01 11:50:25 -05:00
parent b4ed3b6f3c
commit 91d1b52b38
9 changed files with 61 additions and 0 deletions

26
Cargo.lock generated
View file

@ -429,6 +429,7 @@ dependencies = [
"servo_config 0.0.1", "servo_config 0.0.1",
"webrender_api 0.60.0 (git+https://github.com/servo/webrender)", "webrender_api 0.60.0 (git+https://github.com/servo/webrender)",
"webvr_traits 0.0.1", "webvr_traits 0.0.1",
"webxr-api 0.0.1 (git+https://github.com/servo/webxr.git)",
] ]
[[package]] [[package]]
@ -617,6 +618,7 @@ dependencies = [
"webrender_api 0.60.0 (git+https://github.com/servo/webrender)", "webrender_api 0.60.0 (git+https://github.com/servo/webrender)",
"webvr 0.0.1", "webvr 0.0.1",
"webvr_traits 0.0.1", "webvr_traits 0.0.1",
"webxr-api 0.0.1 (git+https://github.com/servo/webxr.git)",
] ]
[[package]] [[package]]
@ -2487,6 +2489,7 @@ dependencies = [
"webrender_api 0.60.0 (git+https://github.com/servo/webrender)", "webrender_api 0.60.0 (git+https://github.com/servo/webrender)",
"webvr 0.0.1", "webvr 0.0.1",
"webvr_traits 0.0.1", "webvr_traits 0.0.1",
"webxr-api 0.0.1 (git+https://github.com/servo/webxr.git)",
] ]
[[package]] [[package]]
@ -3980,6 +3983,7 @@ dependencies = [
"rust-webvr 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", "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)", "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)", "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)", "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)", "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)", "x11 2.17.3 (registry+https://github.com/rust-lang/crates.io-index)",
@ -5326,6 +5330,26 @@ dependencies = [
"serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[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]] [[package]]
name = "weedle" name = "weedle"
version = "0.9.0" version = "0.9.0"
@ -5961,6 +5985,8 @@ dependencies = [
"checksum webrender 0.60.0 (git+https://github.com/servo/webrender)" = "<none>" "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_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 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 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 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" "checksum winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "f10e386af2b13e47c89e7236a7a14a086791a2b88ebad6df9bf42040195cf770"

View file

@ -15,6 +15,8 @@ opt-level = 3
# lto = false # lto = false
[patch.crates-io] [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 # If you need to temporarily test Servo with a local fork of some upstream
# crate, add that here. Use the form: # crate, add that here. Use the form:
# #

View file

@ -27,3 +27,4 @@ serde_bytes = "0.10"
servo_config = {path = "../config"} servo_config = {path = "../config"}
webrender_api = {git = "https://github.com/servo/webrender", features = ["ipc"]} webrender_api = {git = "https://github.com/servo/webrender", features = ["ipc"]}
webvr_traits = {path = "../webvr_traits"} webvr_traits = {path = "../webvr_traits"}
webxr-api = "0.0.1"

View file

@ -4,6 +4,8 @@
use euclid::{Rect, Size2D}; use euclid::{Rect, Size2D};
use gleam::gl; use gleam::gl;
use gleam::gl::GLsync;
use gleam::gl::GLuint;
use gleam::gl::Gl; use gleam::gl::Gl;
use ipc_channel::ipc::{IpcBytesReceiver, IpcBytesSender, IpcSharedMemory}; use ipc_channel::ipc::{IpcBytesReceiver, IpcBytesSender, IpcSharedMemory};
use pixels::PixelFormat; 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)] #[derive(Deserialize, Serialize)]
pub struct TruncatedDebug<T>(T); pub struct TruncatedDebug<T>(T);

View file

@ -40,6 +40,7 @@ webrender = {git = "https://github.com/servo/webrender", features = ["capture"]}
webrender_api = {git = "https://github.com/servo/webrender", features = ["ipc"]} webrender_api = {git = "https://github.com/servo/webrender", features = ["ipc"]}
webvr_traits = {path = "../webvr_traits"} webvr_traits = {path = "../webvr_traits"}
webvr = {path = "../webvr"} webvr = {path = "../webvr"}
webxr-api = "0.0.1"
[build-dependencies] [build-dependencies]
toml = "0.4.5" toml = "0.4.5"

View file

@ -169,6 +169,9 @@ pub trait EmbedderMethods {
_: &mut Vec<Box<dyn WebVRMainThreadHeartbeat>>, _: &mut Vec<Box<dyn WebVRMainThreadHeartbeat>>,
) { ) {
} }
/// Register services with a WebXR Registry.
fn register_webxr(&mut self, _: &mut webxr_api::Registry) {}
} }
#[derive(Clone, Copy, Debug)] #[derive(Clone, Copy, Debug)]

View file

@ -78,6 +78,7 @@ webrender_api = {git = "https://github.com/servo/webrender", features = ["ipc"]}
webdriver_server = {path = "../webdriver_server", optional = true} webdriver_server = {path = "../webdriver_server", optional = true}
webvr = {path = "../webvr"} webvr = {path = "../webvr"}
webvr_traits = {path = "../webvr_traits"} 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] [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"} gaol = {git = "https://github.com/servo/gaol"}

View file

@ -285,6 +285,13 @@ where
// can't defer it after `create_constellation` has started. // can't defer it after `create_constellation` has started.
script::init(); 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 mut webvr_heartbeats = Vec::new();
let webvr_services = if pref!(dom.webvr.enabled) || pref!(dom.webxr.enabled) { let webvr_services = if pref!(dom.webvr.enabled) || pref!(dom.webxr.enabled) {
let mut services = VRServiceManager::new(); let mut services = VRServiceManager::new();

View file

@ -55,6 +55,7 @@ libservo = {path = "../../components/servo"}
libc = "0.2" libc = "0.2"
log = "0.4" log = "0.4"
rust-webvr = { version = "0.13", features = ["glwindow"] } rust-webvr = { version = "0.13", features = ["glwindow"] }
webxr = { version = "0.0.1", features = ["glwindow"] }
tinyfiledialogs = "3.0" tinyfiledialogs = "3.0"
[target.'cfg(any(target_os = "linux", target_os = "windows"))'.dependencies] [target.'cfg(any(target_os = "linux", target_os = "windows"))'.dependencies]