pub struct PaintPacer { /* private fields */ }Expand description
Shared, mutable editor scale factor.
Single source of truth for the live content-scale of an open plugin
window. Each GUI backend (egui / iced / slint) constructs one in
Editor::open, stores it on the editor for set_scale_factor to
write through, and hands a clone to its baseview WindowHandler so
the render thread can pick up changes between frames.
Two writers, one reader-per-frame:
Editor::set_scale_factor(host → editor, e.g. CLAPset_scale, VST3 WindowsIPlugViewContentScaleSupport).WindowEvent::Resized(baseview → handler, fired when the OS reports a new content scale, e.g. dragging the window across monitors with different DPIs).
Most-recent-write wins. The handler tracks a last_applied_scale
alongside its EditorScale clone and, when it observes a divergence
at frame start, recomputes physical sizes and reconfigures its
surface / renderer.
Paces editor paints to the compositor’s measured consumption rate.
A child-window swapchain acquire (get_current_texture) blocks
until the compositor frees a frame slot, and a host may compose an
embedded editor window far below the editor’s tick rate (REAPER on
Windows composes FX child windows at ~13 Hz). Painting every tick
then parks the host’s GUI thread in that wait - measured at 74 ms
of every 77 ms frame, which saturates the host’s whole UI and reads
as the DAW hanging. Editors feed each paint’s measured acquire wait
into Self::record_acquire and skip the tick while
Self::should_hold is true, converging on the rate the
compositor actually displays (which is all the user ever saw).
The pace is a decayed maximum: a successfully paced paint measures a ~0 ms acquire, so pacing by the last wait alone oscillates (paced, unpaced, paced, …). Holding the estimate through the zeros and shrinking it ~15% per paint lets it track a compositor that genuinely speeds up within roughly a second.
Implementations§
Source§impl PaintPacer
impl PaintPacer
Sourcepub fn should_hold(&self) -> bool
pub fn should_hold(&self) -> bool
Whether this tick’s paint should be skipped: the previous acquire showed the compositor hasn’t caught up yet.
Sourcepub fn record_acquire(&mut self, wait: Duration)
pub fn record_acquire(&mut self, wait: Duration)
Record how long a paint’s swapchain acquire blocked, scheduling the earliest next paint accordingly.