pub trait VsyncPacer: Send {
// Required methods
fn set_active(&mut self, active: bool);
fn is_active(&self) -> bool;
// Provided methods
fn on_tick_received(&self) { ... }
fn nominal_interval_us(&self) -> Option<u32> { ... }
fn next_deadline_us(
&self,
_last_frame_us: Option<u64>,
_now_us: u64,
) -> Option<u64> { ... }
}Expand description
Platform-pluggable vsync / frame pacing strategy.
Push-driven native pacers (CADisplayLink, CVDisplayLink, DwmFlush, browser
requestAnimationFrame) return None from Self::next_deadline_us and deliver ticks via
their platform event loop / wake callback while Self::is_active is true.
Timer / poll pacers (such as TimerVsyncPacer) return Some(deadline_us) from
Self::next_deadline_us while active so the event loop can sleep until the next frame
boundary (ControlFlow::WaitUntil) with 0% idle CPU.
Required Methods§
Sourcefn set_active(&mut self, active: bool)
fn set_active(&mut self, active: bool)
Starts (true) or pauses (false) frame delivery. Idle pacers MUST consume 0% CPU.
Provided Methods§
Sourcefn on_tick_received(&self)
fn on_tick_received(&self)
Acknowledges receipt of a delivered vsync tick so push-driven pacers can clear their coalescing latch and emit the next frame tick.
Sourcefn nominal_interval_us(&self) -> Option<u32>
fn nominal_interval_us(&self) -> Option<u32>
Nominal frame interval in microseconds if known (e.g. 8_333 for 120 Hz ProMotion).
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".