Trim raster cache in iced_tiny_skia

This commit is contained in:
Héctor Ramón Jiménez 2023-03-07 06:15:05 +01:00
parent 5b3977daf6
commit a8d55ceb82
No known key found for this signature in database
GPG key ID: 140CC052C94F138E
2 changed files with 12 additions and 0 deletions

View file

@ -86,6 +86,9 @@ impl Backend {
self.text_pipeline.trim_cache();
#[cfg(feature = "image")]
self.raster_pipeline.trim_cache();
#[cfg(feature = "svg")]
self.vector_pipeline.trim_cache();
}

View file

@ -52,6 +52,10 @@ impl Pipeline {
);
}
}
pub fn trim_cache(&mut self) {
self.cache.borrow_mut().trim();
}
}
#[derive(Default)]
@ -98,6 +102,11 @@ impl Cache {
.expect("Build pixmap from image bytes")
})
}
fn trim(&mut self) {
self.entries.retain(|key, _| self.hits.contains(key));
self.hits.clear();
}
}
struct Entry {