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

@ -5,16 +5,14 @@
use dom_struct::dom_struct;
use euclid::Size2D;
use profile_traits::ipc;
use script_traits::ScriptMsg;
use style_traits::CSSPixel;
use webrender_api::units::DeviceIntSize;
use webrender_traits::CrossProcessCompositorMessage;
use crate::dom::bindings::codegen::Bindings::ScreenBinding::ScreenMethods;
use crate::dom::bindings::inheritance::Castable;
use crate::dom::bindings::num::Finite;
use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector};
use crate::dom::bindings::root::{Dom, DomRoot};
use crate::dom::globalscope::GlobalScope;
use crate::dom::window::Window;
#[dom_struct]
@ -39,9 +37,9 @@ impl Screen {
let (send, recv) =
ipc::channel::<DeviceIntSize>(self.global().time_profiler_chan().clone()).unwrap();
self.window
.upcast::<GlobalScope>()
.script_to_constellation_chan()
.send(ScriptMsg::GetScreenSize(send))
.compositor_api()
.sender()
.send(CrossProcessCompositorMessage::GetScreenSize(send))
.unwrap();
let dpr = self.window.device_pixel_ratio();
let screen = recv.recv().unwrap_or(Size2D::zero());
@ -52,9 +50,9 @@ impl Screen {
let (send, recv) =
ipc::channel::<DeviceIntSize>(self.global().time_profiler_chan().clone()).unwrap();
self.window
.upcast::<GlobalScope>()
.script_to_constellation_chan()
.send(ScriptMsg::GetScreenAvailSize(send))
.compositor_api()
.sender()
.send(CrossProcessCompositorMessage::GetAvailableScreenSize(send))
.unwrap();
let dpr = self.window.device_pixel_ratio();
let screen = recv.recv().unwrap_or(Size2D::zero());