diff options
author | 2020-02-12 03:47:36 +0100 | |
---|---|---|
committer | 2020-02-12 03:47:36 +0100 | |
commit | f436f20eb86b2324126a54d4164b4cedf2134a45 (patch) | |
tree | a19be4a267640d459ae4cbd6b5a26e3c69120189 /wgpu/src/widget/canvas/layer.rs | |
parent | 8daf798e5760a0d35d5491027d51a5dd96898b0d (diff) | |
download | iced-f436f20eb86b2324126a54d4164b4cedf2134a45.tar.gz iced-f436f20eb86b2324126a54d4164b4cedf2134a45.tar.bz2 iced-f436f20eb86b2324126a54d4164b4cedf2134a45.zip |
Draft `Canvas` types and `clock` example
Diffstat (limited to 'wgpu/src/widget/canvas/layer.rs')
-rw-r--r-- | wgpu/src/widget/canvas/layer.rs | 41 |
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); +} |