diff options
author | 2023-05-30 01:47:31 +0200 | |
---|---|---|
committer | 2023-05-30 01:47:31 +0200 | |
commit | 9253f7663dc862484988dead9a9d1a0cf2dc93f5 (patch) | |
tree | 0e3b21b14ff0d19a90c22b436e02a9a76729aea3 /wgpu/src/layer.rs | |
parent | 8ff2e0178ff9e53ab5cff9bdbc7c834d277a6a93 (diff) | |
parent | c319f5113b274bedff0d18260eddbd6f9915efc3 (diff) | |
download | iced-9253f7663dc862484988dead9a9d1a0cf2dc93f5.tar.gz iced-9253f7663dc862484988dead9a9d1a0cf2dc93f5.tar.bz2 iced-9253f7663dc862484988dead9a9d1a0cf2dc93f5.zip |
Merge pull request #1873 from bungoboingo/fix/bg-gradient-layering
[Fix] Quads of different background types not ordered
Diffstat (limited to 'wgpu/src/layer.rs')
-rw-r--r-- | wgpu/src/layer.rs | 50 |
1 files changed, 5 insertions, 45 deletions
diff --git a/wgpu/src/layer.rs b/wgpu/src/layer.rs index bf5c4c0a..1a870c15 100644 --- a/wgpu/src/layer.rs +++ b/wgpu/src/layer.rs @@ -3,18 +3,16 @@ mod image; mod text; pub mod mesh; -pub mod quad; pub use image::Image; pub use mesh::Mesh; -pub use quad::Quad; pub use text::Text; use crate::core; use crate::core::alignment; -use crate::core::{Background, Color, Font, Point, Rectangle, Size, Vector}; -use crate::graphics::gradient; +use crate::core::{Color, Font, Point, Rectangle, Size, Vector}; use crate::graphics::{Primitive, Viewport}; +use crate::quad::{self, Quad}; /// A group of primitives that should be clipped together. #[derive(Debug)] @@ -23,7 +21,7 @@ pub struct Layer<'a> { pub bounds: Rectangle, /// The quads of the [`Layer`]. - pub quads: Quads, + pub quads: quad::Batch, /// The triangle meshes of the [`Layer`]. pub meshes: Vec<Mesh<'a>>, @@ -35,29 +33,12 @@ pub struct Layer<'a> { pub images: Vec<Image>, } -/// The quads of the [`Layer`]. -#[derive(Default, Debug)] -pub struct Quads { - /// The solid quads of the [`Layer`]. - pub solids: Vec<quad::Solid>, - - /// The gradient quads of the [`Layer`]. - pub gradients: Vec<quad::Gradient>, -} - -impl Quads { - /// Returns true if there are no quads of any type in [`Quads`]. - pub fn is_empty(&self) -> bool { - self.solids.is_empty() && self.gradients.is_empty() - } -} - impl<'a> Layer<'a> { /// Creates a new [`Layer`] with the given clipping bounds. pub fn new(bounds: Rectangle) -> Self { Self { bounds, - quads: Quads::default(), + quads: quad::Batch::default(), meshes: Vec::new(), text: Vec::new(), images: Vec::new(), @@ -174,28 +155,7 @@ impl<'a> Layer<'a> { border_width: *border_width, }; - match background { - Background::Color(color) => { - layer.quads.solids.push(quad::Solid { - color: color.into_linear(), - quad, - }); - } - Background::Gradient(gradient) => { - let quad = quad::Gradient { - gradient: gradient::pack( - gradient, - Rectangle::new( - quad.position.into(), - quad.size.into(), - ), - ), - quad, - }; - - layer.quads.gradients.push(quad); - } - }; + layer.quads.add(quad, background); } Primitive::Image { handle, bounds } => { let layer = &mut layers[current_layer]; |