blob: 5b8aacabadce8ce33df2041462cb16020ed9b487 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
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;
}
}
|