summaryrefslogtreecommitdiffstats
path: root/renderer
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2023-10-24 05:34:03 +0200
committerLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-02-02 02:24:45 +0100
commitf4d66486016076bb339a338bc589645119962d1e (patch)
treebbb9c4d996216893296cf4323857323542d6e757 /renderer
parenta6e91d13d5d43796d0e6bb570fb4f010cf27921a (diff)
downloadiced-f4d66486016076bb339a338bc589645119962d1e.tar.gz
iced-f4d66486016076bb339a338bc589645119962d1e.tar.bz2
iced-f4d66486016076bb339a338bc589645119962d1e.zip
Introduce `with_transformation` to `Renderer` trait
Diffstat (limited to 'renderer')
-rw-r--r--renderer/src/geometry.rs3
-rw-r--r--renderer/src/lib.rs16
2 files changed, 10 insertions, 9 deletions
diff --git a/renderer/src/geometry.rs b/renderer/src/geometry.rs
index 9cf506a8..f09ccfbf 100644
--- a/renderer/src/geometry.rs
+++ b/renderer/src/geometry.rs
@@ -2,9 +2,8 @@ mod cache;
pub use cache::Cache;
-use crate::core::{Point, Rectangle, Size, Vector};
+use crate::core::{Point, Rectangle, Size, Transformation, Vector};
use crate::graphics::geometry::{Fill, Path, Stroke, Text};
-use crate::graphics::Transformation;
use crate::Renderer;
macro_rules! delegate {
diff --git a/renderer/src/lib.rs b/renderer/src/lib.rs
index a7df414b..757c264d 100644
--- a/renderer/src/lib.rs
+++ b/renderer/src/lib.rs
@@ -22,7 +22,9 @@ pub use geometry::Geometry;
use crate::core::renderer;
use crate::core::text::{self, Text};
-use crate::core::{Background, Color, Font, Pixels, Point, Rectangle, Vector};
+use crate::core::{
+ Background, Color, Font, Pixels, Point, Rectangle, Transformation,
+};
use crate::graphics::text::Editor;
use crate::graphics::text::Paragraph;
use crate::graphics::Mesh;
@@ -97,20 +99,20 @@ impl core::Renderer for Renderer {
}
}
- fn with_translation(
+ fn with_transformation(
&mut self,
- translation: Vector,
+ transformation: Transformation,
f: impl FnOnce(&mut Self),
) {
match self {
Self::TinySkia(renderer) => {
- let primitives = renderer.start_translation();
+ let primitives = renderer.start_transformation();
f(self);
match self {
Self::TinySkia(renderer) => {
- renderer.end_translation(primitives, translation);
+ renderer.end_transformation(primitives, transformation);
}
#[cfg(feature = "wgpu")]
_ => unreachable!(),
@@ -118,14 +120,14 @@ impl core::Renderer for Renderer {
}
#[cfg(feature = "wgpu")]
Self::Wgpu(renderer) => {
- let primitives = renderer.start_translation();
+ let primitives = renderer.start_transformation();
f(self);
match self {
#[cfg(feature = "wgpu")]
Self::Wgpu(renderer) => {
- renderer.end_translation(primitives, translation);
+ renderer.end_transformation(primitives, transformation);
}
_ => unreachable!(),
}