diff options
Diffstat (limited to '')
-rw-r--r-- | wgpu/src/layer.rs (renamed from graphics/src/layer.rs) | 80 | ||||
-rw-r--r-- | wgpu/src/layer/image.rs (renamed from graphics/src/layer/image.rs) | 0 | ||||
-rw-r--r-- | wgpu/src/layer/mesh.rs (renamed from graphics/src/layer/mesh.rs) | 6 | ||||
-rw-r--r-- | wgpu/src/layer/quad.rs (renamed from graphics/src/layer/quad.rs) | 0 | ||||
-rw-r--r-- | wgpu/src/layer/text.rs (renamed from graphics/src/layer/text.rs) | 0 |
5 files changed, 45 insertions, 41 deletions
diff --git a/graphics/src/layer.rs b/wgpu/src/layer.rs index f6eb2fdd..0840555a 100644 --- a/graphics/src/layer.rs +++ b/wgpu/src/layer.rs @@ -10,10 +10,11 @@ pub use mesh::Mesh; pub use quad::Quad; pub use text::Text; -use crate::alignment; -use crate::{ - Background, Color, Font, Point, Primitive, Rectangle, Size, Vector, - Viewport, +use crate::Primitive; + +use iced_graphics::alignment; +use iced_graphics::{ + Background, Color, Font, Point, Rectangle, Size, Vector, Viewport, }; /// A group of primitives that should be clipped together. @@ -110,18 +111,6 @@ impl<'a> Layer<'a> { current_layer: usize, ) { match primitive { - Primitive::None => {} - Primitive::Group { primitives } => { - // TODO: Inspect a bit and regroup (?) - for primitive in primitives { - Self::process_primitive( - layers, - translation, - primitive, - current_layer, - ) - } - } Primitive::Text { content, bounds, @@ -167,6 +156,27 @@ impl<'a> Layer<'a> { border_color: border_color.into_linear(), }); } + Primitive::Image { handle, bounds } => { + let layer = &mut layers[current_layer]; + + layer.images.push(Image::Raster { + handle: handle.clone(), + bounds: *bounds + translation, + }); + } + Primitive::Svg { + handle, + color, + bounds, + } => { + let layer = &mut layers[current_layer]; + + layer.images.push(Image::Vector { + handle: handle.clone(), + color: *color, + bounds: *bounds + translation, + }); + } Primitive::SolidMesh { buffers, size } => { let layer = &mut layers[current_layer]; @@ -206,6 +216,17 @@ impl<'a> Layer<'a> { }); } } + Primitive::Group { primitives } => { + // TODO: Inspect a bit and regroup (?) + for primitive in primitives { + Self::process_primitive( + layers, + translation, + primitive, + current_layer, + ) + } + } Primitive::Clip { bounds, content } => { let layer = &mut layers[current_layer]; let translated_bounds = *bounds + translation; @@ -236,34 +257,17 @@ impl<'a> Layer<'a> { current_layer, ); } - Primitive::Cached { cache } => { + Primitive::Cache { content } => { Self::process_primitive( layers, translation, - cache, + content, current_layer, ); } - Primitive::Image { handle, bounds } => { - let layer = &mut layers[current_layer]; - - layer.images.push(Image::Raster { - handle: handle.clone(), - bounds: *bounds + translation, - }); - } - Primitive::Svg { - handle, - color, - bounds, - } => { - let layer = &mut layers[current_layer]; - - layer.images.push(Image::Vector { - handle: handle.clone(), - color: *color, - bounds: *bounds + translation, - }); + Primitive::Fill { .. } | Primitive::Stroke { .. } => { + // Unsupported! + // TODO: Draw a placeholder (?) } } } diff --git a/graphics/src/layer/image.rs b/wgpu/src/layer/image.rs index 3eff2397..3eff2397 100644 --- a/graphics/src/layer/image.rs +++ b/wgpu/src/layer/image.rs diff --git a/graphics/src/layer/mesh.rs b/wgpu/src/layer/mesh.rs index 7661c5c9..5c1e41ad 100644 --- a/graphics/src/layer/mesh.rs +++ b/wgpu/src/layer/mesh.rs @@ -1,5 +1,5 @@ //! A collection of triangle primitives. -use crate::triangle; +use crate::primitive; use crate::{Gradient, Point, Rectangle}; /// A mesh of triangles. @@ -11,7 +11,7 @@ pub enum Mesh<'a> { origin: Point, /// The vertex and index buffers of the [`Mesh`]. - buffers: &'a triangle::Mesh2D<triangle::ColoredVertex2D>, + buffers: &'a primitive::Mesh2D<primitive::ColoredVertex2D>, /// The clipping bounds of the [`Mesh`]. clip_bounds: Rectangle<f32>, @@ -22,7 +22,7 @@ pub enum Mesh<'a> { origin: Point, /// The vertex and index buffers of the [`Mesh`]. - buffers: &'a triangle::Mesh2D<triangle::Vertex2D>, + buffers: &'a primitive::Mesh2D<primitive::Vertex2D>, /// The clipping bounds of the [`Mesh`]. clip_bounds: Rectangle<f32>, diff --git a/graphics/src/layer/quad.rs b/wgpu/src/layer/quad.rs index 0d8bde9d..0d8bde9d 100644 --- a/graphics/src/layer/quad.rs +++ b/wgpu/src/layer/quad.rs diff --git a/graphics/src/layer/text.rs b/wgpu/src/layer/text.rs index 38d62616..38d62616 100644 --- a/graphics/src/layer/text.rs +++ b/wgpu/src/layer/text.rs |