[librsvg: 25/45] layout.rs: Use a session for logging




commit 5300bb66d4901ff50b41432c7b5a8ce967613687
Author: Federico Mena Quintero <federico gnome org>
Date:   Tue Aug 23 12:24:21 2022 -0500

    layout.rs: Use a session for logging
    
    This involves passing a Session down to StackingContext::new()
    
    Part-of: <https://gitlab.gnome.org/GNOME/librsvg/-/merge_requests/731>

 src/drawing_ctx.rs | 20 ++++++++++++++++----
 src/image.rs       |  8 +++++++-
 src/layout.rs      | 11 ++++++++---
 src/marker.rs      |  3 ++-
 src/shapes.rs      |  9 +++++++--
 src/structure.rs   | 25 ++++++++++++++++++++++---
 src/text.rs        |  8 +++++++-
 7 files changed, 69 insertions(+), 15 deletions(-)
---
diff --git a/src/drawing_ctx.rs b/src/drawing_ctx.rs
index 9193d1429..0342cfb51 100644
--- a/src/drawing_ctx.rs
+++ b/src/drawing_ctx.rs
@@ -654,8 +654,13 @@ impl DrawingCtx {
 
             let mut mask_draw_ctx = self.nested(mask_cr);
 
-            let stacking_ctx =
-                StackingContext::new(acquired_nodes, &mask_element, Transform::identity(), values);
+            let stacking_ctx = StackingContext::new(
+                self.session(),
+                acquired_nodes,
+                &mask_element,
+                Transform::identity(),
+                values,
+            );
 
             let res = mask_draw_ctx.with_discrete_layer(
                 &stacking_ctx,
@@ -1111,6 +1116,7 @@ impl DrawingCtx {
                     let elt = pattern_node.borrow_element();
 
                     let stacking_ctx = StackingContext::new(
+                        self.session(),
                         acquired_nodes,
                         &elt,
                         Transform::identity(),
@@ -1694,8 +1700,13 @@ impl DrawingCtx {
                 None
             };
 
-            let stacking_ctx =
-                StackingContext::new(acquired_nodes, &use_element, Transform::identity(), values);
+            let stacking_ctx = StackingContext::new(
+                self.session(),
+                acquired_nodes,
+                &use_element,
+                Transform::identity(),
+                values,
+            );
 
             self.with_discrete_layer(
                 &stacking_ctx,
@@ -1728,6 +1739,7 @@ impl DrawingCtx {
             // otherwise the referenced node is not a <symbol>; process it generically
 
             let stacking_ctx = StackingContext::new(
+                self.session(),
                 acquired_nodes,
                 &use_element,
                 Transform::new_translate(use_rect.x0, use_rect.y0),
diff --git a/src/image.rs b/src/image.rs
index b825ef342..a8c3ab93a 100644
--- a/src/image.rs
+++ b/src/image.rs
@@ -97,7 +97,13 @@ impl Draw for Image {
         };
 
         let elt = node.borrow_element();
-        let stacking_ctx = StackingContext::new(acquired_nodes, &elt, values.transform(), values);
+        let stacking_ctx = StackingContext::new(
+            draw_ctx.session(),
+            acquired_nodes,
+            &elt,
+            values.transform(),
+            values,
+        );
 
         draw_ctx.draw_image(&image, &stacking_ctx, acquired_nodes, values, clipping)
     }
diff --git a/src/layout.rs b/src/layout.rs
index f68eb1cf5..c67164a45 100644
--- a/src/layout.rs
+++ b/src/layout.rs
@@ -21,6 +21,7 @@ use crate::properties::{
     TextDecoration, TextRendering, UnicodeBidi, XmlLang,
 };
 use crate::rect::Rect;
+use crate::session::Session;
 use crate::surface_utils::shared_surface::SharedImageSurface;
 use crate::transform::Transform;
 use crate::unit_interval::UnitInterval;
@@ -137,6 +138,7 @@ pub struct FontProperties {
 
 impl StackingContext {
     pub fn new(
+        session: &Session,
         acquired_nodes: &mut AcquiredNodes<'_>,
         element: &Element,
         transform: Transform,
@@ -189,7 +191,8 @@ impl StackingContext {
                     Element::Mask(_) => Some(node.clone()),
 
                     _ => {
-                        rsvg_log!(
+                        rsvg_log_session!(
+                            session,
                             "element {} references \"{}\" which is not a mask",
                             element,
                             mask_id
@@ -199,7 +202,8 @@ impl StackingContext {
                     }
                 }
             } else {
-                rsvg_log!(
+                rsvg_log_session!(
+                    session,
                     "element {} references nonexistent mask \"{}\"",
                     element,
                     mask_id
@@ -227,13 +231,14 @@ impl StackingContext {
     }
 
     pub fn new_with_link(
+        session: &Session,
         acquired_nodes: &mut AcquiredNodes<'_>,
         element: &Element,
         transform: Transform,
         values: &ComputedValues,
         link_target: Option<String>,
     ) -> StackingContext {
-        let mut ctx = Self::new(acquired_nodes, element, transform, values);
+        let mut ctx = Self::new(session, acquired_nodes, element, transform, values);
         ctx.link_target = link_target;
         ctx
     }
diff --git a/src/marker.rs b/src/marker.rs
index 5acab183f..87c0135f4 100644
--- a/src/marker.rs
+++ b/src/marker.rs
@@ -184,7 +184,8 @@ impl Marker {
         };
 
         let elt = node.borrow_element();
-        let stacking_ctx = StackingContext::new(acquired_nodes, &elt, transform, values);
+        let stacking_ctx =
+            StackingContext::new(draw_ctx.session(), acquired_nodes, &elt, transform, values);
 
         draw_ctx.with_discrete_layer(
             &stacking_ctx,
diff --git a/src/shapes.rs b/src/shapes.rs
index b617da9e8..d7a161b4c 100644
--- a/src/shapes.rs
+++ b/src/shapes.rs
@@ -138,8 +138,13 @@ macro_rules! impl_draw {
                 };
 
                 let elt = node.borrow_element();
-                let stacking_ctx =
-                    StackingContext::new(acquired_nodes, &elt, values.transform(), values);
+                let stacking_ctx = StackingContext::new(
+                    draw_ctx.session(),
+                    acquired_nodes,
+                    &elt,
+                    values.transform(),
+                    values,
+                );
 
                 draw_ctx.draw_shape(
                     &view_params,
diff --git a/src/structure.rs b/src/structure.rs
index 8fb48c1be..da0457284 100644
--- a/src/structure.rs
+++ b/src/structure.rs
@@ -36,7 +36,13 @@ impl Draw for Group {
         let values = cascaded.get();
 
         let elt = node.borrow_element();
-        let stacking_ctx = StackingContext::new(acquired_nodes, &elt, values.transform(), values);
+        let stacking_ctx = StackingContext::new(
+            draw_ctx.session(),
+            acquired_nodes,
+            &elt,
+            values.transform(),
+            values,
+        );
 
         draw_ctx.with_discrete_layer(
             &stacking_ctx,
@@ -77,7 +83,13 @@ impl Draw for Switch {
         let values = cascaded.get();
 
         let elt = node.borrow_element();
-        let stacking_ctx = StackingContext::new(acquired_nodes, &elt, values.transform(), values);
+        let stacking_ctx = StackingContext::new(
+            draw_ctx.session(),
+            acquired_nodes,
+            &elt,
+            values.transform(),
+            values,
+        );
 
         draw_ctx.with_discrete_layer(
             &stacking_ctx,
@@ -279,7 +291,13 @@ impl Draw for Svg {
         let values = cascaded.get();
 
         let elt = node.borrow_element();
-        let stacking_ctx = StackingContext::new(acquired_nodes, &elt, values.transform(), values);
+        let stacking_ctx = StackingContext::new(
+            draw_ctx.session(),
+            acquired_nodes,
+            &elt,
+            values.transform(),
+            values,
+        );
 
         draw_ctx.with_discrete_layer(
             &stacking_ctx,
@@ -575,6 +593,7 @@ impl Draw for Link {
         };
 
         let stacking_ctx = StackingContext::new_with_link(
+            draw_ctx.session(),
             acquired_nodes,
             &elt,
             values.transform(),
diff --git a/src/text.rs b/src/text.rs
index b4f77e3b1..dc4f65e72 100644
--- a/src/text.rs
+++ b/src/text.rs
@@ -762,7 +762,13 @@ impl Draw for Text {
 
         let elt = node.borrow_element();
 
-        let stacking_ctx = StackingContext::new(acquired_nodes, &elt, values.transform(), values);
+        let stacking_ctx = StackingContext::new(
+            draw_ctx.session(),
+            acquired_nodes,
+            &elt,
+            values.transform(),
+            values,
+        );
 
         draw_ctx.with_discrete_layer(
             &stacking_ctx,


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