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.
Members
instanceis_render_scheduledrenderis_top_level_activeremove_top_levelbegin_invoke_on_renderclockmedia_context_clockrequest_animation_framehas_composition_batches_in_flightimmediate_render_requestedcommit_and_request_frame
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.
is_render_scheduled
fn is_render_scheduled(self: &Self) -> bool
Whether a render pass has been requested and not yet run.
render
fn render(self: &Self)
Runs a render pass: pulses the animation clock, fires the queued pre-render callbacks and commits the compositors.
is_top_level_active
fn is_top_level_active(self: &Self, key: usize) -> bool
Whether a top-level is registered (for unit tests).
remove_top_level
fn remove_top_level(self: &Self, key: usize)
Unregisters a top-level and stops its renderer.
begin_invoke_on_render
fn begin_invoke_on_render(self: &Self, callback: Rc<dyn Fn() -> ()>)
Queues a callback to run before the next render.
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.
media_context_clock
fn media_context_clock(self: &Self) -> &Rc<MediaContextClock>
The global animation clock, as its concrete type.
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.
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.
immediate_render_requested
fn immediate_render_requested(self: &Self, compositor: &Rc<Compositor>)
Commits the compositor of a composition target right away and renders it.
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.
Trait implementations
SendSyncFreezeUnsafeUnpinUnpinUnwindSafeRefUnwindSafeClassDefaultsBorrow<T>BorrowMut<T>Into<U>From<T>TryInto<U>TryFrom<U>AnyErasedDestructorIntoEitherICompositorScheduler
Availability
Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.