mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2025-01-02 17:00:19 +00:00
cssimagelinear: Don't call get_start_end if !repeating
This makes it clear that the !repeating case is easier.
This commit is contained in:
parent
59111d100f
commit
c427c2b22a
@ -31,7 +31,7 @@
|
||||
G_DEFINE_TYPE (GtkCssImageLinear, _gtk_css_image_linear, GTK_TYPE_CSS_IMAGE)
|
||||
|
||||
static void
|
||||
gtk_css_image_linear_get_start_end (GtkCssImageLinear *linear,
|
||||
gtk_css_image_linear_get_repeating_start_end (GtkCssImageLinear *linear,
|
||||
double length,
|
||||
double *start,
|
||||
double *end)
|
||||
@ -40,8 +40,8 @@ gtk_css_image_linear_get_start_end (GtkCssImageLinear *linear,
|
||||
double pos;
|
||||
guint i;
|
||||
|
||||
if (linear->repeating)
|
||||
{
|
||||
g_assert (linear->repeating);
|
||||
|
||||
stop = &g_array_index (linear->stops, GtkCssImageLinearColorStop, 0);
|
||||
if (stop->offset == NULL)
|
||||
*start = 0;
|
||||
@ -64,12 +64,6 @@ gtk_css_image_linear_get_start_end (GtkCssImageLinear *linear,
|
||||
|
||||
if (stop->offset == NULL)
|
||||
*end = MAX (*end, 1.0);
|
||||
}
|
||||
else
|
||||
{
|
||||
*start = 0;
|
||||
*end = 1;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
@ -188,19 +182,28 @@ gtk_css_image_linear_snapshot (GtkCssImage *image,
|
||||
&x, &y,
|
||||
&length);
|
||||
|
||||
gtk_css_image_linear_get_start_end (linear, length, &start, &end);
|
||||
if (linear->repeating)
|
||||
{
|
||||
gtk_css_image_linear_get_repeating_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);
|
||||
GtkCssImageLinearColorStop *stop = &g_array_index (linear->stops, GtkCssImageLinearColorStop,
|
||||
linear->stops->len - 1);
|
||||
|
||||
gtk_snapshot_append_color (snapshot,
|
||||
_gtk_css_rgba_value_get_rgba (stop->color),
|
||||
&GRAPHENE_RECT_INIT (0, 0, width, height));
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
start = 0;
|
||||
end = 1;
|
||||
}
|
||||
|
||||
offset = start;
|
||||
last = -1;
|
||||
|
Loading…
Reference in New Issue
Block a user