зеркало из https://github.com/mozilla/gecko-dev.git
servo: Merge #13840 - WebGL support on Windows (from MortimerGoro:webrender_dispatcher); r=emilio
<!-- Please describe your changes on the following line: --> This is the final step to provide WebGL support on Windows ;) Some Related PRs already merged in webrender and offscreen-gl-context: https://github.com/emilio/rust-offscreen-rendering-context/pull/64 https://github.com/servo/webrender/pull/432 --- - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [ ] These changes fix #__ (github issue number if applicable). - [X] There are tests for these changes OR - [ ] These changes do not require tests because _____ Source-Repo: https://github.com/servo/servo Source-Revision: 4216224f9cc7f3430db2b59f4d77061824ba7a1e
This commit is contained in:
Родитель
98b2f1c431
Коммит
ff7bafc3a9
|
@ -354,6 +354,17 @@ impl webrender_traits::RenderNotifier for RenderNotifier {
|
|||
}
|
||||
}
|
||||
|
||||
// Used to dispatch functions from webrender to the main thread's event loop.
|
||||
struct CompositorThreadDispatcher {
|
||||
compositor_proxy: Box<CompositorProxy>
|
||||
}
|
||||
|
||||
impl webrender_traits::RenderDispatcher for CompositorThreadDispatcher {
|
||||
fn dispatch(&self, f: Box<Fn() + Send>) {
|
||||
self.compositor_proxy.send(Msg::Dispatch(f));
|
||||
}
|
||||
}
|
||||
|
||||
impl<Window: WindowMethods> IOCompositor<Window> {
|
||||
fn new(window: Rc<Window>, state: InitialCompositorState)
|
||||
-> IOCompositor<Window> {
|
||||
|
@ -426,6 +437,15 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
|||
compositor.constellation_chan.clone());
|
||||
compositor.webrender.set_render_notifier(Box::new(render_notifier));
|
||||
|
||||
if cfg!(target_os = "windows") {
|
||||
// Used to dispatch functions from webrender to the main thread's event loop.
|
||||
// Required to allow WGL GLContext sharing in Windows.
|
||||
let dispatcher = Box::new(CompositorThreadDispatcher {
|
||||
compositor_proxy: compositor.channel_to_self.clone_compositor_proxy()
|
||||
});
|
||||
compositor.webrender.set_main_thread_dispatcher(dispatcher);
|
||||
}
|
||||
|
||||
// Set the size of the root layer.
|
||||
compositor.update_zoom_transform();
|
||||
|
||||
|
@ -642,6 +662,12 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
|||
}
|
||||
}
|
||||
|
||||
(Msg::Dispatch(func), ShutdownState::NotShuttingDown) => {
|
||||
// The functions sent here right now are really dumb, so they can't panic.
|
||||
// But if we start running more complex code here, we should really catch panic here.
|
||||
func();
|
||||
}
|
||||
|
||||
// When we are shutting_down, we need to avoid performing operations
|
||||
// such as Paint that may crash because we have begun tearing down
|
||||
// the rest of our resources.
|
||||
|
|
|
@ -126,6 +126,10 @@ pub enum Msg {
|
|||
// sends a reply on the IpcSender, the constellation knows it's safe to
|
||||
// tear down the other threads associated with this pipeline.
|
||||
PipelineExited(PipelineId, IpcSender<()>),
|
||||
/// Runs a closure in the compositor thread.
|
||||
/// It's used to dispatch functions from webrender to the main thread's event loop.
|
||||
/// Required to allow WGL GLContext sharing in Windows.
|
||||
Dispatch(Box<Fn() + Send>)
|
||||
}
|
||||
|
||||
impl Debug for Msg {
|
||||
|
@ -158,6 +162,7 @@ impl Debug for Msg {
|
|||
Msg::PipelineVisibilityChanged(..) => write!(f, "PipelineVisibilityChanged"),
|
||||
Msg::PipelineExited(..) => write!(f, "PipelineExited"),
|
||||
Msg::NewScrollFrameReady(..) => write!(f, "NewScrollFrameReady"),
|
||||
Msg::Dispatch(..) => write!(f, "Dispatch"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче