diff options
author | 2024-04-03 21:07:54 +0200 | |
---|---|---|
committer | 2024-04-03 21:07:54 +0200 | |
commit | b05e61f5c8ae61c9f3c7cc08cded53901ebbccfd (patch) | |
tree | 3d35a011d94d4936f09b5a9be4031358a09c60da /graphics/src/layer.rs | |
parent | 99a904112ca111f2ab0e60e30b6c369741b1653b (diff) | |
download | iced-b05e61f5c8ae61c9f3c7cc08cded53901ebbccfd.tar.gz iced-b05e61f5c8ae61c9f3c7cc08cded53901ebbccfd.tar.bz2 iced-b05e61f5c8ae61c9f3c7cc08cded53901ebbccfd.zip |
Redesign `iced_wgpu` layering architecture
Diffstat (limited to '')
-rw-r--r-- | graphics/src/layer.rs | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/graphics/src/layer.rs b/graphics/src/layer.rs new file mode 100644 index 00000000..5b8aacab --- /dev/null +++ b/graphics/src/layer.rs @@ -0,0 +1,47 @@ +pub trait Layer { + type Cache; + + fn new() -> Self; + + fn clear(&mut self); +} + +pub struct Recorder<T: Layer> { + layers: Vec<T>, + caches: Vec<T::Cache>, + stack: Vec<Kind>, + current: usize, +} + +enum Kind { + Fresh(usize), + Cache(usize), +} + +impl<T: Layer> Recorder<T> { + pub fn new() -> Self { + Self { + layers: vec![Layer::new()], + caches: Vec::new(), + stack: Vec::new(), + current: 0, + } + } + + pub fn fill_quad(&mut self) {} + + pub fn push_cache(&mut self, cache: T::Cache) { + self.caches.push(cache); + } + + pub fn clear(&mut self) { + self.caches.clear(); + self.stack.clear(); + + for mut layer in self.layers { + layer.clear(); + } + + self.current = 0; + } +} |