summaryrefslogtreecommitdiffstats
path: root/wgpu/src/texture/atlas/allocation.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2020-02-26 12:34:34 +0100
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2020-02-26 12:34:34 +0100
commit59d45a5440aaa46c7dc8f3dc70c8518167c10418 (patch)
tree2b5ad3d2c577e9ebb7fcac7452a74680174f8108 /wgpu/src/texture/atlas/allocation.rs
parent82f0a49062d10f3cbf202a5379c061a2509ec97b (diff)
downloadiced-59d45a5440aaa46c7dc8f3dc70c8518167c10418.tar.gz
iced-59d45a5440aaa46c7dc8f3dc70c8518167c10418.tar.bz2
iced-59d45a5440aaa46c7dc8f3dc70c8518167c10418.zip
Refactor texture atlas
- Split into multiple modules - Rename some concepts - Change API details
Diffstat (limited to 'wgpu/src/texture/atlas/allocation.rs')
-rw-r--r--wgpu/src/texture/atlas/allocation.rs35
1 files changed, 35 insertions, 0 deletions
diff --git a/wgpu/src/texture/atlas/allocation.rs b/wgpu/src/texture/atlas/allocation.rs
new file mode 100644
index 00000000..e17b3f8c
--- /dev/null
+++ b/wgpu/src/texture/atlas/allocation.rs
@@ -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,
+ }
+ }
+}