Refactor texture atlas
- Split into multiple modules - Rename some concepts - Change API details
This commit is contained in:
parent
82f0a49062
commit
59d45a5440
11 changed files with 647 additions and 667 deletions
35
wgpu/src/texture/atlas/allocation.rs
Normal file
35
wgpu/src/texture/atlas/allocation.rs
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
use crate::texture::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,
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue