mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Improve decisions in compositor over when to draw a frame.
This patch fixes a couple of issues in the compositor: 1) Remove the delayed composition code. Previously, this would schedule a composite for 12ms in the future. This doesn't really make any sense with WR. There's no point in doing a composite unless WR has provided a new frame to be drawn. This fixes issues in several benchmarks where we were doing multiple composite / renders per rAF, which is a waste of CPU time. This *does* make the framerate slower in some cases (such as a slow rAF callback) but it's more correct - otherwise we were just compositing the same frame multiple times for no real benefit. 2) Inform the window of the current animation state of the compositor. Specifically, if an animation (or rAF) is currently active, the window system switches to use event polling, and does not block on the OS-level event loop. In the case of active animation, we just assume that we want to be running as the vsync interval and not blocking. This means the compositor thread only sleeps on vsync during animation, which reduces OS scheduling and results in much smoother animation.
This commit is contained in:
parent
5f10a25ead
commit
c8255922a9
6 changed files with 32 additions and 154 deletions
|
@ -102,6 +102,12 @@ impl Debug for WindowEvent {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone, PartialEq)]
|
||||
pub enum AnimationState {
|
||||
Idle,
|
||||
Animating,
|
||||
}
|
||||
|
||||
pub trait WindowMethods {
|
||||
/// Returns the rendering area size in hardware pixels.
|
||||
fn framebuffer_size(&self) -> TypedSize2D<u32, DevicePixel>;
|
||||
|
@ -163,4 +169,10 @@ pub trait WindowMethods {
|
|||
|
||||
/// Return the GL function pointer trait.
|
||||
fn gl(&self) -> Rc<gl::Gl>;
|
||||
|
||||
/// Set whether the application is currently animating.
|
||||
/// Typically, when animations are active, the window
|
||||
/// will want to avoid blocking on UI events, and just
|
||||
/// run the event loop at the vsync interval.
|
||||
fn set_animation_state(&self, _state: AnimationState) {}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue