summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--graphics/src/transformation.rs15
-rw-r--r--tiny_skia/src/backend.rs8
-rw-r--r--wgpu/src/backend.rs8
-rw-r--r--wgpu/src/layer.rs6
4 files changed, 16 insertions, 21 deletions
diff --git a/graphics/src/transformation.rs b/graphics/src/transformation.rs
index 1aeb691e..e2642980 100644
--- a/graphics/src/transformation.rs
+++ b/graphics/src/transformation.rs
@@ -26,21 +26,16 @@ impl Transformation {
Transformation(Mat4::from_translation(Vec3::new(x, y, 0.0)))
}
- /// Creates a scale transformation.
- pub fn scale(x: f32, y: f32) -> Transformation {
- Transformation(Mat4::from_scale(Vec3::new(x, y, 1.0)))
+ /// Creates a uniform scaling transformation.
+ pub fn scale(scaling: f32) -> Transformation {
+ Transformation(Mat4::from_scale(Vec3::new(scaling, scaling, 1.0)))
}
- /// The scale factor on the X axis.
- pub fn scale_x(&self) -> f32 {
+ /// The scale factor of the [`Transformation`].
+ pub fn scale_factor(&self) -> f32 {
self.0.x_axis.x
}
- /// The scale factor on the Y axis.
- pub fn scale_y(&self) -> f32 {
- self.0.y_axis.y
- }
-
/// The translation on the X axis.
pub fn translation_x(&self) -> f32 {
self.0.w_axis.x
diff --git a/tiny_skia/src/backend.rs b/tiny_skia/src/backend.rs
index 87007a51..9c03818f 100644
--- a/tiny_skia/src/backend.rs
+++ b/tiny_skia/src/backend.rs
@@ -461,7 +461,7 @@ impl Backend {
paragraph,
*position * transformation,
*color,
- scale_factor,
+ scale_factor * transformation.scale_factor(),
pixels,
clip_mask,
);
@@ -523,7 +523,7 @@ impl Backend {
*horizontal_alignment,
*vertical_alignment,
*shaping,
- scale_factor,
+ scale_factor * transformation.scale_factor(),
pixels,
clip_mask,
);
@@ -770,10 +770,10 @@ fn into_color(color: Color) -> tiny_skia::Color {
fn into_transform(transformation: Transformation) -> tiny_skia::Transform {
tiny_skia::Transform {
- sx: transformation.scale_x(),
+ sx: transformation.scale_factor(),
kx: 0.0,
ky: 0.0,
- sy: transformation.scale_y(),
+ sy: transformation.scale_factor(),
tx: transformation.translation_x(),
ty: transformation.translation_y(),
}
diff --git a/wgpu/src/backend.rs b/wgpu/src/backend.rs
index 25134d68..e86e52c4 100644
--- a/wgpu/src/backend.rs
+++ b/wgpu/src/backend.rs
@@ -147,8 +147,8 @@ impl Backend {
}
if !layer.meshes.is_empty() {
- let scaled = transformation
- * Transformation::scale(scale_factor, scale_factor);
+ let scaled =
+ transformation * Transformation::scale(scale_factor);
self.triangle_pipeline.prepare(
device,
@@ -161,8 +161,8 @@ impl Backend {
#[cfg(any(feature = "image", feature = "svg"))]
{
if !layer.images.is_empty() {
- let scaled = transformation
- * Transformation::scale(scale_factor, scale_factor);
+ let scaled =
+ transformation * Transformation::scale(scale_factor);
self.image_pipeline.prepare(
device,
diff --git a/wgpu/src/layer.rs b/wgpu/src/layer.rs
index 82e8ba02..4a2e72df 100644
--- a/wgpu/src/layer.rs
+++ b/wgpu/src/layer.rs
@@ -133,7 +133,7 @@ impl<'a> Layer<'a> {
position: *position * transformation,
color: *color,
clip_bounds: *clip_bounds * transformation,
- scale: transformation.scale_y(),
+ scale: transformation.scale_factor(),
});
}
Primitive::Editor {
@@ -149,7 +149,7 @@ impl<'a> Layer<'a> {
position: *position * transformation,
color: *color,
clip_bounds: *clip_bounds * transformation,
- scale: transformation.scale_y(),
+ scale: transformation.scale_factor(),
});
}
Primitive::Text {
@@ -169,7 +169,7 @@ impl<'a> Layer<'a> {
layer.text.push(Text::Cached(text::Cached {
content,
bounds: *bounds * transformation,
- size: *size * transformation.scale_y(),
+ size: *size * transformation.scale_factor(),
line_height: *line_height,
color: *color,
font: *font,