diff options
author | 2020-02-28 15:17:16 +0100 | |
---|---|---|
committer | 2020-02-28 15:17:16 +0100 | |
commit | bab7dbcaef5d637e6452ef814b78595d9004971c (patch) | |
tree | db82ee28634d499749816f69eaac4f303d088c14 /wgpu/src/image/atlas/allocation.rs | |
parent | 69c81aa50dc30bc7a05df4393e45bc3d478db8b5 (diff) | |
parent | 88d4cd097044077127e1b3aa8fcb04afed185491 (diff) | |
download | iced-bab7dbcaef5d637e6452ef814b78595d9004971c.tar.gz iced-bab7dbcaef5d637e6452ef814b78595d9004971c.tar.bz2 iced-bab7dbcaef5d637e6452ef814b78595d9004971c.zip |
Merge pull request #154 from Maldela/atlas
Texture atlas
Diffstat (limited to 'wgpu/src/image/atlas/allocation.rs')
-rw-r--r-- | wgpu/src/image/atlas/allocation.rs | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/wgpu/src/image/atlas/allocation.rs b/wgpu/src/image/atlas/allocation.rs new file mode 100644 index 00000000..59b7239f --- /dev/null +++ b/wgpu/src/image/atlas/allocation.rs @@ -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, + } + } +} |