Skip to main content

Player

Struct Player 

Source
pub struct Player<I = RenderedTexture> { /* private fields */ }
Expand description

Stateful real-time runner, holding the last picture its renderer drew: I is FrameRenderer::Image, a RenderedTexture on the GPU and an Arc<CpuImage> on the alpha2_render::CpuRenderer.

MissingFramePolicy::HoldPrevious is the default; a host that would rather show its own loading state than a stale frame selects MissingFramePolicy::Wait through Player::with_missing_frame_policy.

Implementations§

Source§

impl<I> Player<I>

Source

pub fn render_size( &self, project: &EngineProject, ) -> Result<RenderSize, EngineError>

The size frames of project render at: where a host prepares their captions.

§Errors

Returns an error when the quality profile cannot size the project.

Source

pub fn new(quality: QualityProfile) -> Result<Self, EngineError>

Creates a player with explicit runtime quality.

§Errors

Returns EngineError::InvalidQualityProfile for invalid controls.

Source

pub const fn with_prefetch_frames(self, frames: u32) -> Self

Sets how many future frame boundaries are included in prefetch requests. Values above 120 are clamped to keep one request bounded.

Source

pub const fn prefetch_frames(&self) -> u32

How many future frame boundaries prefetch requests include.

Source

pub const fn quality(&self) -> QualityProfile

Returns the active quality profile.

Source

pub const fn with_missing_frame_policy(self, policy: MissingFramePolicy) -> Self

Sets what Player::render_at returns while source frames are missing.

MissingFramePolicy::HoldPrevious repeats the last successful texture, which keeps real-time playback moving. MissingFramePolicy::Wait withholds it, so the host can render its own loading state instead of presenting a frame that belongs to another timestamp. The held frame is retained either way and is presented again as soon as a render succeeds.

Source

pub const fn missing_frame_policy(&self) -> MissingFramePolicy

Returns the policy used when source frames are unavailable.

Source

pub fn prefetch_needs( &self, project: &EngineProject, time: MediaTime, ) -> Result<Vec<FrameNeed>, EngineError>

Collects deduplicated decode requests for the current and future frames.

§Errors

Returns evaluation or timeline overflow errors.

Source

pub fn render_at<'a, R: FrameRenderer<Image = I> + ?Sized>( &'a mut self, project: &EngineProject, renderer: &R, frames: &dyn FrameProvider, time: MediaTime, ) -> Result<PlaybackFrame<'a, I>, EngineError>

Evaluates and attempts to present the host clock’s current frame.

When inputs are missing, the most recent successful texture is returned with repeated = true under MissingFramePolicy::HoldPrevious, and withheld under MissingFramePolicy::Wait. Before the first successful frame, texture is absent and the host can display its own loading state.

A frame whose output equals the texture last returned (the same render size, frame-graph cache key and renderer content epoch, with every source keyed) is not rendered: that texture is returned again with unchanged = true, and no GPU work is encoded. A frame drawn from a source without a stable key always renders.

§Errors

Returns timeline evaluation, quality, or rendering failures, and EngineError::UnregisteredEffect naming an effect the frame draws that renderer has not registered.

Source

pub fn reset(&mut self)

Drops the held frame, for example after a seek or project swap.

Trait Implementations§

Source§

impl<I: Debug> Debug for Player<I>

Source§

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

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

impl<I> Default for Player<I>

Source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl<I> Freeze for Player<I>
where Option<(MediaTime, I)>: Freeze,

§

impl<I> RefUnwindSafe for Player<I>

§

impl<I> Send for Player<I>
where Option<(MediaTime, I)>: Send,

§

impl<I> Sync for Player<I>
where Option<(MediaTime, I)>: Sync,

§

impl<I> Unpin for Player<I>
where Option<(MediaTime, I)>: Unpin,

§

impl<I> UnsafeUnpin for Player<I>

§

impl<I> UnwindSafe for Player<I>

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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 = !

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

fn try_from(value: U) -> Result<T, !>

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,