[librsvg: 1/3] draw_text_span() - only do the work if there is stroke or fill paint




commit 4f272461345b698b5ae6a4d33d3c3ba19f08fd7e
Author: Federico Mena Quintero <federico gnome org>
Date:   Mon Oct 4 19:49:50 2021 -0500

    draw_text_span() - only do the work if there is stroke or fill paint
    
    Part-of: <https://gitlab.gnome.org/GNOME/librsvg/-/merge_requests/598>

 src/drawing_ctx.rs | 38 ++++++++++++++++++++------------------
 1 file changed, 20 insertions(+), 18 deletions(-)
---
diff --git a/src/drawing_ctx.rs b/src/drawing_ctx.rs
index 2b074889..a68484fe 100644
--- a/src/drawing_ctx.rs
+++ b/src/drawing_ctx.rs
@@ -1401,38 +1401,40 @@ impl DrawingCtx {
                 for &target in &paint_order.targets {
                     match target {
                         PaintTarget::Fill => {
-                            self.cr.move_to(span.x, span.y);
-
-                            let matrix = self.cr.matrix();
-                            if let Some(rot) = rotation {
-                                self.cr.rotate(rot);
-                            }
-
                             let fill_paint =
                                 span.fill_paint.to_user_space(&bbox, view_params, values);
                             let had_paint_server =
                                 self.set_paint_source(&fill_paint, acquired_nodes)?;
+
                             if had_paint_server {
+                                self.cr.move_to(span.x, span.y);
+
+                                let matrix = self.cr.matrix();
+                                if let Some(rot) = rotation {
+                                    self.cr.rotate(rot);
+                                }
+
                                 pangocairo::functions::update_layout(&self.cr, &span.layout);
                                 pangocairo::functions::show_layout(&self.cr, &span.layout);
-                            }
 
-                            self.cr.set_matrix(matrix);
+                                self.cr.set_matrix(matrix);
+                            }
                         }
 
                         PaintTarget::Stroke => {
-                            self.cr.move_to(span.x, span.y);
-
-                            let matrix = self.cr.matrix();
-                            if let Some(rot) = rotation {
-                                self.cr.rotate(rot);
-                            }
-
                             let stroke_paint =
                                 span.stroke_paint.to_user_space(&bbox, view_params, values);
                             let had_paint_server =
                                 self.set_paint_source(&stroke_paint, acquired_nodes)?;
+
                             if had_paint_server {
+                                self.cr.move_to(span.x, span.y);
+
+                                let matrix = self.cr.matrix();
+                                if let Some(rot) = rotation {
+                                    self.cr.rotate(rot);
+                                }
+
                                 pangocairo::functions::update_layout(&self.cr, &span.layout);
                                 pangocairo::functions::layout_path(&self.cr, &span.layout);
 
@@ -1443,9 +1445,9 @@ impl DrawingCtx {
                                     .with_ink_rect(r);
                                 bbox.insert(&ib);
                                 self.cr.stroke()?;
-                            }
 
-                            self.cr.set_matrix(matrix);
+                                self.cr.set_matrix(matrix);
+                            }
                         }
 
                         PaintTarget::Markers => {}


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