Fix potentially evicting glyphs in use during try_allocate
This commit is contained in:
parent
bc9cc82050
commit
7f31965063
1 changed files with 7 additions and 0 deletions
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue