2023-03-04 05:37:11 +01:00
|
|
|
use crate::core::Size;
|
2020-02-28 14:38:42 +01:00
|
|
|
use crate::image::atlas;
|
2022-11-05 03:13:04 +01:00
|
|
|
|
2020-02-26 12:34:34 +01:00
|
|
|
#[derive(Debug)]
|
|
|
|
|
pub enum Entry {
|
|
|
|
|
Contiguous(atlas::Allocation),
|
|
|
|
|
Fragmented {
|
2022-11-05 03:13:04 +01:00
|
|
|
size: Size<u32>,
|
2020-02-26 12:34:34 +01:00
|
|
|
fragments: Vec<Fragment>,
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-07 03:47:49 +01:00
|
|
|
impl Entry {
|
|
|
|
|
#[cfg(feature = "image")]
|
|
|
|
|
pub fn size(&self) -> Size<u32> {
|
2020-02-26 12:34:34 +01:00
|
|
|
match self {
|
|
|
|
|
Entry::Contiguous(allocation) => allocation.size(),
|
|
|
|
|
Entry::Fragmented { size, .. } => *size,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Debug)]
|
|
|
|
|
pub struct Fragment {
|
|
|
|
|
pub position: (u32, u32),
|
|
|
|
|
pub allocation: atlas::Allocation,
|
|
|
|
|
}
|