summaryrefslogtreecommitdiffstats
path: root/wgpu/src/layer.rs
diff options
context:
space:
mode:
Diffstat (limited to 'wgpu/src/layer.rs')
-rw-r--r--wgpu/src/layer.rs93
1 files changed, 51 insertions, 42 deletions
diff --git a/wgpu/src/layer.rs b/wgpu/src/layer.rs
index 71570e3d..b8f32db1 100644
--- a/wgpu/src/layer.rs
+++ b/wgpu/src/layer.rs
@@ -11,8 +11,10 @@ pub use text::Text;
use crate::core;
use crate::core::alignment;
use crate::core::{Color, Font, Point, Rectangle, Size, Vector};
+use crate::graphics;
use crate::graphics::color;
-use crate::graphics::{Primitive, Viewport};
+use crate::graphics::Viewport;
+use crate::primitive::{self, Primitive};
use crate::quad::{self, Quad};
/// A group of primitives that should be clipped together.
@@ -179,40 +181,6 @@ impl<'a> Layer<'a> {
bounds: *bounds + translation,
});
}
- Primitive::SolidMesh { buffers, size } => {
- let layer = &mut layers[current_layer];
-
- let bounds = Rectangle::new(
- Point::new(translation.x, translation.y),
- *size,
- );
-
- // Only draw visible content
- if let Some(clip_bounds) = layer.bounds.intersection(&bounds) {
- layer.meshes.push(Mesh::Solid {
- origin: Point::new(translation.x, translation.y),
- buffers,
- clip_bounds,
- });
- }
- }
- Primitive::GradientMesh { buffers, size } => {
- let layer = &mut layers[current_layer];
-
- let bounds = Rectangle::new(
- Point::new(translation.x, translation.y),
- *size,
- );
-
- // Only draw visible content
- if let Some(clip_bounds) = layer.bounds.intersection(&bounds) {
- layer.meshes.push(Mesh::Gradient {
- origin: Point::new(translation.x, translation.y),
- buffers,
- clip_bounds,
- });
- }
- }
Primitive::Group { primitives } => {
// TODO: Inspect a bit and regroup (?)
for primitive in primitives {
@@ -262,13 +230,54 @@ impl<'a> Layer<'a> {
current_layer,
);
}
- _ => {
- // Not supported!
- log::warn!(
- "Unsupported primitive in `iced_wgpu`: {:?}",
- primitive
- );
- }
+ Primitive::Custom(custom) => match custom {
+ primitive::Custom::Mesh(mesh) => match mesh {
+ graphics::Mesh::Solid { buffers, size } => {
+ let layer = &mut layers[current_layer];
+
+ let bounds = Rectangle::new(
+ Point::new(translation.x, translation.y),
+ *size,
+ );
+
+ // Only draw visible content
+ if let Some(clip_bounds) =
+ layer.bounds.intersection(&bounds)
+ {
+ layer.meshes.push(Mesh::Solid {
+ origin: Point::new(
+ translation.x,
+ translation.y,
+ ),
+ buffers,
+ clip_bounds,
+ });
+ }
+ }
+ graphics::Mesh::Gradient { buffers, size } => {
+ let layer = &mut layers[current_layer];
+
+ let bounds = Rectangle::new(
+ Point::new(translation.x, translation.y),
+ *size,
+ );
+
+ // Only draw visible content
+ if let Some(clip_bounds) =
+ layer.bounds.intersection(&bounds)
+ {
+ layer.meshes.push(Mesh::Gradient {
+ origin: Point::new(
+ translation.x,
+ translation.y,
+ ),
+ buffers,
+ clip_bounds,
+ });
+ }
+ }
+ },
+ },
}
}
}