[gtk/wip/baedert/css-values] cssimagefallback: Don't compute new image if only a color is set
- From: Timm Bäder <baedert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/baedert/css-values] cssimagefallback: Don't compute new image if only a color is set
- Date: Sat, 11 Jan 2020 09:53:51 +0000 (UTC)
commit 2d570eede6dcf64a088f68b2c5e19dc1ccbd7b18
Author: Timm Bäder <mail baedert org>
Date: Sat Jan 11 08:25:52 2020 +0100
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.
gtk/gtkcssimagefallback.c | 23 +++++++++++++++--------
1 file changed, 15 insertions(+), 8 deletions(-)
---
diff --git a/gtk/gtkcssimagefallback.c b/gtk/gtkcssimagefallback.c
index 8d8ca30b52..879703b0d9 100644
--- a/gtk/gtkcssimagefallback.c
+++ b/gtk/gtkcssimagefallback.c
@@ -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);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]