diff options
author | 2023-03-17 19:58:42 +0100 | |
---|---|---|
committer | 2023-03-17 19:58:42 +0100 | |
commit | ea50ec8df1431c9c6aa8077cd1578c4698dc0314 (patch) | |
tree | 5326bf86485925f1f9afaea523d0d4d5742ebe46 /wgpu/src/text.rs | |
parent | c8f637fc16099c70836574425a6df20a3e2fa801 (diff) | |
download | iced-ea50ec8df1431c9c6aa8077cd1578c4698dc0314.tar.gz iced-ea50ec8df1431c9c6aa8077cd1578c4698dc0314.tar.bz2 iced-ea50ec8df1431c9c6aa8077cd1578c4698dc0314.zip |
Trim text `Buffer` cache every frame in `iced_wgpu` and `iced_tiny_skia`
Diffstat (limited to 'wgpu/src/text.rs')
-rw-r--r-- | wgpu/src/text.rs | 16 |
1 files changed, 3 insertions, 13 deletions
diff --git a/wgpu/src/text.rs b/wgpu/src/text.rs index e99844e6..35f24cd9 100644 --- a/wgpu/src/text.rs +++ b/wgpu/src/text.rs @@ -321,7 +321,6 @@ struct Cache<'a> { entries: FxHashMap<KeyHash, glyphon::Buffer<'a>>, recently_used: FxHashSet<KeyHash>, hasher: HashBuilder, - trim_count: usize, } #[cfg(not(target_arch = "wasm32"))] @@ -331,14 +330,11 @@ type HashBuilder = twox_hash::RandomXxHashBuilder64; type HashBuilder = std::hash::BuildHasherDefault<twox_hash::XxHash64>; impl<'a> Cache<'a> { - const TRIM_INTERVAL: usize = 300; - fn new() -> Self { Self { entries: FxHashMap::default(), recently_used: FxHashSet::default(), hasher: HashBuilder::default(), - trim_count: 0, } } @@ -387,16 +383,10 @@ impl<'a> Cache<'a> { } fn trim(&mut self) { - if self.trim_count >= Self::TRIM_INTERVAL { - self.entries - .retain(|key, _| self.recently_used.contains(key)); - - self.recently_used.clear(); + self.entries + .retain(|key, _| self.recently_used.contains(key)); - self.trim_count = 0; - } else { - self.trim_count += 1; - } + self.recently_used.clear(); } } |