summaryrefslogtreecommitdiffstats
path: root/wgpu
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2023-05-29 20:56:51 +0200
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2023-05-29 20:56:51 +0200
commit8ca7b884c0695e4e7a031ea1359ee733bdcaa8a4 (patch)
treeff619b90ef356d3b4d9e8f542816bfa9bcb7a2d6 /wgpu
parent902e333148a1ceed85aba36262a849aaed8d3ac9 (diff)
downloadiced-8ca7b884c0695e4e7a031ea1359ee733bdcaa8a4.tar.gz
iced-8ca7b884c0695e4e7a031ea1359ee733bdcaa8a4.tar.bz2
iced-8ca7b884c0695e4e7a031ea1359ee733bdcaa8a4.zip
Make `Packed` fully opaque
... by only allowing direct conversion from our `Gradient` types
Diffstat (limited to '')
-rw-r--r--wgpu/src/layer.rs34
1 files changed, 1 insertions, 33 deletions
diff --git a/wgpu/src/layer.rs b/wgpu/src/layer.rs
index 9d7f9f2a..bf5c4c0a 100644
--- a/wgpu/src/layer.rs
+++ b/wgpu/src/layer.rs
@@ -183,7 +183,7 @@ impl<'a> Layer<'a> {
}
Background::Gradient(gradient) => {
let quad = quad::Gradient {
- gradient: pack_gradient(
+ gradient: gradient::pack(
gradient,
Rectangle::new(
quad.position.into(),
@@ -311,35 +311,3 @@ impl<'a> Layer<'a> {
}
}
}
-
-/// Packs the [`Gradient`] for use in shader code.
-fn pack_gradient(
- gradient: &core::Gradient,
- bounds: Rectangle,
-) -> gradient::Packed {
- match gradient {
- core::Gradient::Linear(linear) => {
- let mut data: [f32; 44] = [0.0; 44];
-
- for (index, stop) in linear.stops.iter().enumerate() {
- let [r, g, b, a] =
- stop.map_or(Color::default(), |s| s.color).into_linear();
-
- data[index * 4] = r;
- data[(index * 4) + 1] = g;
- data[(index * 4) + 2] = b;
- data[(index * 4) + 3] = a;
- data[32 + index] = stop.map_or(2.0, |s| s.offset);
- }
-
- let (start, end) = linear.angle.to_distance(&bounds);
-
- data[40] = start.x;
- data[41] = start.y;
- data[42] = end.x;
- data[43] = end.y;
-
- data.into()
- }
- }
-}