[librsvg] gradient: shorten code
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg] gradient: shorten code
- Date: Wed, 12 Sep 2018 11:54:52 +0000 (UTC)
commit 998f0a920823a50e9fcec812ca2943fa2fb767b5
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 6ab3ece8..b2892e81 100644
--- a/rsvg_internals/src/gradient.rs
+++ b/rsvg_internals/src/gradient.rs
@@ -677,21 +677,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,
@@ -705,11 +690,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]