[librsvg/librsvg-2.44] gradient: shorten code



commit 3811063356c1eba382a91314591d0d516c4242de
Author: Paolo Borelli <pborelli gnome org>
Date:   Sat Sep 8 18:36:11 2018 +0200

    gradient: shorten code
    
    Also inline resolve_fallbacks_and_set_pattern

 rsvg_internals/src/gradient.rs | 29 ++++++++++-------------------
 1 file changed, 10 insertions(+), 19 deletions(-)
---
diff --git a/rsvg_internals/src/gradient.rs b/rsvg_internals/src/gradient.rs
index 61c1287c..904f7259 100644
--- a/rsvg_internals/src/gradient.rs
+++ b/rsvg_internals/src/gradient.rs
@@ -675,21 +675,6 @@ impl NodeTrait for NodeGradient {
     }
 }
 
-fn resolve_fallbacks_and_set_pattern(
-    gradient: &Gradient,
-    values: &ComputedValues,
-    draw_ctx: &mut DrawingCtx,
-    opacity: &UnitInterval,
-    bbox: &BoundingBox,
-) {
-    if let Some(r) = bbox.rect {
-        if !r.is_empty() {
-            let resolved = resolve_gradient(gradient, draw_ctx);
-            set_pattern_on_draw_context(&resolved, values, draw_ctx, opacity, bbox)
-        }
-    }
-}
-
 pub fn gradient_resolve_fallbacks_and_set_pattern(
     node: &RsvgNode,
     draw_ctx: &mut DrawingCtx,
@@ -703,11 +688,17 @@ pub fn gradient_resolve_fallbacks_and_set_pattern(
     let mut did_set_gradient = false;
 
     node.with_impl(|node_gradient: &NodeGradient| {
-        let gradient = node_gradient.get_gradient_with_color_stops_from_node(node);
-        let cascaded = node.get_cascaded_values();
-        let values = cascaded.get();
+        if let Some(r) = bbox.rect {
+            if !r.is_empty() {
+                let gradient = node_gradient.get_gradient_with_color_stops_from_node(node);
+                let resolved = resolve_gradient(&gradient, draw_ctx);
+                let cascaded = node.get_cascaded_values();
+                let values = cascaded.get();
+
+                set_pattern_on_draw_context(&resolved, values, draw_ctx, opacity, bbox)
+            }
+        }
 
-        resolve_fallbacks_and_set_pattern(&gradient, &values, draw_ctx, opacity, bbox);
         did_set_gradient = true;
     });
 


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