From aa41d7656e734b5dae3c19dff87afbc74617a67f Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Tue, 24 Oct 2023 02:51:02 +0200 Subject: Apply `Transform` scaling to text primitives --- wgpu/src/text.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'wgpu/src/text.rs') diff --git a/wgpu/src/text.rs b/wgpu/src/text.rs index dca09cb8..4a151073 100644 --- a/wgpu/src/text.rs +++ b/wgpu/src/text.rs @@ -124,11 +124,13 @@ impl Pipeline { vertical_alignment, color, clip_bounds, + scale, ) = match section { Text::Paragraph { position, color, clip_bounds, + scale, .. } => { use crate::core::text::Paragraph as _; @@ -145,12 +147,14 @@ impl Pipeline { paragraph.vertical_alignment(), *color, *clip_bounds, + *scale, ) } Text::Editor { position, color, clip_bounds, + scale, .. } => { use crate::core::text::Editor as _; @@ -167,6 +171,7 @@ impl Pipeline { alignment::Vertical::Top, *color, *clip_bounds, + *scale, ) } Text::Cached(text) => { @@ -186,6 +191,7 @@ impl Pipeline { text.vertical_alignment, text.color, text.clip_bounds, + 1.0, ) } Text::Raw(text) => { @@ -205,6 +211,7 @@ impl Pipeline { alignment::Vertical::Top, text.color, text.clip_bounds, + 1.0, ) } }; @@ -234,7 +241,7 @@ impl Pipeline { buffer, left, top, - scale: scale_factor, + scale: scale * scale_factor, bounds: glyphon::TextBounds { left: clip_bounds.x as i32, top: clip_bounds.y as i32, -- cgit From f4d66486016076bb339a338bc589645119962d1e Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Tue, 24 Oct 2023 05:34:03 +0200 Subject: Introduce `with_transformation` to `Renderer` trait --- wgpu/src/text.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'wgpu/src/text.rs') diff --git a/wgpu/src/text.rs b/wgpu/src/text.rs index 4a151073..cffe57cb 100644 --- a/wgpu/src/text.rs +++ b/wgpu/src/text.rs @@ -1,5 +1,5 @@ use crate::core::alignment; -use crate::core::{Rectangle, Size}; +use crate::core::{Rectangle, Size, Transformation}; use crate::graphics::color; use crate::graphics::text::cache::{self, Cache}; use crate::graphics::text::{font_system, to_color, Editor, Paragraph}; @@ -124,13 +124,13 @@ impl Pipeline { vertical_alignment, color, clip_bounds, - scale, + transformation, ) = match section { Text::Paragraph { position, color, clip_bounds, - scale, + transformation, .. } => { use crate::core::text::Paragraph as _; @@ -147,14 +147,14 @@ impl Pipeline { paragraph.vertical_alignment(), *color, *clip_bounds, - *scale, + *transformation, ) } Text::Editor { position, color, clip_bounds, - scale, + transformation, .. } => { use crate::core::text::Editor as _; @@ -171,7 +171,7 @@ impl Pipeline { alignment::Vertical::Top, *color, *clip_bounds, - *scale, + *transformation, ) } Text::Cached(text) => { @@ -191,7 +191,7 @@ impl Pipeline { text.vertical_alignment, text.color, text.clip_bounds, - 1.0, + Transformation::IDENTITY, ) } Text::Raw(text) => { @@ -211,12 +211,12 @@ impl Pipeline { alignment::Vertical::Top, text.color, text.clip_bounds, - 1.0, + Transformation::IDENTITY, ) } }; - let bounds = bounds * scale_factor; + let bounds = bounds * transformation * scale_factor; let left = match horizontal_alignment { alignment::Horizontal::Left => bounds.x, @@ -241,7 +241,7 @@ impl Pipeline { buffer, left, top, - scale: scale * scale_factor, + scale: scale_factor * transformation.scale_factor(), bounds: glyphon::TextBounds { left: clip_bounds.x as i32, top: clip_bounds.y as i32, -- cgit From d8dffa411b8c1bbee538e3b51aae6f768e293789 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Fri, 2 Feb 2024 02:31:47 +0100 Subject: Transform `clip_bounds` in `wgpu::text` --- wgpu/src/text.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'wgpu/src/text.rs') diff --git a/wgpu/src/text.rs b/wgpu/src/text.rs index cffe57cb..15179ff3 100644 --- a/wgpu/src/text.rs +++ b/wgpu/src/text.rs @@ -234,8 +234,9 @@ impl Pipeline { alignment::Vertical::Bottom => bounds.y - bounds.height, }; - let clip_bounds = - layer_bounds.intersection(&(clip_bounds * scale_factor))?; + let clip_bounds = layer_bounds.intersection( + &(clip_bounds * transformation * scale_factor), + )?; Some(glyphon::TextArea { buffer, -- cgit From b3adf3184594c9bf60e0548a0362d30c512f3966 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Fri, 2 Feb 2024 14:43:04 +0100 Subject: Apply `Transformation` to `RawText` primitives --- wgpu/src/text.rs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'wgpu/src/text.rs') diff --git a/wgpu/src/text.rs b/wgpu/src/text.rs index 15179ff3..6fa1922d 100644 --- a/wgpu/src/text.rs +++ b/wgpu/src/text.rs @@ -109,7 +109,9 @@ impl Pipeline { Some(Allocation::Cache(key)) } - Text::Raw(text) => text.buffer.upgrade().map(Allocation::Raw), + Text::Raw { raw, .. } => { + raw.buffer.upgrade().map(Allocation::Raw) + } }) .collect(); @@ -194,7 +196,10 @@ impl Pipeline { Transformation::IDENTITY, ) } - Text::Raw(text) => { + Text::Raw { + raw, + transformation, + } => { let Some(Allocation::Raw(buffer)) = allocation else { return None; }; @@ -204,14 +209,14 @@ impl Pipeline { ( buffer.as_ref(), Rectangle::new( - text.position, + raw.position, Size::new(width, height), ), alignment::Horizontal::Left, alignment::Vertical::Top, - text.color, - text.clip_bounds, - Transformation::IDENTITY, + raw.color, + raw.clip_bounds, + *transformation, ) } }; -- cgit