iced/wgpu/src/image/atlas/allocation.rs
Héctor Ramón Jiménez 8ce8d374b1
Refactor some image traits a bit
- Use `Size<u32>` were applicable.
- Rename `TextureStore` to `image::Storage`.
- Rename `TextureStoreEntry` to `image::storage::Entry`.
- Wire up `viewport_dimensions` to `iced_glow` for `Svg`.
2022-11-05 03:19:38 +01:00

37 lines
844 B
Rust

use crate::image::atlas::{self, allocator};
use iced_graphics::Size;
#[derive(Debug)]
pub enum Allocation {
Partial {
layer: usize,
region: allocator::Region,
},
Full {
layer: usize,
},
}
impl Allocation {
pub fn position(&self) -> (u32, u32) {
match self {
Allocation::Partial { region, .. } => region.position(),
Allocation::Full { .. } => (0, 0),
}
}
pub fn size(&self) -> Size<u32> {
match self {
Allocation::Partial { region, .. } => region.size(),
Allocation::Full { .. } => Size::new(atlas::SIZE, atlas::SIZE),
}
}
pub fn layer(&self) -> usize {
match self {
Allocation::Partial { layer, .. } => *layer,
Allocation::Full { layer } => *layer,
}
}
}