[gtk/wip/otte/conic: 1/4] rendernodeparser: Split out a function




commit 71cb7c2063a85d4f8d5424e466319f30be318913
Author: Benjamin Otte <otte redhat com>
Date:   Wed Dec 2 21:48:35 2020 +0100

    rendernodeparser: Split out a function

 gsk/gskrendernodeparser.c | 61 ++++++++++++++++++++++-------------------------
 1 file changed, 28 insertions(+), 33 deletions(-)
---
diff --git a/gsk/gskrendernodeparser.c b/gsk/gskrendernodeparser.c
index fd62b6d4c3..61f94853a1 100644
--- a/gsk/gskrendernodeparser.c
+++ b/gsk/gskrendernodeparser.c
@@ -2184,6 +2184,30 @@ append_node_param (Printer       *p,
   render_node_print (p, node);
 }
 
+static void
+append_stops_param (Printer            *p,
+                    const char         *param_name,
+                    const GskColorStop *stops,
+                    gsize               n_stops)
+{
+  gsize i;
+
+  _indent (p);
+  g_string_append (p->str, param_name);
+  g_string_append (p->str, ": ");
+
+  for (i = 0; i < n_stops; i ++)
+    {
+      if (i > 0)
+        g_string_append (p->str, ", ");
+
+      string_append_double (p->str, stops[i].offset);
+      g_string_append_c (p->str, ' ');
+      append_rgba (p->str, &stops[i].color);
+    }
+  g_string_append (p->str, ";\n");
+}
+
 static cairo_status_t
 cairo_write_array (void                *closure,
                    const unsigned char *data,
@@ -2294,10 +2318,6 @@ render_node_print (Printer       *p,
     case GSK_REPEATING_LINEAR_GRADIENT_NODE:
     case GSK_LINEAR_GRADIENT_NODE:
       {
-        const gsize n_stops = gsk_linear_gradient_node_get_n_color_stops (node);
-        const GskColorStop *stops = gsk_linear_gradient_node_get_color_stops (node, NULL);
-        gsize i;
-
         if (gsk_render_node_get_node_type (node) == GSK_REPEATING_LINEAR_GRADIENT_NODE)
           start_node (p, "repeating-linear-gradient");
         else
@@ -2306,19 +2326,8 @@ render_node_print (Printer       *p,
         append_rect_param (p, "bounds", &node->bounds);
         append_point_param (p, "end", gsk_linear_gradient_node_get_end (node));
         append_point_param (p, "start", gsk_linear_gradient_node_get_start (node));
-
-        _indent (p);
-        g_string_append (p->str, "stops: ");
-        for (i = 0; i < n_stops; i ++)
-          {
-            if (i > 0)
-              g_string_append (p->str, ", ");
-
-            string_append_double (p->str, stops[i].offset);
-            g_string_append_c (p->str, ' ');
-            append_rgba (p->str, &stops[i].color);
-          }
-        g_string_append (p->str, ";\n");
+        append_stops_param (p, "stops", gsk_linear_gradient_node_get_color_stops (node, NULL),
+                                        gsk_linear_gradient_node_get_n_color_stops (node));
 
         end_node (p);
       }
@@ -2327,10 +2336,6 @@ render_node_print (Printer       *p,
     case GSK_REPEATING_RADIAL_GRADIENT_NODE:
     case GSK_RADIAL_GRADIENT_NODE:
       {
-        const gsize n_stops = gsk_radial_gradient_node_get_n_color_stops (node);
-        const GskColorStop *stops = gsk_radial_gradient_node_get_color_stops (node, NULL);
-        gsize i;
-
         if (gsk_render_node_get_node_type (node) == GSK_REPEATING_RADIAL_GRADIENT_NODE)
           start_node (p, "repeating-radial-gradient");
         else
@@ -2343,18 +2348,8 @@ render_node_print (Printer       *p,
         append_float_param (p, "start", gsk_radial_gradient_node_get_start (node), 0.0f);
         append_float_param (p, "end", gsk_radial_gradient_node_get_end (node), 1.0f);
 
-        _indent (p);
-        g_string_append (p->str, "stops: ");
-        for (i = 0; i < n_stops; i ++)
-          {
-            if (i > 0)
-              g_string_append (p->str, ", ");
-
-            string_append_double (p->str, stops[i].offset);
-            g_string_append_c (p->str, ' ');
-            append_rgba (p->str, &stops[i].color);
-          }
-        g_string_append (p->str, ";\n");
+        append_stops_param (p, "stops", gsk_radial_gradient_node_get_color_stops (node, NULL),
+                                        gsk_radial_gradient_node_get_n_color_stops (node));
 
         end_node (p);
       }


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