Skip to main content

LayerCache

Struct LayerCache 

Source
pub struct LayerCache<T> { /* private fields */ }
Expand description

As camadas guardadas de um renderizador (Canvas::begin_cached), pela chave completa (a do núcleo com o tamanho e a escala em pixels). Cada uma lembra a chave que o núcleo passou (owner), para o núcleo soltar a de um controle quando ela deixa de valer (forget). Passando de ImageCacheLimits::layers_mb, sai a usada há mais tempo; uma camada maior que o limite inteiro nem é montada (accepts).

Implementations§

Source§

impl<T> LayerCache<T>

Source

pub fn named(name: &'static str) -> Self

Um cache que aparece no painel de memória (stats) com este nome.

Source

pub fn accepts(bytes: usize) -> bool

Se vale montar uma camada de bytes: com o limite em zero, ou menor que ela, não (quem chama desenha direto, sem a imagem fora da tela).

Source

pub fn get(&mut self, key: u64) -> Option<&T>

A camada pela chave completa, marcada como usada agora. Se o limite baixou em execução (o layers_mb do RenderSettings), o excedente sai aqui, as usadas há mais tempo primeiro (a pedida também, se não couber: quem chama desenha de novo).

Source

pub fn insert(&mut self, owner: u64, key: u64, value: T, bytes: usize)

Guarda a camada; passando do limite, tira as usadas há mais tempo (nunca a que entrou).

Source

pub fn forget(&mut self, owner: u64)

Solta as camadas montadas com a chave owner do núcleo (a camada deixou de valer: a transição acabou, o desenho de dentro mudou).

Source

pub fn clear(&mut self)

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source

pub fn bytes(&self) -> usize

A soma dos bytes guardados.

Trait Implementations§

Source§

impl<T> Default for LayerCache<T>

Source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl<T> Forget for LayerCache<T>

§

impl<T> Freeze for LayerCache<T>
where HashMap<u64, Layer<T>>: Freeze,

§

impl<T> Move for LayerCache<T>

§

impl<T> RefUnwindSafe for LayerCache<T>
where HashMap<u64, Layer<T>>: RefUnwindSafe,

§

impl<T> Send for LayerCache<T>
where HashMap<u64, Layer<T>>: Send,

§

impl<T> Sync for LayerCache<T>
where HashMap<u64, Layer<T>>: Sync,

§

impl<T> Unpin for LayerCache<T>
where HashMap<u64, Layer<T>>: Unpin,

§

impl<T> UnsafeUnpin for LayerCache<T>
where HashMap<u64, Layer<T>>: UnsafeUnpin,

§

impl<T> UnwindSafe for LayerCache<T>
where HashMap<u64, Layer<T>>: UnwindSafe,

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<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, 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.