From a8d55ceb829377725b4e7632702894fed6867eda Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Tue, 7 Mar 2023 06:15:05 +0100 Subject: Trim `raster` cache in `iced_tiny_skia` --- tiny_skia/src/raster.rs | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'tiny_skia/src/raster.rs') diff --git a/tiny_skia/src/raster.rs b/tiny_skia/src/raster.rs index e57f0e50..2fd73f8c 100644 --- a/tiny_skia/src/raster.rs +++ b/tiny_skia/src/raster.rs @@ -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 { -- cgit