Make image Cache eviction strategy less aggressive in iced_wgpu
Instead of trimming unconditionally at the end of a frame, we now trim the cache only when there is a cache miss. This way, images that are not visible but still a part of the layout will stay cached. Eviction will only happen when the images are not a part of the UI for two consectuive frames.
This commit is contained in:
parent
fdcec03197
commit
493c36ac71
6 changed files with 41 additions and 5 deletions
|
|
@ -33,6 +33,10 @@ impl Allocator {
|
|||
pub fn is_empty(&self) -> bool {
|
||||
self.allocations == 0
|
||||
}
|
||||
|
||||
pub fn allocations(&self) -> usize {
|
||||
self.allocations
|
||||
}
|
||||
}
|
||||
|
||||
pub struct Region {
|
||||
|
|
|
|||
|
|
@ -11,4 +11,12 @@ impl Layer {
|
|||
pub fn is_empty(&self) -> bool {
|
||||
matches!(self, Layer::Empty)
|
||||
}
|
||||
|
||||
pub fn allocations(&self) -> usize {
|
||||
match self {
|
||||
Layer::Empty => 0,
|
||||
Layer::Busy(allocator) => allocator.allocations(),
|
||||
Layer::Full => 1,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue