mirror of
https://github.com/servo/servo.git
synced 2025-08-07 14:35:33 +01:00
compositor: Create a single cross-process compositor API (#33619)
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:
parent
986c3a38a3
commit
f2f5614ad6
28 changed files with 547 additions and 801 deletions
|
@ -108,8 +108,7 @@ use canvas_traits::canvas::{CanvasId, CanvasMsg};
|
|||
use canvas_traits::webgl::WebGLThreads;
|
||||
use canvas_traits::ConstellationCanvasMsg;
|
||||
use compositing_traits::{
|
||||
CompositorMsg, CompositorProxy, ConstellationMsg as FromCompositorMsg,
|
||||
ForwardedToCompositorMsg, SendableFrameTree,
|
||||
CompositorMsg, CompositorProxy, ConstellationMsg as FromCompositorMsg, SendableFrameTree,
|
||||
};
|
||||
use crossbeam_channel::{after, never, select, unbounded, Receiver, Sender};
|
||||
use devtools_traits::{
|
||||
|
@ -157,7 +156,7 @@ use webgpu::swapchain::WGPUImageMap;
|
|||
use webgpu::{self, WebGPU, WebGPURequest, WebGPUResponse};
|
||||
use webrender::{RenderApi, RenderApiSender};
|
||||
use webrender_api::DocumentId;
|
||||
use webrender_traits::{WebRenderNetApi, WebRenderScriptApi, WebrenderExternalImageRegistry};
|
||||
use webrender_traits::WebrenderExternalImageRegistry;
|
||||
|
||||
use crate::browsingcontext::{
|
||||
AllBrowsingContextsIterator, BrowsingContext, FullyActiveBrowsingContextsIterator,
|
||||
|
@ -392,14 +391,6 @@ pub struct Constellation<STF, SWF> {
|
|||
/// Webrender related objects required by WebGPU threads
|
||||
webrender_wgpu: WebrenderWGPU,
|
||||
|
||||
/// A channel for content processes to send messages that will
|
||||
/// be relayed to the WebRender thread.
|
||||
webrender_api_ipc_sender: WebRenderScriptApi,
|
||||
|
||||
/// A channel for content process image caches to send messages
|
||||
/// that will be relayed to the WebRender thread.
|
||||
webrender_image_api_sender: WebRenderNetApi,
|
||||
|
||||
/// A map of message-port Id to info.
|
||||
message_ports: HashMap<MessagePortId, MessagePortInfo>,
|
||||
|
||||
|
@ -506,7 +497,7 @@ pub struct InitialConstellationState {
|
|||
/// A channel through which messages can be sent to the embedder.
|
||||
pub embedder_proxy: EmbedderProxy,
|
||||
|
||||
/// A channel through which messages can be sent to the compositor.
|
||||
/// A channel through which messages can be sent to the compositor in-process.
|
||||
pub compositor_proxy: CompositorProxy,
|
||||
|
||||
/// A channel to the developer tools, if applicable.
|
||||
|
@ -705,35 +696,6 @@ where
|
|||
// Zero is reserved for the embedder.
|
||||
PipelineNamespace::install(PipelineNamespaceId(1));
|
||||
|
||||
let (webrender_ipc_sender, webrender_ipc_receiver) =
|
||||
ipc::channel().expect("ipc channel failure");
|
||||
let (webrender_image_ipc_sender, webrender_image_ipc_receiver) =
|
||||
ipc::channel().expect("ipc channel failure");
|
||||
|
||||
let compositor_proxy = state.compositor_proxy.clone();
|
||||
ROUTER.add_route(
|
||||
webrender_ipc_receiver.to_opaque(),
|
||||
Box::new(move |message| {
|
||||
compositor_proxy.send(CompositorMsg::Forwarded(
|
||||
ForwardedToCompositorMsg::Layout(
|
||||
message.to().expect("conversion failure"),
|
||||
),
|
||||
));
|
||||
}),
|
||||
);
|
||||
|
||||
let compositor_proxy = state.compositor_proxy.clone();
|
||||
ROUTER.add_route(
|
||||
webrender_image_ipc_receiver.to_opaque(),
|
||||
Box::new(move |message| {
|
||||
compositor_proxy.send(CompositorMsg::Forwarded(
|
||||
ForwardedToCompositorMsg::Net(
|
||||
message.to().expect("conversion failure"),
|
||||
),
|
||||
));
|
||||
}),
|
||||
);
|
||||
|
||||
let webrender_wgpu = WebrenderWGPU {
|
||||
webrender_api: state.webrender_api_sender.create_api(),
|
||||
webrender_external_images: state.webrender_external_images,
|
||||
|
@ -788,8 +750,6 @@ where
|
|||
scheduler_receiver,
|
||||
document_states: HashMap::new(),
|
||||
webrender_document: state.webrender_document,
|
||||
webrender_api_ipc_sender: WebRenderScriptApi::new(webrender_ipc_sender),
|
||||
webrender_image_api_sender: WebRenderNetApi::new(webrender_image_ipc_sender),
|
||||
webrender_wgpu,
|
||||
shutting_down: false,
|
||||
handled_warnings: VecDeque::new(),
|
||||
|
@ -1053,8 +1013,6 @@ where
|
|||
event_loop,
|
||||
load_data,
|
||||
prev_throttled: throttled,
|
||||
webrender_api_sender: self.webrender_api_ipc_sender.clone(),
|
||||
webrender_image_api_sender: self.webrender_image_api_sender.clone(),
|
||||
webrender_document: self.webrender_document,
|
||||
webgl_chan: self
|
||||
.webgl_threads
|
||||
|
@ -1751,18 +1709,6 @@ where
|
|||
|
||||
response_sender.send(true).unwrap_or_default();
|
||||
},
|
||||
FromScriptMsg::GetClientWindow(response_sender) => {
|
||||
self.compositor_proxy
|
||||
.send(CompositorMsg::GetClientWindow(response_sender));
|
||||
},
|
||||
FromScriptMsg::GetScreenSize(response_sender) => {
|
||||
self.compositor_proxy
|
||||
.send(CompositorMsg::GetScreenSize(response_sender));
|
||||
},
|
||||
FromScriptMsg::GetScreenAvailSize(response_sender) => {
|
||||
self.compositor_proxy
|
||||
.send(CompositorMsg::GetScreenAvailSize(response_sender));
|
||||
},
|
||||
FromScriptMsg::LogEntry(thread_name, entry) => {
|
||||
self.handle_log_entry(Some(source_top_ctx_id), thread_name, entry);
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue