mirror of
https://github.com/servo/servo.git
synced 2025-07-21 22:33:41 +01:00
Auto merge of #23758 - jdm:compositing-canvas-break, r=gterzian
Remove canvas->compositing dependency There's one tiny place in the canvas crate that depends on the compositing crate, and it's really quite backwards. If we use trait objects instead it becomes much cleaner to reason about. --- - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes do not require tests because no tests for windows-only webgl code. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/23758) <!-- Reviewable:end -->
This commit is contained in:
commit
812bf8d816
5 changed files with 52 additions and 42 deletions
|
@ -64,7 +64,7 @@ fn webdriver(_port: u16, _constellation: Sender<ConstellationMsg>) {}
|
|||
|
||||
use bluetooth::BluetoothThreadFactory;
|
||||
use bluetooth_traits::BluetoothRequest;
|
||||
use canvas::gl_context::GLContextFactory;
|
||||
use canvas::gl_context::{CloneableDispatcher, GLContextFactory};
|
||||
use canvas::webgl_thread::WebGLThreads;
|
||||
use compositing::compositor_thread::{
|
||||
CompositorProxy, CompositorReceiver, InitialCompositorState, Msg,
|
||||
|
@ -100,6 +100,7 @@ use media::{GLPlayerThreads, WindowGLContext};
|
|||
use msg::constellation_msg::{PipelineNamespace, PipelineNamespaceId};
|
||||
use net::resource_thread::new_resource_threads;
|
||||
use net_traits::IpcSend;
|
||||
use offscreen_gl_context::GLContextDispatcher;
|
||||
use profile::mem as profile_mem;
|
||||
use profile::time as profile_time;
|
||||
use profile_traits::mem;
|
||||
|
@ -745,7 +746,8 @@ fn create_constellation(
|
|||
let gl_factory = if opts.should_use_osmesa() {
|
||||
GLContextFactory::current_osmesa_handle()
|
||||
} else {
|
||||
GLContextFactory::current_native_handle(&compositor_proxy)
|
||||
let dispatcher = Box::new(MainThreadDispatcher::new(compositor_proxy.clone())) as Box<_>;
|
||||
GLContextFactory::current_native_handle(dispatcher)
|
||||
};
|
||||
|
||||
let (external_image_handlers, external_images) = WebrenderExternalImageHandlers::new();
|
||||
|
@ -937,3 +939,29 @@ fn create_sandbox() {
|
|||
fn create_sandbox() {
|
||||
panic!("Sandboxing is not supported on Windows, iOS, ARM targets and android.");
|
||||
}
|
||||
|
||||
/// Implements GLContextDispatcher to dispatch functions from GLContext threads to the main thread's event loop.
|
||||
/// It's used in Windows to allow WGL GLContext sharing.
|
||||
pub struct MainThreadDispatcher {
|
||||
compositor_proxy: CompositorProxy,
|
||||
}
|
||||
|
||||
impl MainThreadDispatcher {
|
||||
fn new(proxy: CompositorProxy) -> Self {
|
||||
Self {
|
||||
compositor_proxy: proxy,
|
||||
}
|
||||
}
|
||||
}
|
||||
impl GLContextDispatcher for MainThreadDispatcher {
|
||||
fn dispatch(&self, f: Box<dyn Fn() + Send>) {
|
||||
self.compositor_proxy.send(Msg::Dispatch(f));
|
||||
}
|
||||
}
|
||||
impl CloneableDispatcher for MainThreadDispatcher {
|
||||
fn clone(&self) -> Box<dyn GLContextDispatcher> {
|
||||
Box::new(MainThreadDispatcher {
|
||||
compositor_proxy: self.compositor_proxy.clone(),
|
||||
}) as Box<_>
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue