diff options
author | 2020-02-20 05:51:18 +0100 | |
---|---|---|
committer | 2020-02-20 05:51:18 +0100 | |
commit | 17271eae671a933a862dc85aa5b9956a7da70b28 (patch) | |
tree | 1a24e3eebb544b0bc8b0ebf2d92f330141f699bf /wgpu/src/widget/canvas/layer.rs | |
parent | 8d63c49ba1aa43407e0dab0a8e69d3f316a79279 (diff) | |
parent | 6f7247ca13181bcdfe1a3065215c1b3204723b84 (diff) | |
download | iced-17271eae671a933a862dc85aa5b9956a7da70b28.tar.gz iced-17271eae671a933a862dc85aa5b9956a7da70b28.tar.bz2 iced-17271eae671a933a862dc85aa5b9956a7da70b28.zip |
Merge pull request #193 from hecrj/feature/canvas
Canvas widget for 2D graphics
Diffstat (limited to 'wgpu/src/widget/canvas/layer.rs')
-rw-r--r-- | wgpu/src/widget/canvas/layer.rs | 25 |
1 files changed, 25 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..82d647bb --- /dev/null +++ b/wgpu/src/widget/canvas/layer.rs @@ -0,0 +1,25 @@ +//! Produce, store, and reuse geometry. +mod cache; + +pub use cache::Cache; + +use crate::triangle; + +use iced_native::Size; +use std::sync::Arc; + +/// A layer that can be presented at a [`Canvas`]. +/// +/// [`Canvas`]: ../struct.Canvas.html +pub trait Layer: std::fmt::Debug { + /// Draws the [`Layer`] in the given bounds and produces [`Mesh2D`] as a + /// result. + /// + /// The [`Layer`] may choose to store the produced [`Mesh2D`] locally and + /// only recompute it when the bounds change, its contents change, or is + /// otherwise explicitly cleared by other means. + /// + /// [`Layer`]: trait.Layer.html + /// [`Mesh2D`]: ../../../triangle/struct.Mesh2D.html + fn draw(&self, bounds: Size) -> Arc<triangle::Mesh2D>; +} |