summaryrefslogtreecommitdiffstats
path: root/graphics/src/renderer.rs
diff options
context:
space:
mode:
Diffstat (limited to 'graphics/src/renderer.rs')
-rw-r--r--graphics/src/renderer.rs27
1 files changed, 21 insertions, 6 deletions
diff --git a/graphics/src/renderer.rs b/graphics/src/renderer.rs
index d90a3f1e..8b6c2217 100644
--- a/graphics/src/renderer.rs
+++ b/graphics/src/renderer.rs
@@ -51,10 +51,26 @@ where
layout
}
- fn with_layer(
+ fn with_layer(&mut self, bounds: Rectangle, f: impl FnOnce(&mut Self)) {
+ let current_primitives =
+ std::mem::replace(&mut self.primitives, Vec::new());
+
+ f(self);
+
+ let layer_primitives =
+ std::mem::replace(&mut self.primitives, current_primitives);
+
+ self.primitives.push(Primitive::Clip {
+ bounds,
+ content: Box::new(Primitive::Group {
+ primitives: layer_primitives,
+ }),
+ });
+ }
+
+ fn with_translation(
&mut self,
- bounds: Rectangle,
- offset: Vector<u32>,
+ translation: Vector,
f: impl FnOnce(&mut Self),
) {
let current_primitives =
@@ -65,9 +81,8 @@ where
let layer_primitives =
std::mem::replace(&mut self.primitives, current_primitives);
- self.primitives.push(Primitive::Clip {
- bounds,
- offset,
+ self.primitives.push(Primitive::Translate {
+ translation,
content: Box::new(Primitive::Group {
primitives: layer_primitives,
}),