1
use easygpu::prelude::*;
2
use easygpu_lyon::ShapeBuilder;
3

            
4
use crate::math::Pixels;
5
use crate::shape::Shape;
6

            
7
/// A batch of shapes that can be rendered together.
8
1
#[derive(Debug, Default, Clone)]
9
pub struct Batch {
10
    shapes: Vec<Shape<Pixels>>,
11
}
12

            
13
impl Batch {
14
3
    pub(crate) fn add(&mut self, shape: Shape<Pixels>) {
15
3
        self.shapes.push(shape);
16
3
    }
17

            
18
1
    pub(crate) fn finish(self, renderer: &Renderer) -> crate::Result<easygpu_lyon::Shape> {
19
1
        let mut builder = ShapeBuilder::default();
20

            
21
4
        for shape in self.shapes {
22
3
            shape.build(&mut builder)?;
23
        }
24

            
25
1
        Ok(builder.prepare(renderer))
26
1
    }
27
}