struct Pool {
gl: Option<Arc<Context>>,
free: Vec<Target>,
live: usize,
}Expand description
Size-keyed target pool. GL objects are created by the renderer when take finds nothing reusable
and deleted here when the free list outgrows its budget. Ping-pong falls out of it: composite
takes a second canvas-sized target, draws into it and returns the old canvas here, so the two keep
swapping.
Fields§
§gl: Option<Arc<Context>>The context, so put can actually free what it evicts. None in the pure-bookkeeping tests.
free: Vec<Target>§live: usizeTargets handed out and not yet returned.
Implementations§
Source§impl Pool
impl Pool
Sourceconst MAX_FREE_PX: usize = 67_108_864usize
const MAX_FREE_PX: usize = 67_108_864usize
How many RGBA8 pixels the free list may hold (~256 MB: 8 × 4K, 30 × 1080p). Without a cap a preview resize walks through one target per pixel width and never frees any of them.
Sourcefn take(&mut self, w: u32, h: u32) -> Option<Target>
fn take(&mut self, w: u32, h: u32) -> Option<Target>
A free target of exactly this size, if there is one (callers create one otherwise).
fn put(&mut self, t: Target)
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Pool
impl RefUnwindSafe for Pool
impl Send for Pool
impl Sync for Pool
impl Unpin for Pool
impl UnwindSafe for Pool
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
Mutably borrows from an owned value. Read more
§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
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 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>
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