summaryrefslogtreecommitdiffstats
path: root/wgpu/src/layer.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-04-08 15:04:35 +0200
committerLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-04-08 15:04:35 +0200
commitd922b478156488a7bc03c6e791e05c040d702634 (patch)
tree767e9b9fa2c6527a0b3e3b3dd1c21b29cd533ee8 /wgpu/src/layer.rs
parent6ea763c2a79292e5b10be2240b4b57b920223616 (diff)
downloadiced-d922b478156488a7bc03c6e791e05c040d702634.tar.gz
iced-d922b478156488a7bc03c6e791e05c040d702634.tar.bz2
iced-d922b478156488a7bc03c6e791e05c040d702634.zip
Reintroduce support for custom primitives in `iced_wgpu`
Diffstat (limited to 'wgpu/src/layer.rs')
-rw-r--r--wgpu/src/layer.rs16
1 files changed, 16 insertions, 0 deletions
diff --git a/wgpu/src/layer.rs b/wgpu/src/layer.rs
index c8c27c61..7a18e322 100644
--- a/wgpu/src/layer.rs
+++ b/wgpu/src/layer.rs
@@ -4,6 +4,7 @@ use crate::graphics::color;
use crate::graphics::text::{Editor, Paragraph};
use crate::graphics::Mesh;
use crate::image::{self, Image};
+use crate::primitive::{self, Primitive};
use crate::quad::{self, Quad};
use crate::text::{self, Text};
use crate::triangle;
@@ -13,6 +14,7 @@ pub struct Layer {
pub bounds: Rectangle,
pub quads: quad::Batch,
pub triangles: triangle::Batch,
+ pub primitives: primitive::Batch,
pub text: text::Batch,
pub images: image::Batch,
}
@@ -23,6 +25,7 @@ impl Default for Layer {
bounds: Rectangle::INFINITE,
quads: quad::Batch::default(),
triangles: triangle::Batch::default(),
+ primitives: primitive::Batch::default(),
text: text::Batch::default(),
images: image::Batch::default(),
}
@@ -222,6 +225,18 @@ impl Stack {
});
}
+ pub fn draw_primitive(
+ &mut self,
+ bounds: Rectangle,
+ primitive: Box<dyn Primitive>,
+ ) {
+ let bounds = bounds * self.transformation();
+
+ self.layers[self.current]
+ .primitives
+ .push(primitive::Instance { bounds, primitive });
+ }
+
pub fn push_clip(&mut self, bounds: Rectangle) {
self.previous.push(self.current);
@@ -282,6 +297,7 @@ impl Stack {
live.quads.clear();
live.triangles.clear();
+ live.primitives.clear();
live.text.clear();
live.images.clear();
pending_meshes.clear();