Fix potentially evicting glyphs in use during try_allocate

This commit is contained in:
Héctor Ramón Jiménez 2023-07-04 18:36:18 +02:00 committed by Josh Groves
parent bc9cc82050
commit 7f31965063

View file

@ -84,12 +84,19 @@ impl InnerAtlas {
// Try to free least recently used allocation // Try to free least recently used allocation
let (mut key, mut value) = self.glyph_cache.peek_lru()?; let (mut key, mut value) = self.glyph_cache.peek_lru()?;
// Find a glyph with an actual size
while value.atlas_id.is_none() { while value.atlas_id.is_none() {
// All sized glyphs are in use, cache is full
if self.glyphs_in_use.contains(&key) {
return None;
}
let _ = self.glyph_cache.pop_lru(); let _ = self.glyph_cache.pop_lru();
(key, value) = self.glyph_cache.peek_lru()?; (key, value) = self.glyph_cache.peek_lru()?;
} }
// All sized glyphs are in use, cache is full
if self.glyphs_in_use.contains(&key) { if self.glyphs_in_use.contains(&key) {
return None; return None;
} }