FerroUI/ docs

Search guides, controls, Rust APIs, and XAML.

    GitHub ↗

    MediaContext

    struct · ferroui-base · v0.5.0

    struct MediaContext
    

    Coordinates the work that has to happen once per frame on the UI thread: the animation clock, layout passes and other callbacks that must run right before rendering, and the commit of the compositors.

    View source

    Members

    instance

    fn instance() -> Rc<MediaContext>
    

    The media context of the application.

    It is registered in the service locator and created on first use, so a locator scope (a unit test) gets a fresh one.

    Source

    is_render_scheduled

    fn is_render_scheduled(self: &Self) -> bool
    

    Whether a render pass has been requested and not yet run.

    Source

    render

    fn render(self: &Self)
    

    Runs a render pass: pulses the animation clock, fires the queued pre-render callbacks and commits the compositors.

    Source

    is_top_level_active

    fn is_top_level_active(self: &Self, key: usize) -> bool
    

    Whether a top-level is registered (for unit tests).

    Source

    remove_top_level

    fn remove_top_level(self: &Self, key: usize)
    

    Unregisters a top-level and stops its renderer.

    Source

    begin_invoke_on_render

    fn begin_invoke_on_render(self: &Self, callback: Rc<dyn Fn() -> ()>)
    

    Queues a callback to run before the next render.

    Source

    clock

    fn clock(self: &Self) -> Rc<dyn IGlobalClock>
    

    The global animation clock: what the application registers as the dyn IGlobalClock service, so that every animation without an explicit clock is pulsed by the render passes of this context.

    Source

    media_context_clock

    fn media_context_clock(self: &Self) -> &Rc<MediaContextClock>
    

    The global animation clock, as its concrete type.

    Source

    request_animation_frame

    fn request_animation_frame(self: &Self, action: impl FnOnce(SignedDuration) -> () + 'static)
    

    Runs action with the frame time on the next pulse of the animation clock.

    Source

    has_composition_batches_in_flight

    fn has_composition_batches_in_flight(self: &Self) -> bool
    

    Whether a committed composition batch has not been accepted by its server compositor yet: while one is, the render passes hold the next commits back. Not in upstream: the session of the headless platform asks it between two tests of a shared application.

    Source

    immediate_render_requested

    fn immediate_render_requested(self: &Self, compositor: &Rc<Compositor>)
    

    Commits the compositor of a composition target right away and renders it.

    Source

    commit_and_request_frame

    fn commit_and_request_frame(self: &Self, compositor: &Rc<Compositor>)
    

    Commits the compositor of a composition target right away and asks its render loop for a frame out of turn, without waiting for the frame. Not from upstream: for a platform whose frames are rendered by another thread and shown asynchronously (the render worker of the browser), where waiting would block this thread without the frame being shown any sooner.

    Source

    Trait implementations

    • Send
    • Sync
    • Freeze
    • UnsafeUnpin
    • Unpin
    • UnwindSafe
    • RefUnwindSafe
    • ClassDefaults
    • Borrow<T>
    • BorrowMut<T>
    • Into<U>
    • From<T>
    • TryInto<U>
    • TryFrom<U>
    • Any
    • ErasedDestructor
    • IntoEither
    • ICompositorScheduler

    Availability

    Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.