summaryrefslogtreecommitdiffstats
path: root/wgpu/src/widget/canvas/layer.rs
blob: 95e2d0eed580120d2e796097ff7fb168b044aad3 (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
//! Produce, store, and reuse geometry.
mod cache;

pub use cache::Cache;

use crate::Primitive;

use iced_native::{Point, Size};

/// 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, origin: Point, bounds: Size) -> Primitive;
}