[librsvg: 11/13] Store the element_name in StackingContext




commit ec8026786120e07906f2a6587a5f9d1e8b53b167
Author: Federico Mena Quintero <federico gnome org>
Date:   Tue May 11 17:54:54 2021 -0500

    Store the element_name in StackingContext
    
    Mainly this lets us avoid passing a `node` argument to with_discrete_layer().

 src/drawing_ctx.rs | 11 +----------
 src/layout.rs      |  4 ++++
 src/marker.rs      |  1 -
 src/structure.rs   |  4 ----
 src/text.rs        |  1 -
 5 files changed, 5 insertions(+), 16 deletions(-)
---
diff --git a/src/drawing_ctx.rs b/src/drawing_ctx.rs
index e943ea50..abadf400 100644
--- a/src/drawing_ctx.rs
+++ b/src/drawing_ctx.rs
@@ -576,7 +576,6 @@ impl DrawingCtx {
 
             let res = mask_draw_ctx.with_discrete_layer(
                 &stacking_ctx,
-                mask_node,
                 acquired_nodes,
                 values,
                 false,
@@ -599,7 +598,6 @@ impl DrawingCtx {
     pub fn with_discrete_layer(
         &mut self,
         stacking_ctx: &StackingContext,
-        node: &Node,
         acquired_nodes: &mut AcquiredNodes<'_>,
         values: &ComputedValues,
         clipping: bool,
@@ -673,8 +671,6 @@ impl DrawingCtx {
 
                 cr.set_matrix(affines.for_temporary_surface.into());
 
-                let node_name = format!("{}", node);
-
                 let (source_surface, mut res, bbox) = {
                     let mut temporary_draw_ctx = saved_cr.draw_ctx.nested(cr);
 
@@ -699,7 +695,7 @@ impl DrawingCtx {
                             surface_to_filter,
                             &stacking_ctx.filter,
                             acquired_nodes,
-                            &node_name,
+                            &stacking_ctx.element_name,
                             values,
                             bbox,
                         )?,
@@ -986,7 +982,6 @@ impl DrawingCtx {
 
                     dc.with_discrete_layer(
                         &stacking_ctx,
-                        &pattern.node_with_children,
                         acquired_nodes,
                         pattern_values,
                         false,
@@ -1169,7 +1164,6 @@ impl DrawingCtx {
 
         self.with_discrete_layer(
             &stacking_ctx,
-            node,
             acquired_nodes,
             values,
             clipping,
@@ -1282,7 +1276,6 @@ impl DrawingCtx {
 
         self.with_discrete_layer(
             &stacking_ctx,
-            node,
             acquired_nodes,
             values,
             clipping,
@@ -1598,7 +1591,6 @@ impl DrawingCtx {
 
             self.with_discrete_layer(
                 &stacking_ctx,
-                node,
                 acquired_nodes,
                 values,
                 clipping,
@@ -1631,7 +1623,6 @@ impl DrawingCtx {
 
             self.with_discrete_layer(
                 &stacking_ctx,
-                node,
                 acquired_nodes,
                 values,
                 clipping,
diff --git a/src/layout.rs b/src/layout.rs
index ee520b4f..43009b9f 100644
--- a/src/layout.rs
+++ b/src/layout.rs
@@ -24,6 +24,7 @@ use crate::unit_interval::UnitInterval;
 /// Here we store all the parameters that may lead to the decision to actually
 /// render an element as an isolated group.
 pub struct StackingContext {
+    pub element_name: String,
     pub transform: Transform,
     pub opacity: Opacity,
     pub filter: Filter,
@@ -37,6 +38,8 @@ impl StackingContext {
         transform: Transform,
         values: &ComputedValues,
     ) -> StackingContext {
+        let element_name = format!("{}", element);
+
         let opacity;
         let filter;
 
@@ -82,6 +85,7 @@ impl StackingContext {
         });
 
         StackingContext {
+            element_name,
             transform,
             opacity,
             filter,
diff --git a/src/marker.rs b/src/marker.rs
index b3b5eb75..25f21fbf 100644
--- a/src/marker.rs
+++ b/src/marker.rs
@@ -165,7 +165,6 @@ impl Marker {
 
         draw_ctx.with_discrete_layer(
             &stacking_ctx,
-            node,
             acquired_nodes,
             values,
             clipping,
diff --git a/src/structure.rs b/src/structure.rs
index 2f390cc4..47fc9de5 100644
--- a/src/structure.rs
+++ b/src/structure.rs
@@ -39,7 +39,6 @@ impl Draw for Group {
 
         draw_ctx.with_discrete_layer(
             &stacking_ctx,
-            node,
             acquired_nodes,
             values,
             clipping,
@@ -81,7 +80,6 @@ impl Draw for Switch {
 
         draw_ctx.with_discrete_layer(
             &stacking_ctx,
-            node,
             acquired_nodes,
             values,
             clipping,
@@ -259,7 +257,6 @@ impl Draw for Svg {
 
         draw_ctx.with_discrete_layer(
             &stacking_ctx,
-            node,
             acquired_nodes,
             values,
             clipping,
@@ -511,7 +508,6 @@ impl Draw for Link {
 
         draw_ctx.with_discrete_layer(
             &stacking_ctx,
-            node,
             acquired_nodes,
             values,
             clipping,
diff --git a/src/text.rs b/src/text.rs
index d72a54fe..71b52e5b 100644
--- a/src/text.rs
+++ b/src/text.rs
@@ -498,7 +498,6 @@ impl Draw for Text {
 
         draw_ctx.with_discrete_layer(
             &stacking_ctx,
-            node,
             acquired_nodes,
             values,
             clipping,


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