aboutsummaryrefslogtreecommitdiffstats
path: root/components/canvas/webgl_mode
diff options
context:
space:
mode:
authorFernando Jiménez Moreno <ferjmoreno@gmail.com>2019-06-25 19:42:47 +0200
committerFernando Jiménez Moreno <ferjmoreno@gmail.com>2019-07-04 10:26:47 +0200
commitba9cf85fb3c1697998abab92488a0ab7ecdf431d (patch)
treedb5d5a66e9272469a446d7fd49e886e24c3074b2 /components/canvas/webgl_mode
parent7d589ed4f5762ee185b60a34a76bb59cdf05a536 (diff)
downloadservo-ba9cf85fb3c1697998abab92488a0ab7ecdf431d.tar.gz
servo-ba9cf85fb3c1697998abab92488a0ab7ecdf431d.zip
Webrender external image handler demux
Diffstat (limited to 'components/canvas/webgl_mode')
-rw-r--r--components/canvas/webgl_mode/inprocess.rs23
1 files changed, 14 insertions, 9 deletions
diff --git a/components/canvas/webgl_mode/inprocess.rs b/components/canvas/webgl_mode/inprocess.rs
index b93b2fb0a19..6e53879c501 100644
--- a/components/canvas/webgl_mode/inprocess.rs
+++ b/components/canvas/webgl_mode/inprocess.rs
@@ -3,7 +3,7 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use crate::gl_context::GLContextFactory;
-use crate::webgl_thread::{WebGLExternalImageApi, WebGLExternalImageHandler, WebGLThread};
+use crate::webgl_thread::WebGLThread;
use canvas_traits::webgl::webgl_channel;
use canvas_traits::webgl::DOMToTextureCommand;
use canvas_traits::webgl::{WebGLChan, WebGLContextId, WebGLMsg, WebGLPipeline, WebGLReceiver};
@@ -13,6 +13,7 @@ use fnv::FnvHashMap;
use gleam::gl;
use servo_config::pref;
use std::rc::Rc;
+use webrender_traits::WebrenderExternalImageApi;
/// WebGL Threading API entry point that lives in the constellation.
pub struct WebGLThreads(WebGLSender<WebGLMsg>);
@@ -26,7 +27,7 @@ impl WebGLThreads {
webvr_compositor: Option<Box<dyn WebVRRenderHandler>>,
) -> (
WebGLThreads,
- Box<dyn webrender::ExternalImageHandler>,
+ Box<dyn WebrenderExternalImageApi>,
Option<Box<dyn webrender::OutputImageHandler>>,
) {
// This implementation creates a single `WebGLThread` for all the pipelines.
@@ -43,8 +44,7 @@ impl WebGLThreads {
} else {
None
};
- let external =
- WebGLExternalImageHandler::new(WebGLExternalImages::new(webrender_gl, channel.clone()));
+ let external = WebGLExternalImages::new(webrender_gl, channel.clone());
(
WebGLThreads(channel),
Box::new(external),
@@ -87,12 +87,15 @@ impl WebGLExternalImages {
}
}
-impl WebGLExternalImageApi for WebGLExternalImages {
- fn lock(&mut self, ctx_id: WebGLContextId) -> (u32, Size2D<i32>) {
+impl WebrenderExternalImageApi for WebGLExternalImages {
+ fn lock(&mut self, id: u64) -> (u32, Size2D<i32>) {
// WebGL Thread has it's own GL command queue that we need to synchronize with the WR GL command queue.
// The WebGLMsg::Lock message inserts a fence in the WebGL command queue.
self.webgl_channel
- .send(WebGLMsg::Lock(ctx_id, self.lock_channel.0.clone()))
+ .send(WebGLMsg::Lock(
+ WebGLContextId(id as usize),
+ self.lock_channel.0.clone(),
+ ))
.unwrap();
let (image_id, size, gl_sync) = self.lock_channel.1.recv().unwrap();
// The next glWaitSync call is run on the WR thread and it's used to synchronize the two
@@ -103,8 +106,10 @@ impl WebGLExternalImageApi for WebGLExternalImages {
(image_id, size)
}
- fn unlock(&mut self, ctx_id: WebGLContextId) {
- self.webgl_channel.send(WebGLMsg::Unlock(ctx_id)).unwrap();
+ fn unlock(&mut self, id: u64) {
+ self.webgl_channel
+ .send(WebGLMsg::Unlock(WebGLContextId(id as usize)))
+ .unwrap();
}
}