summaryrefslogtreecommitdiffstats
path: root/wgpu/src/layer.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2023-06-29 07:48:03 +0200
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2023-06-29 07:48:03 +0200
commitfa5650cfd1115e6ccec2ad795cf58fd970d5b43c (patch)
tree90fa0706c8d28547fd4dae1000161082b52b9b27 /wgpu/src/layer.rs
parent2128472c2a8afcb59927712497c4f613612e9dcc (diff)
downloadiced-fa5650cfd1115e6ccec2ad795cf58fd970d5b43c.tar.gz
iced-fa5650cfd1115e6ccec2ad795cf58fd970d5b43c.tar.bz2
iced-fa5650cfd1115e6ccec2ad795cf58fd970d5b43c.zip
Decouple `Mesh` primitives from main `Primitive` type
Diffstat (limited to 'wgpu/src/layer.rs')
-rw-r--r--wgpu/src/layer.rs86
1 files changed, 50 insertions, 36 deletions
diff --git a/wgpu/src/layer.rs b/wgpu/src/layer.rs
index ef850cd9..b8f32db1 100644
--- a/wgpu/src/layer.rs
+++ b/wgpu/src/layer.rs
@@ -11,10 +11,11 @@ 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::Viewport;
+use crate::primitive::{self, Primitive};
use crate::quad::{self, Quad};
-use crate::Primitive;
/// A group of primitives that should be clipped together.
#[derive(Debug)]
@@ -180,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 {
@@ -263,7 +230,54 @@ impl<'a> Layer<'a> {
current_layer,
);
}
- Primitive::Custom(()) => {}
+ 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,
+ });
+ }
+ }
+ },
+ },
}
}
}