compositor: Create a single cross-process compositor API (#33619) (#33660)

Instead of exposing many different kinds of messages to the compositor
that are routed through the constellation, expose a single message type
which can be sent across IPC channels. In addition, this IPC channel and
the route to the crossbeam channel with the compositor is created along
with the `CompositorProxy`, simplifying what needs to be passed around
during pipeline initialization.

Previously, some image updates (from video) were sent over IPC with a
special serialization routine and some were sent via crossbeam channels
(canvas). Now all updates go over the IPC channel `IpcSharedMemory` is
used to avoid serialization penalties. This should improve performance
and reduce copies for video, but add a memory copy overhead for canvas.
This will improve in the future when canvas renders directly into a
texture.

All-in-all this is a simplification which opens the path toward having a
standard compositor API and reduces the number of duplicate messages and
proxying that had to happen in libservo.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
Martin Robinson 2024-10-09 10:30:24 -07:00 committed by GitHub
parent 30cbf01280
commit 9195344b75
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
28 changed files with 547 additions and 800 deletions

View file

@ -95,7 +95,7 @@ use style::thread_state::{self, ThreadState};
use url::Position;
use webgpu::{WebGPUDevice, WebGPUMsg};
use webrender_api::DocumentId;
use webrender_traits::WebRenderScriptApi;
use webrender_traits::CrossProcessCompositorApi;
use crate::document_loader::DocumentLoader;
use crate::dom::bindings::cell::DomRefCell;
@ -669,9 +669,9 @@ pub struct ScriptThread {
#[no_trace]
webrender_document: DocumentId,
/// Webrender API sender.
/// Cross-process access to the compositor's API.
#[no_trace]
webrender_api_sender: WebRenderScriptApi,
compositor_api: CrossProcessCompositorApi,
/// Periodically print out on which events script threads spend their processing time.
profile_script_events: bool,
@ -1399,7 +1399,7 @@ impl ScriptThread {
custom_element_reaction_stack: CustomElementReactionStack::new(),
webrender_document: state.webrender_document,
webrender_api_sender: state.webrender_api_sender,
compositor_api: state.compositor_api,
profile_script_events: opts.debug.profile_script_events,
print_pwm: opts.print_pwm,
@ -3661,7 +3661,7 @@ impl ScriptThread {
system_font_service: self.system_font_service.clone(),
resource_threads: self.resource_threads.clone(),
time_profiler_chan: self.time_profiler_chan.clone(),
webrender_api_sender: self.webrender_api_sender.clone(),
compositor_api: self.compositor_api.clone(),
paint_time_metrics,
window_size: incomplete.window_size,
};
@ -3692,7 +3692,7 @@ impl ScriptThread {
self.webxr_registry.clone(),
self.microtask_queue.clone(),
self.webrender_document,
self.webrender_api_sender.clone(),
self.compositor_api.clone(),
self.relayout_event,
self.prepare_for_screenshot,
self.unminify_js,