compositor: Improve the way we wait for frames (#31523)

* compositor: Improve the way we wait for frames

In the newest version of WebRender it will be harder to make the
distinction between frame queued for scrolling and other kinds of
pending frames. This change makes it so that we queue frames for both
kinds of changes the same way and keeps a counting of pending frames.
This is conceptually a lot simpler.

In addition, do queue a composite even when recomposite isn't necessary
for a WebRender frame when there are active requestAnimationFrame
callbacks. Doing a composite is what triggers the callbacks to actually
run in the script thread! I believe this was a bug, but the WebRender
upgrade made it much more obvious.

These changes are in preparation for the WebRender upgrade.

* Remove spurious println
This commit is contained in:
Martin Robinson 2024-03-07 12:59:02 +01:00 committed by GitHub
parent 3098c3d121
commit 6005049d88
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 74 additions and 98 deletions

View file

@ -33,8 +33,8 @@ use canvas_traits::webgl::WebGLThreads;
use compositing::windowing::{EmbedderEvent, EmbedderMethods, WindowMethods};
use compositing::{CompositeTarget, IOCompositor, InitialCompositorState, ShutdownState};
use compositing_traits::{
CanvasToCompositorMsg, CompositingReason, CompositorMsg, CompositorProxy, CompositorReceiver,
ConstellationMsg, FontToCompositorMsg, ForwardedToCompositorMsg,
CanvasToCompositorMsg, CompositorMsg, CompositorProxy, CompositorReceiver, ConstellationMsg,
FontToCompositorMsg, ForwardedToCompositorMsg,
};
#[cfg(all(
not(target_os = "windows"),
@ -198,26 +198,17 @@ impl webrender_api::RenderNotifier for RenderNotifier {
Box::new(RenderNotifier::new(self.compositor_proxy.clone()))
}
fn wake_up(&self, composite_needed: bool) {
if composite_needed {
self.compositor_proxy
.recomposite(CompositingReason::NewWebRenderFrame);
}
}
fn wake_up(&self, _composite_needed: bool) {}
fn new_frame_ready(
&self,
_document_id: DocumentId,
scrolled: bool,
_scrolled: bool,
composite_needed: bool,
_render_time_ns: Option<u64>,
) {
if scrolled {
self.compositor_proxy
.send(CompositorMsg::NewScrollFrameReady(composite_needed));
} else {
self.wake_up(true);
}
self.compositor_proxy
.send(CompositorMsg::NewWebRenderFrameReady(composite_needed));
}
}