[librsvg: 28/31] Pass the StackingContext to draw_shape; don't create it there




commit b68fd53c87a58cdbba66f7ab98c63bf48d3ae644
Author: Federico Mena Quintero <federico gnome org>
Date:   Wed Jun 2 20:33:27 2021 -0500

    Pass the StackingContext to draw_shape; don't create it there

 src/drawing_ctx.rs |  7 ++-----
 src/shapes.rs      | 18 +++++++++++++++---
 2 files changed, 17 insertions(+), 8 deletions(-)
---
diff --git a/src/drawing_ctx.rs b/src/drawing_ctx.rs
index 0f53f7ea..73906269 100644
--- a/src/drawing_ctx.rs
+++ b/src/drawing_ctx.rs
@@ -1196,7 +1196,7 @@ impl DrawingCtx {
         &mut self,
         view_params: &ViewParams,
         shape: &Shape,
-        node: &Node,
+        stacking_ctx: &StackingContext,
         acquired_nodes: &mut AcquiredNodes<'_>,
         values: &ComputedValues,
         clipping: bool,
@@ -1205,11 +1205,8 @@ impl DrawingCtx {
             return Ok(self.empty_bbox());
         }
 
-        let elt = node.borrow_element();
-        let stacking_ctx = StackingContext::new(acquired_nodes, &elt, elt.get_transform(), values);
-
         self.with_discrete_layer(
-            &stacking_ctx,
+            stacking_ctx,
             acquired_nodes,
             values,
             clipping,
diff --git a/src/shapes.rs b/src/shapes.rs
index 54e2558a..d794c846 100644
--- a/src/shapes.rs
+++ b/src/shapes.rs
@@ -11,9 +11,9 @@ use crate::document::AcquiredNodes;
 use crate::drawing_ctx::DrawingCtx;
 use crate::element::{Draw, ElementResult, SetAttributes};
 use crate::error::*;
-use crate::layout::Stroke;
+use crate::layout::{StackingContext, Stroke};
 use crate::length::*;
-use crate::node::{CascadedValues, Node};
+use crate::node::{CascadedValues, Node, NodeBorrow};
 use crate::paint_server::PaintSource;
 use crate::parsers::{optional_comma, Parse, ParseValue};
 use crate::path_builder::{LargeArc, Path as SvgPath, PathBuilder, Sweep};
@@ -104,7 +104,19 @@ macro_rules! impl_draw {
                     clip_rule,
                     shape_rendering,
                 };
-                draw_ctx.draw_shape(&view_params, &shape, node, acquired_nodes, values, clipping)
+
+                let elt = node.borrow_element();
+                let stacking_ctx =
+                    StackingContext::new(acquired_nodes, &elt, elt.get_transform(), values);
+
+                draw_ctx.draw_shape(
+                    &view_params,
+                    &shape,
+                    &stacking_ctx,
+                    acquired_nodes,
+                    values,
+                    clipping,
+                )
             }
         }
     };


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