[librsvg: 4/9] gradient: refactor utility function



commit 334a886a3924de7cfcccbd0aafc0e12f0bda7ccb
Author: Paolo Borelli <pborelli gnome org>
Date:   Sat May 25 18:49:56 2019 +0200

    gradient: refactor utility function

 rsvg_internals/src/gradient.rs | 20 ++++++++------------
 1 file changed, 8 insertions(+), 12 deletions(-)
---
diff --git a/rsvg_internals/src/gradient.rs b/rsvg_internals/src/gradient.rs
index 24a567ac..4aa2616a 100644
--- a/rsvg_internals/src/gradient.rs
+++ b/rsvg_internals/src/gradient.rs
@@ -526,9 +526,7 @@ impl PaintSource for NodeGradient {
         draw_ctx: &mut DrawingCtx,
         bbox: &BoundingBox,
     ) -> Result<Option<Self::Source>, RenderingError> {
-        let node_gradient = node.get_impl::<NodeGradient>();
-        let gradient = node_gradient.get_gradient_with_color_stops_from_node(node);
-        let mut result = gradient.clone();
+        let mut result = get_gradient_with_color_stops_from_node(node);
         let mut stack = NodeStack::new();
 
         while !result.is_resolved() {
@@ -540,9 +538,7 @@ impl PaintSource for NodeGradient {
                     return Err(RenderingError::CircularReference);
                 }
 
-                let fallback = a_node
-                    .get_impl::<NodeGradient>()
-                    .get_gradient_with_color_stops_from_node(&a_node);
+                let fallback = get_gradient_with_color_stops_from_node(&a_node);
                 result.resolve_from_fallback(&fallback);
 
                 stack.push(a_node);
@@ -610,6 +606,12 @@ impl PaintSource for NodeGradient {
     }
 }
 
+fn get_gradient_with_color_stops_from_node(node: &RsvgNode) -> Gradient {
+    let mut gradient = node.get_impl::<NodeGradient>().gradient.borrow().clone();
+    gradient.add_color_stops_from_node(node);
+    gradient
+}
+
 pub struct NodeGradient {
     gradient: RefCell<Gradient>,
 }
@@ -632,12 +634,6 @@ impl NodeGradient {
             }),
         }
     }
-
-    fn get_gradient_with_color_stops_from_node(&self, node: &RsvgNode) -> Gradient {
-        let mut gradient = self.gradient.borrow().clone();
-        gradient.add_color_stops_from_node(node);
-        gradient
-    }
 }
 
 impl NodeTrait for NodeGradient {


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