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.
22 lines
414 B
Rust
22 lines
414 B
Rust
use crate::image::atlas::Allocator;
|
|
|
|
#[derive(Debug)]
|
|
pub enum Layer {
|
|
Empty,
|
|
Busy(Allocator),
|
|
Full,
|
|
}
|
|
|
|
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,
|
|
}
|
|
}
|
|
}
|