[librsvg: 2/13] PositionedSpan::layout - pass the DrawingCtx's transform in the LayoutContext
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 2/13] PositionedSpan::layout - pass the DrawingCtx's transform in the LayoutContext
- Date: Fri, 5 Nov 2021 04:10:04 +0000 (UTC)
commit 5408d368c66f7b2fc9ac3525f29d3bc687866448
Author: Federico Mena Quintero <federico gnome org>
Date: Thu Nov 4 10:22:05 2021 -0600
PositionedSpan::layout - pass the DrawingCtx's transform in the LayoutContext
Do not ask the DrawingCtx directly for the transform; rather, pass it
around in the LayoutContext in case other parts of the text layout
code need it.
Part-of: <https://gitlab.gnome.org/GNOME/librsvg/-/merge_requests/626>
src/text.rs | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
---
diff --git a/src/text.rs b/src/text.rs
index 4e0387f2f..652e7b5b2 100644
--- a/src/text.rs
+++ b/src/text.rs
@@ -28,6 +28,9 @@ use crate::xml::Attributes;
struct LayoutContext {
/// `writing-mode` property from the `<text>` element.
writing_mode: WritingMode,
+
+ /// Current transform in the DrawingCtx.
+ transform: Transform,
}
/// An absolutely-positioned array of `Span`s
@@ -435,8 +438,8 @@ fn compute_text_box(
impl PositionedSpan {
fn layout(
&self,
+ layout_context: &LayoutContext,
acquired_nodes: &mut AcquiredNodes<'_>,
- draw_ctx: &DrawingCtx,
view_params: &ViewParams,
) -> LayoutSpan {
let params = NormalizeParams::new(&self.values, view_params);
@@ -449,7 +452,7 @@ impl PositionedSpan {
let gravity = layout.context().unwrap().gravity();
- let bbox = compute_text_box(&layout, x, y, draw_ctx.get_transform(), gravity);
+ let bbox = compute_text_box(&layout, x, y, layout_context.transform, gravity);
let stroke_paint = self.values.stroke().0.resolve(
acquired_nodes,
@@ -767,6 +770,7 @@ impl Draw for Text {
&mut |an, dc| {
let layout_context = LayoutContext {
writing_mode: values.writing_mode(),
+ transform: dc.get_transform(),
};
let mut x = self.x.to_user(¶ms);
@@ -803,7 +807,7 @@ impl Draw for Text {
let mut layout_spans = Vec::new();
for chunk in &positioned_chunks {
for span in &chunk.spans {
- layout_spans.push(span.layout(an, dc, &view_params));
+ layout_spans.push(span.layout(&layout_context, an, &view_params));
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]