Compositor: add document id to NewWebRenderFrame variant (#33597)

* Add document id to NewWebRenderFrame variant

Signed-off-by: Wu Wayne <yuweiwu@pm.me>

* Match the arguments order

Signed-off-by: Wu Wayne <yuweiwu@pm.me>

---------

Signed-off-by: Wu Wayne <yuweiwu@pm.me>
This commit is contained in:
Ngo Iok Ui (Wu Yu Wei) 2024-10-02 16:34:15 +09:00 committed by GitHub
parent e534c7d461
commit 88dad77483
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 14 additions and 9 deletions

View file

@ -610,7 +610,7 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
let _ = sender.send(());
},
CompositorMsg::NewWebRenderFrameReady(recomposite_needed) => {
CompositorMsg::NewWebRenderFrameReady(_document_id, recomposite_needed) => {
self.pending_frames -= 1;
if recomposite_needed {
@ -991,7 +991,7 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
);
}
},
CompositorMsg::NewWebRenderFrameReady(_) => {
CompositorMsg::NewWebRenderFrameReady(..) => {
// Subtract from the number of pending frames, but do not do any compositing.
self.pending_frames -= 1;
},
@ -2378,12 +2378,12 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
let mut found_recomposite_msg = false;
while let Some(msg) = self.port.try_recv_compositor_msg() {
match msg {
CompositorMsg::NewWebRenderFrameReady(_) if found_recomposite_msg => {
CompositorMsg::NewWebRenderFrameReady(..) if found_recomposite_msg => {
// Only take one of duplicate NewWebRendeFrameReady messages, but do subtract
// one frame from the pending frames.
self.pending_frames -= 1;
},
CompositorMsg::NewWebRenderFrameReady(_) => {
CompositorMsg::NewWebRenderFrameReady(..) => {
found_recomposite_msg = true;
compositor_messages.push(msg)
},
@ -2437,7 +2437,7 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
pub fn repaint_synchronously(&mut self) {
while self.shutdown_state != ShutdownState::ShuttingDown {
let msg = self.port.recv_compositor_msg();
let need_recomposite = matches!(msg, CompositorMsg::NewWebRenderFrameReady(_));
let need_recomposite = matches!(msg, CompositorMsg::NewWebRenderFrameReady(..));
let keep_going = self.handle_browser_message(msg);
if need_recomposite {
self.composite();

View file

@ -206,13 +206,16 @@ impl webrender_api::RenderNotifier for RenderNotifier {
fn new_frame_ready(
&self,
_document_id: DocumentId,
document_id: DocumentId,
_scrolled: bool,
composite_needed: bool,
_frame_publish_id: FramePublishId,
) {
self.compositor_proxy
.send(CompositorMsg::NewWebRenderFrameReady(composite_needed));
.send(CompositorMsg::NewWebRenderFrameReady(
document_id,
composite_needed,
));
}
}

View file

@ -22,6 +22,7 @@ use script_traits::{
};
use style_traits::CSSPixel;
use webrender_api::units::{DeviceIntPoint, DeviceIntSize, DeviceRect};
use webrender_api::DocumentId;
use webrender_traits::{
CanvasToCompositorMsg, FontToCompositorMsg, NetToCompositorMsg, ScriptToCompositorMsg,
};
@ -93,8 +94,9 @@ pub enum CompositorMsg {
/// Set whether to use less resources by stopping animations.
SetThrottled(PipelineId, bool),
/// WebRender has produced a new frame. This message informs the compositor that
/// the frame is ready, so that it may trigger a recomposite.
NewWebRenderFrameReady(bool /* composite_needed */),
/// the frame is ready. It contains a bool to indicate if it needs to composite and the
/// `DocumentId` of the new frame.
NewWebRenderFrameReady(DocumentId, bool),
/// A pipeline was shut down.
// This message acts as a synchronization point between the constellation,
// when it shuts down a pipeline, to the compositor; when the compositor