diff options
author | Benjamin Otte <otte@redhat.com> | 2016-12-26 17:04:56 +0100 |
---|---|---|
committer | Benjamin Otte <otte@redhat.com> | 2016-12-26 17:22:01 +0100 |
commit | 599cc995f3532ba85a96d2409ef5589508785faf (patch) | |
tree | df16fc3971a3921ccac1d1830fd8d4375c550b9a | |
parent | 5017c3be65a8f07178f48042170d93000131980b (diff) | |
download | gtk+-599cc995f3532ba85a96d2409ef5589508785faf.tar.gz |
css: Handle repeating gradients with only one offset
Example:
repeating-linear-gradient(red 50%, blue 50%)
Those gradients in Firefox draw a solid image of the last color, so do
the same here.
-rw-r--r-- | gtk/gtkcssimagelinear.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/gtk/gtkcssimagelinear.c b/gtk/gtkcssimagelinear.c index 17318cabb9..5841e1508f 100644 --- a/gtk/gtkcssimagelinear.c +++ b/gtk/gtkcssimagelinear.c @@ -181,6 +181,19 @@ gtk_css_image_linear_snapshot (GtkCssImage *image, length = sqrt (x * x + y * y); gtk_css_image_linear_get_start_end (linear, length, &start, &end); + if (start == end) + { + /* repeating gradients with all color stops sharing the same offset + * get the color of the last color stop */ + GtkCssImageLinearColorStop *stop = &g_array_index (linear->stops, GtkCssImageLinearColorStop, linear->stops->len - 1); + + gtk_snapshot_append_color_node (snapshot, + _gtk_css_rgba_value_get_rgba (stop->color), + &GRAPHENE_RECT_INIT (0, 0, width, height), + "RepeatingLinearGradient<degenerate>"); + return; + } + offset = start; last = -1; stops = g_newa (GskColorStop, linear->stops->len); |