Deallocate atlas entries and remove padding
This commit is contained in:
parent
48d70280eb
commit
d06d06e050
5 changed files with 82 additions and 44 deletions
|
|
@ -95,10 +95,21 @@ impl Cache {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn trim(&mut self) {
|
||||
pub fn trim(&mut self, atlas: &mut Atlas) {
|
||||
let hits = &self.hits;
|
||||
|
||||
self.map.retain(|k, _| hits.contains(k));
|
||||
self.map.retain(|k, memory| {
|
||||
let retain = hits.contains(k);
|
||||
|
||||
if !retain {
|
||||
if let Memory::Device(entry) = memory {
|
||||
atlas.remove(entry);
|
||||
}
|
||||
}
|
||||
|
||||
retain
|
||||
});
|
||||
|
||||
self.hits.clear();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -130,12 +130,20 @@ impl Cache {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn trim(&mut self) {
|
||||
pub fn trim(&mut self, atlas: &mut Atlas) {
|
||||
let svg_hits = &self.svg_hits;
|
||||
let rasterized_hits = &self.rasterized_hits;
|
||||
|
||||
self.svgs.retain(|k, _| svg_hits.contains(k));
|
||||
self.rasterized.retain(|k, _| rasterized_hits.contains(k));
|
||||
self.rasterized.retain(|k, entry| {
|
||||
let retain = rasterized_hits.contains(k);
|
||||
|
||||
if !retain {
|
||||
atlas.remove(entry);
|
||||
}
|
||||
|
||||
retain
|
||||
});
|
||||
self.svg_hits.clear();
|
||||
self.rasterized_hits.clear();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue