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>
impl<I> Player<I>
Sourcepub fn render_size(
&self,
project: &EngineProject,
) -> Result<RenderSize, EngineError>
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.
Sourcepub fn new(quality: QualityProfile) -> Result<Self, EngineError>
pub fn new(quality: QualityProfile) -> Result<Self, EngineError>
Creates a player with explicit runtime quality.
§Errors
Returns EngineError::InvalidQualityProfile for invalid controls.
Sourcepub const fn with_prefetch_frames(self, frames: u32) -> Self
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.
Sourcepub const fn prefetch_frames(&self) -> u32
pub const fn prefetch_frames(&self) -> u32
How many future frame boundaries prefetch requests include.
Sourcepub const fn quality(&self) -> QualityProfile
pub const fn quality(&self) -> QualityProfile
Returns the active quality profile.
Sourcepub const fn with_missing_frame_policy(self, policy: MissingFramePolicy) -> Self
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.
Sourcepub const fn missing_frame_policy(&self) -> MissingFramePolicy
pub const fn missing_frame_policy(&self) -> MissingFramePolicy
Returns the policy used when source frames are unavailable.
Sourcepub fn prefetch_needs(
&self,
project: &EngineProject,
time: MediaTime,
) -> Result<Vec<FrameNeed>, EngineError>
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.
Sourcepub 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>
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.
Trait Implementations§
Auto Trait Implementations§
impl<I> Freeze for Player<I>
impl<I> RefUnwindSafe for Player<I>
impl<I> Send for Player<I>
impl<I> Sync for Player<I>
impl<I> Unpin for Player<I>
impl<I> UnsafeUnpin for Player<I>
impl<I> UnwindSafe for Player<I>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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