Stop creating image pipeline when unnecessary

This commit is contained in:
Héctor Ramón Jiménez 2020-02-28 14:38:42 +01:00
parent fc55e3a3df
commit 4e7159c22c
11 changed files with 114 additions and 86 deletions

View file

@ -0,0 +1,35 @@
use crate::image::atlas::{self, allocator};
#[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) -> (u32, u32) {
match self {
Allocation::Partial { region, .. } => region.size(),
Allocation::Full { .. } => (atlas::SIZE, atlas::SIZE),
}
}
pub fn layer(&self) -> usize {
match self {
Allocation::Partial { layer, .. } => *layer,
Allocation::Full { layer } => *layer,
}
}
}