summaryrefslogtreecommitdiffstats
path: root/wgpu/src/layer.rs
diff options
context:
space:
mode:
authorLibravatar Bingus <shankern@protonmail.com>2023-05-25 10:27:27 -0700
committerLibravatar Bingus <shankern@protonmail.com>2023-05-29 12:14:11 -0700
commit3f141459a66fe66e6dc25d579d0cda80662f0895 (patch)
treec398cb4801bbfe9da148744ad8da3986c624a808 /wgpu/src/layer.rs
parent75110b9c0e82f37f3c75ce276216db5dbcb4ff1b (diff)
downloadiced-3f141459a66fe66e6dc25d579d0cda80662f0895.tar.gz
iced-3f141459a66fe66e6dc25d579d0cda80662f0895.tar.bz2
iced-3f141459a66fe66e6dc25d579d0cda80662f0895.zip
Fixed issue where quads of different types were not ordered.
Diffstat (limited to '')
-rw-r--r--wgpu/src/layer.rs42
1 files changed, 41 insertions, 1 deletions
diff --git a/wgpu/src/layer.rs b/wgpu/src/layer.rs
index bf5c4c0a..f5c4b576 100644
--- a/wgpu/src/layer.rs
+++ b/wgpu/src/layer.rs
@@ -43,6 +43,12 @@ pub struct Quads {
/// The gradient quads of the [`Layer`].
pub gradients: Vec<quad::Gradient>,
+
+ /// The quad order of the [`Layer`]; stored as a tuple of the quad type & its count.
+ pub order: Vec<(quad::Order, usize)>,
+
+ // The last index of quad ordering.
+ index: usize,
}
impl Quads {
@@ -174,12 +180,13 @@ impl<'a> Layer<'a> {
border_width: *border_width,
};
- match background {
+ let quad_order = match background {
Background::Color(color) => {
layer.quads.solids.push(quad::Solid {
color: color.into_linear(),
quad,
});
+ quad::Order::Solid
}
Background::Gradient(gradient) => {
let quad = quad::Gradient {
@@ -194,8 +201,41 @@ impl<'a> Layer<'a> {
};
layer.quads.gradients.push(quad);
+ quad::Order::Gradient
}
};
+
+ match (layer.quads.order.get_mut(layer.quads.index), quad_order)
+ {
+ (Some((quad_order, count)), quad::Order::Solid) => {
+ match quad_order {
+ quad::Order::Solid => {
+ *count += 1;
+ }
+ quad::Order::Gradient => {
+ layer.quads.order.push((quad::Order::Solid, 1));
+ layer.quads.index += 1;
+ }
+ }
+ }
+ (Some((quad_order, count)), quad::Order::Gradient) => {
+ match quad_order {
+ quad::Order::Solid => {
+ layer
+ .quads
+ .order
+ .push((quad::Order::Gradient, 1));
+ layer.quads.index += 1;
+ }
+ quad::Order::Gradient => {
+ *count += 1;
+ }
+ }
+ }
+ (None, _) => {
+ layer.quads.order.push((quad_order, 1));
+ }
+ }
}
Primitive::Image { handle, bounds } => {
let layer = &mut layers[current_layer];