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.
This commit is contained in:
Benjamin Otte 2016-12-26 17:04:01 +01:00
parent 3a79b17309
commit 5017c3be65

View File

@ -321,11 +321,20 @@ gsk_linear_gradient_node_new (const graphene_rect_t *bounds,
gsize n_color_stops) gsize n_color_stops)
{ {
GskLinearGradientNode *self; GskLinearGradientNode *self;
gsize i;
g_return_val_if_fail (bounds != NULL, NULL); g_return_val_if_fail (bounds != NULL, NULL);
g_return_val_if_fail (start != NULL, NULL); g_return_val_if_fail (start != NULL, NULL);
g_return_val_if_fail (end != NULL, NULL); g_return_val_if_fail (end != NULL, NULL);
g_return_val_if_fail (color_stops != 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); 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) gsize n_color_stops)
{ {
GskLinearGradientNode *self; GskLinearGradientNode *self;
gsize i;
g_return_val_if_fail (bounds != NULL, NULL); g_return_val_if_fail (bounds != NULL, NULL);
g_return_val_if_fail (start != NULL, NULL); g_return_val_if_fail (start != NULL, NULL);
g_return_val_if_fail (end != NULL, NULL); g_return_val_if_fail (end != NULL, NULL);
g_return_val_if_fail (color_stops != 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); self = (GskLinearGradientNode *) gsk_render_node_new (&GSK_REPEATING_LINEAR_GRADIENT_NODE_CLASS, sizeof (GskColorStop) * n_color_stops);