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§
Sourcefn 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_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.
Sourcefn get_or_insert_glyph_with(
&self,
params: &RenderGlyphParams,
build: &mut dyn FnMut() -> Result<ValidatedRasterizedGlyph>,
) -> Result<GlyphAtlasEntry>
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.
Provided Methods§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".