summaryrefslogtreecommitdiffstats
path: root/wgpu/src/widget/canvas/layer.rs
diff options
context:
space:
mode:
Diffstat (limited to 'wgpu/src/widget/canvas/layer.rs')
-rw-r--r--wgpu/src/widget/canvas/layer.rs41
1 files changed, 41 insertions, 0 deletions
diff --git a/wgpu/src/widget/canvas/layer.rs b/wgpu/src/widget/canvas/layer.rs
new file mode 100644
index 00000000..f97634e4
--- /dev/null
+++ b/wgpu/src/widget/canvas/layer.rs
@@ -0,0 +1,41 @@
+use crate::canvas::Frame;
+
+pub trait Layer: std::fmt::Debug {}
+
+use std::marker::PhantomData;
+use std::sync::{Arc, Weak};
+
+#[derive(Debug)]
+pub struct Cached<T: Drawable> {
+ input: PhantomData<T>,
+}
+
+impl<T> Cached<T>
+where
+ T: Drawable + std::fmt::Debug,
+{
+ pub fn new() -> Self {
+ Cached { input: PhantomData }
+ }
+
+ pub fn clear(&mut self) {}
+
+ pub fn with<'a>(&'a self, input: &'a T) -> impl Layer + 'a {
+ Bind {
+ cache: self,
+ input: input,
+ }
+ }
+}
+
+#[derive(Debug)]
+struct Bind<'a, T: Drawable> {
+ cache: &'a Cached<T>,
+ input: &'a T,
+}
+
+impl<'a, T> Layer for Bind<'a, T> where T: Drawable + std::fmt::Debug {}
+
+pub trait Drawable {
+ fn draw(&self, frame: &mut Frame);
+}