Skip to content
Permalink
Browse files

Initialize a wevxr device registry from Servo

  • Loading branch information...
asajeffrey committed Jul 1, 2019
1 parent b4ed3b6 commit 91d1b52b38e4e4c300a12252dc491ecebb2dfb76

Some generated files are not rendered by default. Learn more.

@@ -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:
#
@@ -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"
@@ -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);

@@ -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"
@@ -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)]
@@ -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"}
@@ -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();
@@ -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]

0 comments on commit 91d1b52

Please sign in to comment.
You can’t perform that action at this time.