iced_wgpu/image/atlas/
allocation.rs1use crate::core::Size;
2use crate::image::atlas::allocator;
3
4#[derive(Debug)]
5pub enum Allocation {
6 Partial {
7 layer: usize,
8 region: allocator::Region,
9 atlas_size: u32,
10 },
11 Full {
12 layer: usize,
13 size: u32,
14 },
15}
16
17impl Allocation {
18 pub fn position(&self) -> (u32, u32) {
19 match self {
20 Allocation::Partial { region, .. } => region.position(),
21 Allocation::Full { .. } => (0, 0),
22 }
23 }
24
25 pub fn size(&self) -> Size<u32> {
26 match self {
27 Allocation::Partial { region, .. } => region.size(),
28 Allocation::Full { size, .. } => Size::new(*size, *size),
29 }
30 }
31
32 pub fn padding(&self) -> Size<u32> {
33 match self {
34 Allocation::Partial { region, .. } => region.padding(),
35 Allocation::Full { .. } => Size::new(0, 0),
36 }
37 }
38
39 pub fn layer(&self) -> usize {
40 match self {
41 Allocation::Partial { layer, .. } => *layer,
42 Allocation::Full { layer, .. } => *layer,
43 }
44 }
45
46 pub fn atlas_size(&self) -> u32 {
47 match self {
48 Allocation::Partial { atlas_size, .. } => *atlas_size,
49 Allocation::Full { size, .. } => *size,
50 }
51 }
52}