From 5017c3be65a8f07178f48042170d93000131980b Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Mon, 26 Dec 2016 17:04:01 +0100 Subject: [PATCH] gsk: Insist on ordered color stops I don't want to sort them later for the shader preparation, so make sure they come in ordered. --- gsk/gskrendernodeimpl.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/gsk/gskrendernodeimpl.c b/gsk/gskrendernodeimpl.c index 3cea64c6a4..4e0254625c 100644 --- a/gsk/gskrendernodeimpl.c +++ b/gsk/gskrendernodeimpl.c @@ -321,11 +321,20 @@ gsk_linear_gradient_node_new (const graphene_rect_t *bounds, gsize n_color_stops) { GskLinearGradientNode *self; + gsize i; g_return_val_if_fail (bounds != NULL, NULL); g_return_val_if_fail (start != NULL, NULL); g_return_val_if_fail (end != NULL, NULL); g_return_val_if_fail (color_stops != NULL, NULL); + g_return_val_if_fail (n_color_stops >= 2, NULL); + g_return_val_if_fail (color_stops[0].offset >= 0, NULL); + for (i = 1; i < n_color_stops; i++) + { + g_return_val_if_fail (color_stops[i].offset >= color_stops[i-1].offset, NULL); + + } + g_return_val_if_fail (color_stops[n_color_stops - 1].offset <= 1, NULL); self = (GskLinearGradientNode *) gsk_render_node_new (&GSK_LINEAR_GRADIENT_NODE_CLASS, sizeof (GskColorStop) * n_color_stops); @@ -347,11 +356,20 @@ gsk_repeating_linear_gradient_node_new (const graphene_rect_t *bounds, gsize n_color_stops) { GskLinearGradientNode *self; + gsize i; g_return_val_if_fail (bounds != NULL, NULL); g_return_val_if_fail (start != NULL, NULL); g_return_val_if_fail (end != NULL, NULL); g_return_val_if_fail (color_stops != NULL, NULL); + g_return_val_if_fail (n_color_stops >= 2, NULL); + g_return_val_if_fail (color_stops[0].offset >= 0, NULL); + for (i = 1; i < n_color_stops; i++) + { + g_return_val_if_fail (color_stops[i].offset >= color_stops[i-1].offset, NULL); + + } + g_return_val_if_fail (color_stops[n_color_stops - 1].offset <= 1, NULL); self = (GskLinearGradientNode *) gsk_render_node_new (&GSK_REPEATING_LINEAR_GRADIENT_NODE_CLASS, sizeof (GskColorStop) * n_color_stops);