iced_wgpu/image/atlas/
allocation.rs
1use crate::core::Size;
2use crate::image::atlas::{self, allocator};
3
4#[derive(Debug)]
5pub enum Allocation {
6 Partial {
7 layer: usize,
8 region: allocator::Region,
9 },
10 Full {
11 layer: usize,
12 },
13}
14
15impl Allocation {
16 pub fn position(&self) -> (u32, u32) {
17 match self {
18 Allocation::Partial { region, .. } => region.position(),
19 Allocation::Full { .. } => (0, 0),
20 }
21 }
22
23 pub fn size(&self) -> Size<u32> {
24 match self {
25 Allocation::Partial { region, .. } => region.size(),
26 Allocation::Full { .. } => Size::new(atlas::SIZE, atlas::SIZE),
27 }
28 }
29
30 pub fn layer(&self) -> usize {
31 match self {
32 Allocation::Partial { layer, .. } => *layer,
33 Allocation::Full { layer } => *layer,
34 }
35 }
36}