[gnome-shell] st/icon: Check icon properties for changes before regenerating texture
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] st/icon: Check icon properties for changes before regenerating texture
- Date: Fri, 30 Jul 2021 14:05:15 +0000 (UTC)
commit 0b1dfbf6f3f40e4e7baf67aa77b79d4f0ced6129
Author: Jonas Dreßler <verdre v0yd nl>
Date: Thu Jan 23 10:44:30 2020 +0100
st/icon: Check icon properties for changes before regenerating texture
Properly compare the new icon properties of StIcon to the old ones on
style-changes and only update the icon texture in case something
changed. This should help reduce the amount of texture cache requests
when we start emitting all "style-changed" signals again.
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/953>
src/st/st-icon.c | 45 ++++++++++++++++++++++++++++++++++++---------
1 file changed, 36 insertions(+), 9 deletions(-)
---
diff --git a/src/st/st-icon.c b/src/st/st-icon.c
index c54fe9d724..6a93481792 100644
--- a/src/st/st-icon.c
+++ b/src/st/st-icon.c
@@ -60,6 +60,8 @@ struct _StIconPrivate
gint icon_size; /* icon size we are using */
GIcon *fallback_gicon;
+ StIconColors *colors;
+
CoglPipeline *shadow_pipeline;
StShadow *shadow_spec;
graphene_size_t shadow_size;
@@ -169,6 +171,7 @@ st_icon_dispose (GObject *gobject)
g_clear_object (&priv->gicon);
g_clear_object (&priv->fallback_gicon);
+ g_clear_pointer (&priv->colors, st_icon_colors_unref);
g_clear_pointer (&priv->shadow_pipeline, cogl_object_unref);
g_clear_pointer (&priv->shadow_spec, st_shadow_unref);
@@ -212,22 +215,46 @@ st_icon_style_changed (StWidget *widget)
StIcon *self = ST_ICON (widget);
StThemeNode *theme_node = st_widget_get_theme_node (widget);
StIconPrivate *priv = self->priv;
+ gboolean should_update = FALSE;
+ g_autoptr(StShadow) shadow_spec = NULL;
+ StIconColors *colors;
- st_icon_clear_shadow_pipeline (self);
- g_clear_pointer (&priv->shadow_spec, st_shadow_unref);
-
- priv->shadow_spec = st_theme_node_get_shadow (theme_node, "icon-shadow");
+ shadow_spec = st_theme_node_get_shadow (theme_node, "icon-shadow");
- if (priv->shadow_spec && priv->shadow_spec->inset)
+ if (shadow_spec && shadow_spec->inset)
{
g_warning ("The icon-shadow property does not support inset shadows");
- st_shadow_unref (priv->shadow_spec);
- priv->shadow_spec = NULL;
+ g_clear_pointer (&shadow_spec, st_shadow_unref);
+ }
+
+ if ((shadow_spec && priv->shadow_spec && !st_shadow_equal (shadow_spec, priv->shadow_spec)) ||
+ (shadow_spec && !priv->shadow_spec) || (!shadow_spec && priv->shadow_spec))
+ {
+ st_icon_clear_shadow_pipeline (self);
+
+ g_clear_pointer (&priv->shadow_spec, st_shadow_unref);
+ priv->shadow_spec = g_steal_pointer (&shadow_spec);
+
+ should_update = TRUE;
+ }
+
+ colors = st_theme_node_get_icon_colors (theme_node);
+
+ if ((colors && priv->colors && !st_icon_colors_equal (colors, priv->colors)) ||
+ (colors && !priv->colors) || (!colors && priv->colors))
+ {
+ g_clear_pointer (&priv->colors, st_icon_colors_unref);
+ priv->colors = st_icon_colors_ref (colors);
+
+ should_update = TRUE;
}
priv->theme_icon_size = (int)(0.5 + st_theme_node_get_length (theme_node, "icon-size"));
- st_icon_update_icon_size (self);
- st_icon_update (self);
+
+ should_update |= st_icon_update_icon_size (self);
+
+ if (should_update)
+ st_icon_update (self);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]