pub struct RetainedPages<T = Texture, V = TextureView> { /* private fields */ }Expand description
The renderer’s retained pages: a budgeted, least-recently-used store keyed by the raw retained key (see the module doc).
Implementations§
Source§impl<T, V> RetainedPages<T, V>
impl<T, V> RetainedPages<T, V>
Sourcepub fn new(budget: RetainedBudget, max_dimension: u32) -> Self
pub fn new(budget: RetainedBudget, max_dimension: u32) -> Self
An empty store held to budget, with pages capped at max_dimension
per axis (and never above MAX_INTERMEDIATE_DIMENSION).
Sourcepub fn budget(&self) -> RetainedBudget
pub fn budget(&self) -> RetainedBudget
The budget the store is held to.
Sourcepub fn set_budget(&mut self, budget: RetainedBudget)
pub fn set_budget(&mut self, budget: RetainedBudget)
Re-budget the store, evicting least recently used pages until what it holds fits.
Sourcepub fn max_dimension(&self) -> u32
pub fn max_dimension(&self) -> u32
The largest page extent the store allocates, per axis.
Sourcepub fn used_bytes(&self) -> u64
pub fn used_bytes(&self) -> u64
The bytes of texture the resident pages hold.
Sourcepub fn generation(&self) -> u64
pub fn generation(&self) -> u64
A counter advanced whenever the set Self::entries reports changes —
a page added, evicted, re-rendered at another extent or scale, or the
store cleared. A caller publishing the ledger only when this moved
publishes every change and nothing else.
Sourcepub fn entries(&self) -> impl Iterator<Item = RetainedEntry> + '_
pub fn entries(&self) -> impl Iterator<Item = RetainedEntry> + '_
The resident pages, as the ledger reports them, in no particular order.
Sourcepub fn take_refusal(&mut self) -> bool
pub fn take_refusal(&mut self) -> bool
Whether a DrawRetained refusal cleared the store since the last call,
clearing the flag — what lets a host ask for one more frame to be
painted against the emptied ledger.
Sourcepub fn clear(&mut self)
pub fn clear(&mut self)
Drop every page.
What a surface recreate, a resize and a DrawRetained refusal all do:
the ledger the widget tree paints against goes empty with it, and every
body is painted (and, where admitted, recorded) again.
Sourcepub fn page_for(&self, bracket: u32) -> Option<(&V, (u32, u32))>
pub fn page_for(&self, bracket: u32) -> Option<(&V, (u32, u32))>
The view and texture extent of the page retained bracket bracket of
the last committed frame renders into or composites from.
Sourcepub fn plan(
&mut self,
brackets: &[RetainedBracket],
layers: &mut [RecordedLayer],
) -> Result<RetainedPlan, EngineError>
pub fn plan( &mut self, brackets: &[RetainedBracket], layers: &mut [RecordedLayer], ) -> Result<RetainedPlan, EngineError>
Decide one frame: which bodies render into a retained page, which
DrawRetaineds composite from one and where, and which pages make room
(see the module doc). Advances the frame clock; changes nothing else
unless it refuses.
layers is the frame’s recorded layers, for each body’s drawn bounds;
every layer enclosing a served draw has its bounds grown to hold the
draw’s composite (rounded out to tiles) before any body is sized.
§Errors
EngineError::RetainedKeyMissing for the first DrawRetained whose
key is not resident at its placement — and the store is cleared.
Sourcepub fn commit<A>(
&mut self,
allocator: &A,
brackets: &[RetainedBracket],
superseded: &[u64],
plan: &RetainedPlan,
rendered: &[bool],
)where
A: TextureAllocator<Texture = T, View = V>,
pub fn commit<A>(
&mut self,
allocator: &A,
brackets: &[RetainedBracket],
superseded: &[u64],
plan: &RetainedPlan,
rendered: &[bool],
)where
A: TextureAllocator<Texture = T, View = V>,
Apply plan, decided for brackets, once nothing about the frame can
fail any more: evict, then give every admitted body the schedule really
rendered (rendered, indexed like brackets) its page, then bind each
bracket to the page it uses this frame.
The evictions are the plan’s least-recently-used ones plus every key
the frame re-recorded without its page receiving that recording (see
the module doc’s A page holds this frame’s recording, or goes): a
body the plan refused, an admitted body the schedule did not render,
and every key in superseded — the PushRetained brackets the compiler
swallowed into an enclosing one
(CompiledFrame::retained_superseded).