mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-10 10:50:10 +00:00
cssimagefallback: Don't compute new image if only a color is set
Themes might use e.g. image(red), which is a constant value and will never change. In that case, the fallback image has ->color set, but not ->images. If that's the case and the computed color is the same as the one we already have, just return the already existing image.
This commit is contained in:
parent
67991ed0f4
commit
3401150cca
@ -142,6 +142,20 @@ gtk_css_image_fallback_compute (GtkCssImage *image,
|
||||
|
||||
if (fallback->used < 0)
|
||||
{
|
||||
GtkCssValue *computed_color = NULL;
|
||||
|
||||
if (fallback->color)
|
||||
computed_color= _gtk_css_value_compute (fallback->color,
|
||||
property_id,
|
||||
provider,
|
||||
style,
|
||||
parent_style);
|
||||
|
||||
/* image($color) that didn't change */
|
||||
if (computed_color && !fallback->images &&
|
||||
computed_color == fallback->color)
|
||||
return g_object_ref (image);
|
||||
|
||||
copy = g_object_new (_gtk_css_image_fallback_get_type (), NULL);
|
||||
copy->n_images = fallback->n_images;
|
||||
copy->images = g_new (GtkCssImage *, fallback->n_images);
|
||||
@ -160,14 +174,7 @@ gtk_css_image_fallback_compute (GtkCssImage *image,
|
||||
copy->used = i;
|
||||
}
|
||||
|
||||
if (fallback->color)
|
||||
copy->color = _gtk_css_value_compute (fallback->color,
|
||||
property_id,
|
||||
provider,
|
||||
style,
|
||||
parent_style);
|
||||
else
|
||||
copy->color = NULL;
|
||||
copy->color = computed_color;
|
||||
|
||||
return GTK_CSS_IMAGE (copy);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user