diff options
author | 2024-01-19 20:41:52 +0100 | |
---|---|---|
committer | 2024-01-19 20:41:52 +0100 | |
commit | 1781068e1c3a65551db1e832fdbaddba99124051 (patch) | |
tree | 60e0b3854cc0541712572fbb0e56f14435951ea9 /wgpu/src/layer.rs | |
parent | 41dec5bd203ff5b1574a33a17d5f7358ae1beea2 (diff) | |
parent | 7ae7fcb89855002519bab752fd3686106ce448db (diff) | |
download | iced-1781068e1c3a65551db1e832fdbaddba99124051.tar.gz iced-1781068e1c3a65551db1e832fdbaddba99124051.tar.bz2 iced-1781068e1c3a65551db1e832fdbaddba99124051.zip |
Merge branch 'master' into remove-vertex-indexing
Diffstat (limited to 'wgpu/src/layer.rs')
-rw-r--r-- | wgpu/src/layer.rs | 64 |
1 files changed, 62 insertions, 2 deletions
diff --git a/wgpu/src/layer.rs b/wgpu/src/layer.rs index d20dbe66..4ad12a88 100644 --- a/wgpu/src/layer.rs +++ b/wgpu/src/layer.rs @@ -1,11 +1,13 @@ //! Organize rendering primitives into a flattened list of layers. mod image; +mod pipeline; mod text; pub mod mesh; pub use image::Image; pub use mesh::Mesh; +pub use pipeline::Pipeline; pub use text::Text; use crate::core; @@ -34,6 +36,9 @@ pub struct Layer<'a> { /// The images of the [`Layer`]. pub images: Vec<Image>, + + /// The custom pipelines of this [`Layer`]. + pub pipelines: Vec<Pipeline>, } impl<'a> Layer<'a> { @@ -45,6 +50,7 @@ impl<'a> Layer<'a> { meshes: Vec::new(), text: Vec::new(), images: Vec::new(), + pipelines: Vec::new(), } } @@ -69,6 +75,7 @@ impl<'a> Layer<'a> { horizontal_alignment: alignment::Horizontal::Left, vertical_alignment: alignment::Vertical::Top, shaping: core::text::Shaping::Basic, + clip_bounds: Rectangle::with_size(Size::INFINITY), }; overlay.text.push(Text::Cached(text.clone())); @@ -117,13 +124,30 @@ impl<'a> Layer<'a> { paragraph, position, color, + clip_bounds, } => { let layer = &mut layers[current_layer]; - layer.text.push(Text::Managed { + layer.text.push(Text::Paragraph { paragraph: paragraph.clone(), position: *position + translation, color: *color, + clip_bounds: *clip_bounds + translation, + }); + } + Primitive::Editor { + editor, + position, + color, + clip_bounds, + } => { + let layer = &mut layers[current_layer]; + + layer.text.push(Text::Editor { + editor: editor.clone(), + position: *position + translation, + color: *color, + clip_bounds: *clip_bounds + translation, }); } Primitive::Text { @@ -136,6 +160,7 @@ impl<'a> Layer<'a> { horizontal_alignment, vertical_alignment, shaping, + clip_bounds, } => { let layer = &mut layers[current_layer]; @@ -149,6 +174,22 @@ impl<'a> Layer<'a> { horizontal_alignment: *horizontal_alignment, vertical_alignment: *vertical_alignment, shaping: *shaping, + clip_bounds: *clip_bounds + translation, + })); + } + graphics::Primitive::RawText(graphics::text::Raw { + buffer, + position, + color, + clip_bounds, + }) => { + let layer = &mut layers[current_layer]; + + layer.text.push(Text::Raw(graphics::text::Raw { + buffer: buffer.clone(), + position: *position + translation, + color: *color, + clip_bounds: *clip_bounds + translation, })); } Primitive::Quad { @@ -173,11 +214,16 @@ impl<'a> Layer<'a> { layer.quads.add(quad, background); } - Primitive::Image { handle, bounds } => { + Primitive::Image { + handle, + filter_method, + bounds, + } => { let layer = &mut layers[current_layer]; layer.images.push(Image::Raster { handle: handle.clone(), + filter_method: *filter_method, bounds: *bounds + translation, }); } @@ -290,6 +336,20 @@ impl<'a> Layer<'a> { } } }, + primitive::Custom::Pipeline(pipeline) => { + let layer = &mut layers[current_layer]; + let bounds = pipeline.bounds + translation; + + if let Some(clip_bounds) = + layer.bounds.intersection(&bounds) + { + layer.pipelines.push(Pipeline { + bounds, + viewport: clip_bounds, + primitive: pipeline.primitive.clone(), + }); + } + } }, } } |