Skip to main content

TextBindCache

Struct TextBindCache 

Source
pub struct TextBindCache { /* private fields */ }
Expand description

The text-overlay state one draw call would set that the previous call in the same pass already left bound. A heads-up display is overwhelmingly many labels sharing one atlas and one full-window scissor, so tracking the last value bound turns a per-label bind into a per-change bind.

The scissor is the canonical (x, y, w, h) in attachment pixels that clip_rect_to_scissor returns and every backend’s own rect type converts from, so one cache serves all three backends.

A cache starts empty rather than seeded with whatever the pass began with, so the first call of each kind always binds and the cache never has to assume what the surrounding pass left in place.

Both queries record as they answer, so a caller must ask only where it goes on to bind: asking and then skipping the bind desynchronises the cache from the recorder.

Implementations§

Source§

impl TextBindCache

Source

pub fn new() -> Self

An empty cache: the first query of each kind reports a change.

Source

pub fn atlas_changed(&mut self, idx: usize) -> bool

Whether the atlas at idx still needs binding, recording it as bound.

Source

pub fn scissor_changed(&mut self, rect: (i32, i32, u32, u32)) -> bool

Whether rect still needs setting as the scissor, recording it as set.

Trait Implementations§

Source§

impl Default for TextBindCache

Source§

fn default() -> TextBindCache

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