Skip to main content

PaintPacer

Struct PaintPacer 

Source
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. CLAP set_scale, VST3 Windows IPlugViewContentScaleSupport).
  • 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

Source

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.

Source

pub fn record_acquire(&mut self, wait: Duration)

Record how long a paint’s swapchain acquire blocked, scheduling the earliest next paint accordingly.

Trait Implementations§

Source§

impl Debug for PaintPacer

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for PaintPacer

Source§

fn default() -> PaintPacer

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,