diff options
author | Manish Goregaokar <manishsmail@gmail.com> | 2019-07-10 23:36:21 -0700 |
---|---|---|
committer | Manish Goregaokar <manishsmail@gmail.com> | 2019-07-11 11:12:59 -0700 |
commit | c5a0fc56ea5260a7dcd811abc76d2f51e2ad2fb6 (patch) | |
tree | f55e74b88f4465778016f62d3026448641ae0701 /components/canvas/webgl_thread.rs | |
parent | 036b495cb253f668e88c11813f750b0e537a32bd (diff) | |
download | servo-c5a0fc56ea5260a7dcd811abc76d2f51e2ad2fb6.tar.gz servo-c5a0fc56ea5260a7dcd811abc76d2f51e2ad2fb6.zip |
Use separate IPC-only locking mechanism when locking from webxr
Diffstat (limited to 'components/canvas/webgl_thread.rs')
-rw-r--r-- | components/canvas/webgl_thread.rs | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/components/canvas/webgl_thread.rs b/components/canvas/webgl_thread.rs index 4b2e59dd216..954db9bafc2 100644 --- a/components/canvas/webgl_thread.rs +++ b/components/canvas/webgl_thread.rs @@ -9,6 +9,7 @@ use euclid::Size2D; use fnv::FnvHashMap; use gleam::gl; use half::f16; +use ipc_channel::ipc::IpcSender; use offscreen_gl_context::{DrawBuffer, GLContext, NativeGLContextMethods}; use pixels::{self, PixelFormat}; use std::borrow::Cow; @@ -181,6 +182,9 @@ impl<VR: WebVRRenderHandler + 'static> WebGLThread<VR> { WebGLMsg::Lock(ctx_id, sender) => { self.handle_lock(ctx_id, sender); }, + WebGLMsg::LockIPC(ctx_id, sender) => { + self.handle_lock_ipc(ctx_id, sender); + }, WebGLMsg::Unlock(ctx_id) => { self.handle_unlock(ctx_id); }, @@ -231,13 +235,27 @@ impl<VR: WebVRRenderHandler + 'static> WebGLThread<VR> { ); } } - /// Handles a lock external callback received from webrender::ExternalImageHandler fn handle_lock( &mut self, context_id: WebGLContextId, sender: WebGLSender<(u32, Size2D<i32>, usize)>, ) { + sender.send(self.handle_lock_inner(context_id)).unwrap(); + } + + /// handle_lock, but unconditionally IPC (used by webxr) + fn handle_lock_ipc( + &mut self, + context_id: WebGLContextId, + sender: IpcSender<(u32, Size2D<i32>, usize)>, + ) { + sender.send(self.handle_lock_inner(context_id)).unwrap(); + } + + /// Shared code between handle_lock and handle_lock_ipc, does the actual syncing/flushing + /// but the caller must send the response back + fn handle_lock_inner(&mut self, context_id: WebGLContextId) -> (u32, Size2D<i32>, usize) { let data = Self::make_current_if_needed(context_id, &self.contexts, &mut self.bound_context_id) .expect("WebGLContext not found in a WebGLMsg::Lock message"); @@ -251,9 +269,7 @@ impl<VR: WebVRRenderHandler + 'static> WebGLThread<VR> { // Without proper flushing, the sync object may never be signaled. data.ctx.gl().flush(); - sender - .send((info.texture_id, info.size, gl_sync as usize)) - .unwrap(); + (info.texture_id, info.size, gl_sync as usize) } /// Handles an unlock external callback received from webrender::ExternalImageHandler |