Skip to main content

PlatformAtlas

Trait PlatformAtlas 

Source
pub trait PlatformAtlas {
    // Required methods
    fn get_or_insert_with<'a>(
        &self,
        key: AtlasKey,
        build: &mut dyn FnMut() -> Result<Option<(Size<DevicePixels>, Cow<'a, [u8]>)>>,
    ) -> Result<Option<AtlasTile>>;
    fn get_or_insert_glyph_with(
        &self,
        params: &RenderGlyphParams,
        build: &mut dyn FnMut() -> Result<ValidatedRasterizedGlyph>,
    ) -> Result<GlyphAtlasEntry>;
    fn remove(&self, key: &AtlasKey);

    // Provided method
    fn contains(&self, _key: &AtlasKey) -> bool { ... }
}
Expand description

A texture atlas that packs glyphs, SVGs and images into shared GPU textures.

Each window’s renderer owns one atlas. Methods that insert tiles build the pixels only on a cache miss, so callers don’t pay for rasterizing a tile they already have.

Required Methods§

Source

fn get_or_insert_with<'a>( &self, key: AtlasKey, build: &mut dyn FnMut() -> Result<Option<(Size<DevicePixels>, Cow<'a, [u8]>)>>, ) -> Result<Option<AtlasTile>>

Returns the tile for key, calling build on a cache miss to produce the pixels.

build returns None when there is nothing to draw, and then this returns Ok(None). Returns an error if the pixels fail validation or the atlas is full. The builder runs with the atlas locked and must not re-enter the same atlas.

Source

fn get_or_insert_glyph_with( &self, params: &RenderGlyphParams, build: &mut dyn FnMut() -> Result<ValidatedRasterizedGlyph>, ) -> Result<GlyphAtlasEntry>

Returns the atlas entry for the glyph params, calling build on a cache miss.

build returns a ValidatedRasterizedGlyph, which is inserted into the atlas.

Source

fn remove(&self, key: &AtlasKey)

Removes the tile for key, freeing its space in the atlas.

Provided Methods§

Source

fn contains(&self, _key: &AtlasKey) -> bool

Returns true if the atlas has a tile for key. Atlases that don’t track this return false.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§