Redesign iced_wgpu layering architecture

This commit is contained in:
Héctor Ramón Jiménez 2024-04-03 21:07:54 +02:00
parent 99a904112c
commit b05e61f5c8
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
36 changed files with 2781 additions and 2048 deletions

47
graphics/src/layer.rs Normal file
View file

@ -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;
}
}