forked from AuroraMiddleware/gtk
rendernodeparser: Split out a function
This commit is contained in:
parent
770e848953
commit
71cb7c2063
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user