compositor: Add an initial RefreshDriver (#37169)

This adds a *very* basic implementation of the `RefreshDriver` concept
to the Servo renderer. The initial idea is that controls the frequency
of display during animations. It eliminates the "slowdown" workaround
for WPT tests and now Servo animations don't move faster than 120 FPS
(observed to be slower in practice).

This establishes a base change which will be used to implement
non-display-list-producing layouts in a followup change.

Fixes #3406. (though much more work remains)
Testing: Covered by existing WPT tests.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
Martin Robinson 2025-05-29 12:43:49 +02:00 committed by GitHub
parent 801ac9e22a
commit 9dc1391bef
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 292 additions and 69 deletions

View file

@ -11,7 +11,7 @@ use compositing_traits::rendering_context::RenderingContext;
use compositing_traits::{CompositorMsg, CompositorProxy};
use constellation_traits::EmbedderToConstellationMessage;
use crossbeam_channel::{Receiver, Sender};
use embedder_traits::ShutdownState;
use embedder_traits::{EventLoopWaker, ShutdownState};
use profile_traits::{mem, time};
use webrender::RenderApi;
use webrender_api::DocumentId;
@ -22,9 +22,10 @@ pub use crate::compositor::{IOCompositor, WebRenderDebugOption};
mod tracing;
mod compositor;
mod refresh_driver;
mod touch;
pub mod webview_manager;
pub mod webview_renderer;
mod webview_manager;
mod webview_renderer;
/// Data used to construct a compositor.
pub struct InitialCompositorState {
@ -49,4 +50,7 @@ pub struct InitialCompositorState {
pub webrender_gl: Rc<dyn gleam::gl::Gl>,
#[cfg(feature = "webxr")]
pub webxr_main_thread: webxr::MainThreadRegistry,
/// An [`EventLoopWaker`] used in order to wake up the embedder when it is
/// time to paint.
pub event_loop_waker: Box<dyn EventLoopWaker>,
}