[librsvg: 7/13] Pass the DrawingCtx's current transform to the draw_fn callback of with_discrete_layer()




commit 7b117d2b30123c59aeb584c5898b1dee2a3a4081
Author: Federico Mena Quintero <federico gnome org>
Date:   Thu Nov 4 20:14:02 2021 -0600

    Pass the DrawingCtx's current transform to the draw_fn callback of with_discrete_layer()
    
    It is not used yet, but text.rs will use it instead of asking draw_ctx.get_transform().
    
    Part-of: <https://gitlab.gnome.org/GNOME/librsvg/-/merge_requests/626>

 src/drawing_ctx.rs | 26 +++++++++++++++++---------
 src/marker.rs      |  2 +-
 src/structure.rs   |  8 ++++----
 src/text.rs        |  2 +-
 4 files changed, 23 insertions(+), 15 deletions(-)
---
diff --git a/src/drawing_ctx.rs b/src/drawing_ctx.rs
index 59d8f0e03..8bbed0fb9 100644
--- a/src/drawing_ctx.rs
+++ b/src/drawing_ctx.rs
@@ -652,7 +652,7 @@ impl DrawingCtx {
                 values,
                 false,
                 None,
-                &mut |an, dc| mask_node.draw_children(an, &cascaded, dc, false),
+                &mut |an, dc, _transform| mask_node.draw_children(an, &cascaded, dc, false),
             );
 
             res?;
@@ -680,6 +680,7 @@ impl DrawingCtx {
         draw_fn: &mut dyn FnMut(
             &mut AcquiredNodes<'_>,
             &mut DrawingCtx,
+            &Transform,
         ) -> Result<BoundingBox, RenderingError>,
     ) -> Result<BoundingBox, RenderingError> {
         if !stacking_ctx.transform.is_invertible() {
@@ -696,7 +697,8 @@ impl DrawingCtx {
         self.cr.transform(stacking_ctx.transform.into());
 
         let res = if clipping {
-            draw_fn(acquired_nodes, self)
+            let current_transform = self.get_transform();
+            draw_fn(acquired_nodes, self, &current_transform)
         } else {
             with_saved_cr(&self.cr.clone(), || {
                 if let Some(ref link_target) = stacking_ctx.link_target {
@@ -753,7 +755,12 @@ impl DrawingCtx {
 
                         // Draw!
 
-                        let res = draw_fn(acquired_nodes, &mut temporary_draw_ctx);
+                        let temporary_transform = temporary_draw_ctx.get_transform();
+                        let res = draw_fn(
+                            acquired_nodes,
+                            &mut temporary_draw_ctx,
+                            &temporary_transform,
+                        );
 
                         let bbox = if let Ok(ref bbox) = res {
                             *bbox
@@ -880,7 +887,8 @@ impl DrawingCtx {
 
                     res
                 } else {
-                    draw_fn(acquired_nodes, self)
+                    let current_transform = self.get_transform();
+                    draw_fn(acquired_nodes, self, &current_transform)
                 };
 
                 if stacking_ctx.link_target.is_some() {
@@ -1094,7 +1102,7 @@ impl DrawingCtx {
                         pattern_values,
                         false,
                         None,
-                        &mut |an, dc| {
+                        &mut |an, dc, _transform| {
                             pattern.node_with_children.draw_children(
                                 an,
                                 &pattern_cascaded,
@@ -1231,7 +1239,7 @@ impl DrawingCtx {
             values,
             clipping,
             None,
-            &mut |an, dc| {
+            &mut |an, dc, _transform| {
                 let cr = dc.cr.clone();
                 let transform = dc.get_transform();
                 let mut path_helper =
@@ -1349,7 +1357,7 @@ impl DrawingCtx {
                 values,
                 clipping,
                 None,
-                &mut |_an, dc| {
+                &mut |_an, dc, _transform| {
                     with_saved_cr(&dc.cr.clone(), || {
                         if let Some(_params) =
                             dc.push_new_viewport(Some(vbox), image.rect, image.aspect, clip_mode)
@@ -1695,7 +1703,7 @@ impl DrawingCtx {
                 values,
                 clipping,
                 None,
-                &mut |an, dc| {
+                &mut |an, dc, _transform| {
                     let _params = dc.push_new_viewport(
                         symbol.get_viewbox(),
                         use_rect,
@@ -1732,7 +1740,7 @@ impl DrawingCtx {
                 values,
                 clipping,
                 None,
-                &mut |an, dc| {
+                &mut |an, dc, _transform| {
                     child.draw(
                         an,
                         &CascadedValues::new_from_values(
diff --git a/src/marker.rs b/src/marker.rs
index c0c37a6b1..4fcf87e81 100644
--- a/src/marker.rs
+++ b/src/marker.rs
@@ -192,7 +192,7 @@ impl Marker {
             values,
             clipping,
             clip,
-            &mut |an, dc| node.draw_children(an, &cascaded, dc, clipping),
+            &mut |an, dc, _transform| node.draw_children(an, &cascaded, dc, clipping),
         )
     }
 }
diff --git a/src/structure.rs b/src/structure.rs
index f3e5477df..3fd90a407 100644
--- a/src/structure.rs
+++ b/src/structure.rs
@@ -43,7 +43,7 @@ impl Draw for Group {
             values,
             clipping,
             None,
-            &mut |an, dc| node.draw_children(an, cascaded, dc, clipping),
+            &mut |an, dc, _transform| node.draw_children(an, cascaded, dc, clipping),
         )
     }
 }
@@ -84,7 +84,7 @@ impl Draw for Switch {
             values,
             clipping,
             None,
-            &mut |an, dc| {
+            &mut |an, dc, _transform| {
                 if let Some(child) = node.children().filter(|c| c.is_element()).find(|c| {
                     let elt = c.borrow_element();
                     elt.get_cond(dc.user_language()) && !elt.is_in_error()
@@ -276,7 +276,7 @@ impl Draw for Svg {
             values,
             clipping,
             None,
-            &mut |an, dc| {
+            &mut |an, dc, _transform| {
                 let _params = self.push_viewport(node, cascaded, dc);
                 node.draw_children(an, cascaded, dc, clipping)
             },
@@ -575,7 +575,7 @@ impl Draw for Link {
             values,
             clipping,
             None,
-            &mut |an, dc| node.draw_children(an, &cascaded, dc, clipping),
+            &mut |an, dc, _transform| node.draw_children(an, &cascaded, dc, clipping),
         )
     }
 }
diff --git a/src/text.rs b/src/text.rs
index cce9c7424..33ac8c331 100644
--- a/src/text.rs
+++ b/src/text.rs
@@ -765,7 +765,7 @@ impl Draw for Text {
             values,
             clipping,
             None,
-            &mut |an, dc| {
+            &mut |an, dc, _transform| {
                 let layout_context = LayoutContext {
                     writing_mode: values.writing_mode(),
                     transform: dc.get_transform(),


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