Skip to main content

ImageCache

Struct ImageCache 

Source
pub struct ImageCache { /* private fields */ }

Implementations§

Source§

impl ImageCache

Source

pub fn new() -> Self

Source

pub fn drop_changed(&mut self) -> usize

Reads again the images whose files changed since they were read (a sheet rebuilt, a frame re-rendered in place): their old copies are dropped and they decode anew, as on first use. Returns how many; costs a stat each.

Source

pub fn set_base_dir(&mut self, dir: &Path)

Source

pub fn set_device(&mut self, device: &Device)

Decode into buffers device reads (sparing the render thread the upload copy).

Source

pub fn prefetch(&mut self, src: &str)

Starts decoding src ahead of need (a sequence’s coming frames).

Source

pub fn request(&mut self, src: &str)

Starts decoding src if it is not known yet; an exact render waits for it.

Source

pub fn poll(&mut self, device: &Device, block: bool) -> Vec<(String, Texture)>

Advances loading images. Newly decoded images are uploaded (counted as uploads); the returned textures still need the working-space pass, which the caller encodes and then reports with mark_ready.

Source

pub fn mark_ready(&mut self, src: &str, tex: Texture)

Source

pub fn get(&mut self, src: &str) -> Option<&ImageState>

Source

pub fn end_frame(&mut self)

Advances the LRU clock and evicts the least recently used ready images beyond the cap (never ones used in the last few frames, which in-flight GPU work may still read).

Source

pub fn is_known(&self, src: &str) -> bool

Whether src is loading, loaded or failed (not dropped or never asked for).

Source

pub fn ready(&self, src: &str) -> Option<&Texture>

Source

pub fn bytes(&self) -> u64

GPU bytes of the images held.

Source

pub fn loading(&self) -> usize

Trait Implementations§

Source§

impl Default for ImageCache

Source§

fn default() -> Self

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

Auto Trait Implementations§

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> 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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.