summaryrefslogtreecommitdiffstats
path: root/wgpu/src/widget/canvas/cache.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2020-04-28 06:24:12 +0200
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2020-04-28 06:24:12 +0200
commit2539042b71d70afd4d8f262783d441e768811ee9 (patch)
treef3af8a86b700308ff5fe9f28f88a508b2fd8cdb5 /wgpu/src/widget/canvas/cache.rs
parent7f1e7aea07bb448471470093a47898b059d940d3 (diff)
downloadiced-2539042b71d70afd4d8f262783d441e768811ee9.tar.gz
iced-2539042b71d70afd4d8f262783d441e768811ee9.tar.bz2
iced-2539042b71d70afd4d8f262783d441e768811ee9.zip
Remove `Drawable` and rename `State` to `Program`
Diffstat (limited to 'wgpu/src/widget/canvas/cache.rs')
-rw-r--r--wgpu/src/widget/canvas/cache.rs37
1 files changed, 7 insertions, 30 deletions
diff --git a/wgpu/src/widget/canvas/cache.rs b/wgpu/src/widget/canvas/cache.rs
index 2beed0f7..03643f74 100644
--- a/wgpu/src/widget/canvas/cache.rs
+++ b/wgpu/src/widget/canvas/cache.rs
@@ -1,5 +1,5 @@
use crate::{
- canvas::{Drawable, Frame, Geometry},
+ canvas::{Frame, Geometry},
Primitive,
};
@@ -48,10 +48,11 @@ impl Cache {
*self.state.borrow_mut() = State::Empty;
}
- pub fn draw<T>(&self, new_bounds: Size, input: T) -> Geometry
- where
- T: Drawable + std::fmt::Debug,
- {
+ pub fn draw(
+ &self,
+ new_bounds: Size,
+ draw_fn: impl Fn(&mut Frame),
+ ) -> Geometry {
use std::ops::Deref;
if let State::Filled { bounds, primitive } = self.state.borrow().deref()
@@ -64,7 +65,7 @@ impl Cache {
}
let mut frame = Frame::new(new_bounds);
- input.draw(&mut frame);
+ draw_fn(&mut frame);
let primitive = {
let geometry = frame.into_geometry();
@@ -79,30 +80,6 @@ impl Cache {
Geometry::from_primitive(Primitive::Cached { cache: primitive })
}
-
- pub fn with<'a, T, Message>(
- &'a self,
- input: T,
- ) -> impl crate::canvas::State<Message> + 'a
- where
- T: Drawable + std::fmt::Debug + 'a,
- {
- Bind { cache: self, input }
- }
-}
-
-struct Bind<'a, T> {
- cache: &'a Cache,
- input: T,
-}
-
-impl<'a, T, Message> crate::canvas::State<Message> for Bind<'a, T>
-where
- T: Drawable + std::fmt::Debug + 'a,
-{
- fn draw(&self, bounds: Size) -> Vec<Geometry> {
- vec![self.cache.draw(bounds, &self.input)]
- }
}
impl std::fmt::Debug for State {