pub mod allocator;
pub mod cache;
pub mod rasterizer;
use allocator::GlyphAtlas;
use cache::GlyphCache;
use etagere::Allocation;
pub fn allocate_or_evict(
atlas: &mut GlyphAtlas,
cache: &mut GlyphCache,
width: u32,
height: u32,
) -> (Option<Allocation>, bool) {
if let Some(alloc) = atlas.allocate(width, height) {
return (Some(alloc), false);
}
let evicted = cache.evict_for_pressure();
if evicted.is_empty() {
return (None, false);
}
for glyph in &evicted {
atlas.deallocate(glyph.alloc_id);
#[cfg(debug_assertions)]
atlas.debug_poison_rect(glyph.atlas_x, glyph.atlas_y, glyph.width, glyph.height);
}
(atlas.allocate(width, height), true)
}