Skip to main content

GlyphAtlas

Struct GlyphAtlas 

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

Implementations§

Source§

impl GlyphAtlas

Source

pub fn new(width: u32, height: u32) -> Self

Source

pub fn id(&self) -> u64

Unique identity for this atlas instance.

Glyph UVs are only meaningful for the atlas that produced them; caches must compare this id before reusing shaped output across text systems.

Source

pub fn size(&self) -> (u32, u32)

Source

pub fn version(&self) -> u64

Source

pub fn epoch(&self) -> u64

Source

pub fn pixels(&self) -> &[u8] ⓘ

Source

pub fn bytes(&self) -> usize

Returns the number of bytes occupied by the atlas bitmap.

Source

pub fn compact(&mut self)

Drops the least recently used half of the atlas and repacks it.

Entries that were not looked up recently are evicted, the survivors are moved to the top of the bitmap, and the whole texture is marked dirty. Glyph UVs emitted before this call become stale, so callers that keep a render list across the call must repaint it (the renderer leaves this until after the frame has been uploaded).

Source

pub fn shrink_to_fit(&mut self)

Compacts the atlas and shrinks the bitmap to fit the survivors.

The texture never grows here; dimensions are rounded up to the next power of two and clamped to the current size, with a small floor so a single eviction does not immediately trigger another resize.

Source

pub fn take_dirty(&mut self) -> Option<AtlasDirty>

Source

pub fn copy_rect(&self, x: u32, y: u32, w: u32, h: u32, out: &mut Vec<u8>)

Source

pub fn entry(&self, key: &CacheKey) -> Option<AtlasEntry>

Source

pub fn sprite(&self, key: u64) -> Option<AtlasEntry>

Source

pub fn insert_sprite( &mut self, key: u64, w: u32, h: u32, alpha: &[u8], ) -> AtlasEntry

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.