[librsvg: 12/15] Pre-compute all the layout::TextSpan instead of doing them one by one




commit df8e4258da4353a18234ebb347230b71994fa50e
Author: Federico Mena Quintero <federico gnome org>
Date:   Mon Oct 18 13:40:59 2021 -0500

    Pre-compute all the layout::TextSpan instead of doing them one by one
    
    This will let us have a full layout::Text object.
    
    Part-of: <https://gitlab.gnome.org/GNOME/librsvg/-/merge_requests/613>

 src/text.rs | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
---
diff --git a/src/text.rs b/src/text.rs
index 400c0320..06c67808 100644
--- a/src/text.rs
+++ b/src/text.rs
@@ -686,19 +686,22 @@ impl Draw for Text {
                     positioned_chunks.push(positioned);
                 }
 
-                let mut bbox = dc.empty_bbox();
-
                 let view_params = dc.get_view_params();
 
+                let mut layout_spans = Vec::new();
                 for chunk in &positioned_chunks {
                     for span in &chunk.spans {
-                        let layout_span = span.layout(an, dc, &view_params, chunk.link.clone());
-                        let span_bbox = dc.draw_text_span(&layout_span, an, clipping)?;
-
-                        bbox.insert(&span_bbox);
+                        layout_spans.push(span.layout(an, dc, &view_params, chunk.link.clone()));
                     }
                 }
 
+                let mut bbox = dc.empty_bbox();
+
+                for layout_span in layout_spans {
+                    let span_bbox = dc.draw_text_span(&layout_span, an, clipping)?;
+                    bbox.insert(&span_bbox);
+                }
+
                 Ok(bbox)
             },
         )


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]