[librsvg: 19/45] shapes.rs: Use a session for logging where we have a DrawingCtx




commit 05adeaec2d5cd3b6580819c1a72cd02ae40a71f4
Author: Federico Mena Quintero <federico gnome org>
Date:   Mon Aug 22 19:07:22 2022 -0500

    shapes.rs: Use a session for logging where we have a DrawingCtx
    
    Still to change is the implementation of Path::set_attributes() - but
    we don't have a DrawingCtx at that stage.  Maybe we need to pass the
    session to all the set_attributes() functions.
    
    Part-of: <https://gitlab.gnome.org/GNOME/librsvg/-/merge_requests/731>

 src/shapes.rs | 22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)
---
diff --git a/src/shapes.rs b/src/shapes.rs
index 35716c93e..7cc8c5bba 100644
--- a/src/shapes.rs
+++ b/src/shapes.rs
@@ -18,6 +18,7 @@ use crate::node::{CascadedValues, Node, NodeBorrow};
 use crate::parsers::{optional_comma, Parse, ParseValue};
 use crate::path_builder::{LargeArc, Path as SvgPath, PathBuilder, Sweep};
 use crate::properties::ComputedValues;
+use crate::session::Session;
 use crate::xml::Attributes;
 
 #[derive(PartialEq)]
@@ -86,10 +87,15 @@ macro_rules! impl_draw {
                 let marker_mid_node;
                 let marker_end_node;
 
+                let session = draw_ctx.session();
+
                 if shape_def.markers == Markers::Yes {
-                    marker_start_node = acquire_marker(acquired_nodes, &values.marker_start().0);
-                    marker_mid_node = acquire_marker(acquired_nodes, &values.marker_mid().0);
-                    marker_end_node = acquire_marker(acquired_nodes, &values.marker_end().0);
+                    marker_start_node =
+                        acquire_marker(session, acquired_nodes, &values.marker_start().0);
+                    marker_mid_node =
+                        acquire_marker(session, acquired_nodes, &values.marker_mid().0);
+                    marker_end_node =
+                        acquire_marker(session, acquired_nodes, &values.marker_end().0);
                 } else {
                     marker_start_node = None;
                     marker_mid_node = None;
@@ -146,12 +152,16 @@ macro_rules! impl_draw {
     };
 }
 
-fn acquire_marker(acquired_nodes: &mut AcquiredNodes<'_>, iri: &Iri) -> Option<Node> {
+fn acquire_marker(
+    session: &Session,
+    acquired_nodes: &mut AcquiredNodes<'_>,
+    iri: &Iri,
+) -> Option<Node> {
     iri.get().and_then(|id| {
         acquired_nodes
             .acquire(id)
             .map_err(|e| {
-                rsvg_log!("cannot render marker: {}", e);
+                rsvg_log_session!(session, "cannot render marker: {}", e);
             })
             .ok()
             .and_then(|acquired| {
@@ -160,7 +170,7 @@ fn acquire_marker(acquired_nodes: &mut AcquiredNodes<'_>, iri: &Iri) -> Option<N
                 if is_element_of_type!(node, Marker) {
                     Some(node.clone())
                 } else {
-                    rsvg_log!("{} is not a marker element", id);
+                    rsvg_log_session!(session, "{} is not a marker element", id);
                     None
                 }
             })


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