mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
Pass the GL context to the VRDisplay when rendering
This commit is contained in:
parent
42ebf46172
commit
8ddde7eacc
7 changed files with 34 additions and 22 deletions
10
Cargo.lock
generated
10
Cargo.lock
generated
|
@ -3337,15 +3337,16 @@ dependencies = [
|
||||||
"libloading 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"libloading 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
"log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"ovr-mobile-sys 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"ovr-mobile-sys 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"rust-webvr-api 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rust-webvr-api 0.10.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rust-webvr-api"
|
name = "rust-webvr-api"
|
||||||
version = "0.10.2"
|
version = "0.10.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"android_injected_glue 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
"android_injected_glue 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"gleam 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"ipc-channel 0.11.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"ipc-channel 0.11.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"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)",
|
||||||
"serde_derive 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde_derive 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -4862,6 +4863,7 @@ dependencies = [
|
||||||
"canvas_traits 0.0.1",
|
"canvas_traits 0.0.1",
|
||||||
"crossbeam-channel 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"crossbeam-channel 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"euclid 0.19.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
"euclid 0.19.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"gleam 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"ipc-channel 0.11.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"ipc-channel 0.11.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
"log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"msg 0.0.1",
|
"msg 0.0.1",
|
||||||
|
@ -4877,7 +4879,7 @@ version = "0.0.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"ipc-channel 0.11.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"ipc-channel 0.11.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"msg 0.0.1",
|
"msg 0.0.1",
|
||||||
"rust-webvr-api 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rust-webvr-api 0.10.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"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)",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -5357,7 +5359,7 @@ dependencies = [
|
||||||
"checksum remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3488ba1b9a2084d38645c4c08276a1752dcbf2c7130d74f1569681ad5d2799c5"
|
"checksum remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3488ba1b9a2084d38645c4c08276a1752dcbf2c7130d74f1569681ad5d2799c5"
|
||||||
"checksum ron 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "da06feaa07f69125ab9ddc769b11de29090122170b402547f64b86fe16ebc399"
|
"checksum ron 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "da06feaa07f69125ab9ddc769b11de29090122170b402547f64b86fe16ebc399"
|
||||||
"checksum rust-webvr 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4251e156fc27e2ce17a747e3270ee6940c754145cead0cf5da29792328baf473"
|
"checksum rust-webvr 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4251e156fc27e2ce17a747e3270ee6940c754145cead0cf5da29792328baf473"
|
||||||
"checksum rust-webvr-api 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "95d96901d94bc4e43998cc77f804f6944acb993b61c8470fc3c9600650608148"
|
"checksum rust-webvr-api 0.10.3 (registry+https://github.com/rust-lang/crates.io-index)" = "f8ae20fc34d4b4f59d00be7fa2c06802ad90a0a33195a6f5f73832c6acc5b8fa"
|
||||||
"checksum rustc-demangle 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "3058a43ada2c2d0b92b3ae38007a2d0fa5e9db971be260e0171408a4ff471c95"
|
"checksum rustc-demangle 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "3058a43ada2c2d0b92b3ae38007a2d0fa5e9db971be260e0171408a4ff471c95"
|
||||||
"checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a"
|
"checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a"
|
||||||
"checksum rusttype 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b8eb11f5b0a98c8eca2fb1483f42646d8c340e83e46ab416f8a063a0fd0eeb20"
|
"checksum rusttype 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b8eb11f5b0a98c8eca2fb1483f42646d8c340e83e46ab416f8a063a0fd0eeb20"
|
||||||
|
|
|
@ -11,6 +11,7 @@ use canvas_traits::webgl::{WebGLSender, WebVRCommand, WebVRRenderHandler};
|
||||||
use euclid::Size2D;
|
use euclid::Size2D;
|
||||||
use fnv::FnvHashMap;
|
use fnv::FnvHashMap;
|
||||||
use gleam::gl;
|
use gleam::gl;
|
||||||
|
use gleam::gl::Gl;
|
||||||
use servo_config::prefs::PREFS;
|
use servo_config::prefs::PREFS;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
||||||
|
@ -112,8 +113,8 @@ impl WebGLExternalImageApi for WebGLExternalImages {
|
||||||
struct WebVRRenderWrapper(Box<dyn WebVRRenderHandler>);
|
struct WebVRRenderWrapper(Box<dyn WebVRRenderHandler>);
|
||||||
|
|
||||||
impl WebVRRenderHandler for WebVRRenderWrapper {
|
impl WebVRRenderHandler for WebVRRenderWrapper {
|
||||||
fn handle(&mut self, command: WebVRCommand, texture: Option<(u32, Size2D<i32>)>) {
|
fn handle(&mut self, gl: &dyn Gl, command: WebVRCommand, texture: Option<(u32, Size2D<i32>)>) {
|
||||||
self.0.handle(command, texture);
|
self.0.handle(gl, command, texture);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -210,15 +210,19 @@ impl<VR: WebVRRenderHandler + 'static> WebGLThread<VR> {
|
||||||
|
|
||||||
/// Handles a WebVRCommand for a specific WebGLContext
|
/// Handles a WebVRCommand for a specific WebGLContext
|
||||||
fn handle_webvr_command(&mut self, context_id: WebGLContextId, command: WebVRCommand) {
|
fn handle_webvr_command(&mut self, context_id: WebGLContextId, command: WebVRCommand) {
|
||||||
Self::make_current_if_needed(context_id, &self.contexts, &mut self.bound_context_id);
|
if let Some(context) =
|
||||||
let texture = match command {
|
Self::make_current_if_needed(context_id, &self.contexts, &mut self.bound_context_id)
|
||||||
WebVRCommand::SubmitFrame(..) => self.cached_context_info.get(&context_id),
|
{
|
||||||
_ => None,
|
let texture = match command {
|
||||||
};
|
WebVRCommand::SubmitFrame(..) => self.cached_context_info.get(&context_id),
|
||||||
self.webvr_compositor
|
_ => None,
|
||||||
.as_mut()
|
};
|
||||||
.unwrap()
|
self.webvr_compositor.as_mut().unwrap().handle(
|
||||||
.handle(command, texture.map(|t| (t.texture_id, t.size)));
|
context.ctx.gl(),
|
||||||
|
command,
|
||||||
|
texture.map(|t| (t.texture_id, t.size)),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Handles a lock external callback received from webrender::ExternalImageHandler
|
/// Handles a lock external callback received from webrender::ExternalImageHandler
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
use euclid::{Rect, Size2D};
|
use euclid::{Rect, Size2D};
|
||||||
use gleam::gl;
|
use gleam::gl;
|
||||||
|
use gleam::gl::Gl;
|
||||||
use ipc_channel::ipc::{IpcBytesReceiver, IpcBytesSender, IpcSharedMemory};
|
use ipc_channel::ipc::{IpcBytesReceiver, IpcBytesSender, IpcSharedMemory};
|
||||||
use offscreen_gl_context::{GLContextAttributes, GLLimits};
|
use offscreen_gl_context::{GLContextAttributes, GLLimits};
|
||||||
use pixels::PixelFormat;
|
use pixels::PixelFormat;
|
||||||
|
@ -521,7 +522,7 @@ pub enum WebVRCommand {
|
||||||
// Trait object that handles WebVR commands.
|
// Trait object that handles WebVR commands.
|
||||||
// Receives the texture id and size associated to the WebGLContext.
|
// Receives the texture id and size associated to the WebGLContext.
|
||||||
pub trait WebVRRenderHandler: Send {
|
pub trait WebVRRenderHandler: Send {
|
||||||
fn handle(&mut self, command: WebVRCommand, texture: Option<(u32, Size2D<i32>)>);
|
fn handle(&mut self, gl: &dyn Gl, command: WebVRCommand, texture: Option<(u32, Size2D<i32>)>);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// WebGL commands required to implement DOMToTexture feature.
|
/// WebGL commands required to implement DOMToTexture feature.
|
||||||
|
|
|
@ -18,6 +18,7 @@ oculusvr = ['rust-webvr/oculusvr']
|
||||||
canvas_traits = {path = "../canvas_traits"}
|
canvas_traits = {path = "../canvas_traits"}
|
||||||
crossbeam-channel = "0.3"
|
crossbeam-channel = "0.3"
|
||||||
euclid = "0.19"
|
euclid = "0.19"
|
||||||
|
gleam = "0.6"
|
||||||
ipc-channel = "0.11"
|
ipc-channel = "0.11"
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
msg = {path = "../msg"}
|
msg = {path = "../msg"}
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
use canvas_traits::webgl;
|
use canvas_traits::webgl;
|
||||||
use crossbeam_channel::{unbounded, Receiver, Sender};
|
use crossbeam_channel::{unbounded, Receiver, Sender};
|
||||||
use euclid::Size2D;
|
use euclid::Size2D;
|
||||||
|
use gleam::gl::Gl;
|
||||||
use ipc_channel::ipc;
|
use ipc_channel::ipc;
|
||||||
use ipc_channel::ipc::{IpcReceiver, IpcSender};
|
use ipc_channel::ipc::{IpcReceiver, IpcSender};
|
||||||
use msg::constellation_msg::PipelineId;
|
use msg::constellation_msg::PipelineId;
|
||||||
|
@ -376,7 +377,12 @@ impl WebVRCompositorHandler {
|
||||||
|
|
||||||
impl webgl::WebVRRenderHandler for WebVRCompositorHandler {
|
impl webgl::WebVRRenderHandler for WebVRCompositorHandler {
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
fn handle(&mut self, cmd: webgl::WebVRCommand, texture: Option<(u32, Size2D<i32>)>) {
|
fn handle(
|
||||||
|
&mut self,
|
||||||
|
gl: &dyn Gl,
|
||||||
|
cmd: webgl::WebVRCommand,
|
||||||
|
texture: Option<(u32, Size2D<i32>)>,
|
||||||
|
) {
|
||||||
match cmd {
|
match cmd {
|
||||||
webgl::WebVRCommand::Create(compositor_id) => {
|
webgl::WebVRCommand::Create(compositor_id) => {
|
||||||
if let Some(compositor) = self.create_compositor(compositor_id) {
|
if let Some(compositor) = self.create_compositor(compositor_id) {
|
||||||
|
@ -400,10 +406,7 @@ impl webgl::WebVRRenderHandler for WebVRCompositorHandler {
|
||||||
right_bounds: right_bounds,
|
right_bounds: right_bounds,
|
||||||
texture_size: Some((size.width as u32, size.height as u32)),
|
texture_size: Some((size.width as u32, size.height as u32)),
|
||||||
};
|
};
|
||||||
unsafe {
|
unsafe { (*compositor.0).submit_layer(gl, &layer) };
|
||||||
(*compositor.0).render_layer(&layer);
|
|
||||||
(*compositor.0).submit_frame();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -13,5 +13,5 @@ path = "lib.rs"
|
||||||
[dependencies]
|
[dependencies]
|
||||||
ipc-channel = "0.11"
|
ipc-channel = "0.11"
|
||||||
msg = {path = "../msg"}
|
msg = {path = "../msg"}
|
||||||
rust-webvr-api = {version = "0.10.2", features = ["ipc"]}
|
rust-webvr-api = {version = "0.10.3", features = ["ipc"]}
|
||||||
serde = "1.0"
|
serde = "1.0"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue