Skip to main content

Atlas

Struct Atlas 

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

简单的行式(Row-based)glyph atlas

  • 维护当前行 y 位置 + 行内 x 位置
  • 放不下当前行就换行(y += row_height, x = 0, row_height = 0)
  • 整个 atlas 满了就 panic(阶段 3 简化;后续 LRU/扩容)
  • dirty 标记:从上次 clear_dirty 起,是否有新像素写入

Implementations§

Source§

impl Atlas

Source

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

Source

pub fn get_or_insert( &mut self, key: GlyphKey, bitmap: &[u8], w: u32, h: u32, ) -> AtlasEntry

查询或插入一个 glyph

bitmap 是 R8 灰度数据,长度 = w * h

Source

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

整个 atlas 像素(用于上传到 GPU)

Source

pub fn glyph_count(&self) -> usize

已有 glyph 数量

Source

pub fn is_dirty(&self) -> bool

是否有新像素写入(自上次 clear_dirty 以来)

Source

pub fn clear_dirty(&mut self)

清 dirty 标记(GPU 已上传后调用)

Auto Trait Implementations§

§

impl Forget for Atlas

§

impl Freeze for Atlas

§

impl Move for Atlas

§

impl RefUnwindSafe for Atlas

§

impl Send for Atlas
where RawVecInner: Send, RawTable<(GlyphKey, AtlasEntry)>: Send,

§

impl Sync for Atlas
where RawVecInner: Sync, RawTable<(GlyphKey, AtlasEntry)>: Sync,

§

impl Unpin for Atlas
where *const u8 is !null: Unpin,

§

impl UnsafeUnpin for Atlas

§

impl UnwindSafe for Atlas

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> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> ErasedDestructor for T
where T: 'static,

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

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,