Implemented automatic deallocation of texture space for dropped allocations

This commit is contained in:
Malte Veerman 2020-01-19 18:06:46 +01:00 committed by Héctor Ramón Jiménez
parent 8f9f44b9e8
commit 4617da2818
3 changed files with 88 additions and 85 deletions

View file

@ -130,16 +130,10 @@ impl Cache {
}
}
pub fn trim(&mut self, texture_array: &mut TextureArray) {
pub fn trim(&mut self) {
let svg_hits = &self.svg_hits;
let rasterized_hits = &self.rasterized_hits;
for (k, allocation) in &self.rasterized {
if !rasterized_hits.contains(k) {
texture_array.deallocate(allocation);
}
}
self.svgs.retain(|k, _| svg_hits.contains(k));
self.rasterized.retain(|k, _| rasterized_hits.contains(k));
self.svg_hits.clear();