summaryrefslogtreecommitdiffstats
path: root/wgpu/src/layer.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2023-03-01 21:34:26 +0100
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2023-03-01 21:34:26 +0100
commit5fd5d1cdf8e5354788dc40729c4565ef377d3bba (patch)
tree0921efc7dc13a3050e03482147a791f85515f1f2 /wgpu/src/layer.rs
parent3f6e28fa9b1b8d911f765c9efb5249a9e0c942d5 (diff)
downloadiced-5fd5d1cdf8e5354788dc40729c4565ef377d3bba.tar.gz
iced-5fd5d1cdf8e5354788dc40729c4565ef377d3bba.tar.bz2
iced-5fd5d1cdf8e5354788dc40729c4565ef377d3bba.zip
Implement `Canvas` support for `iced_tiny_skia`
Diffstat (limited to '')
-rw-r--r--wgpu/src/layer.rs (renamed from graphics/src/layer.rs)80
1 files changed, 42 insertions, 38 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 (?)
}
}
}