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>
This commit is contained in:
parent
13562033d7
commit
0b1dfbf6f3
@ -60,6 +60,8 @@ struct _StIconPrivate
|
|||||||
gint icon_size; /* icon size we are using */
|
gint icon_size; /* icon size we are using */
|
||||||
GIcon *fallback_gicon;
|
GIcon *fallback_gicon;
|
||||||
|
|
||||||
|
StIconColors *colors;
|
||||||
|
|
||||||
CoglPipeline *shadow_pipeline;
|
CoglPipeline *shadow_pipeline;
|
||||||
StShadow *shadow_spec;
|
StShadow *shadow_spec;
|
||||||
graphene_size_t shadow_size;
|
graphene_size_t shadow_size;
|
||||||
@ -169,6 +171,7 @@ st_icon_dispose (GObject *gobject)
|
|||||||
|
|
||||||
g_clear_object (&priv->gicon);
|
g_clear_object (&priv->gicon);
|
||||||
g_clear_object (&priv->fallback_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_pipeline, cogl_object_unref);
|
||||||
g_clear_pointer (&priv->shadow_spec, st_shadow_unref);
|
g_clear_pointer (&priv->shadow_spec, st_shadow_unref);
|
||||||
|
|
||||||
@ -212,21 +215,45 @@ st_icon_style_changed (StWidget *widget)
|
|||||||
StIcon *self = ST_ICON (widget);
|
StIcon *self = ST_ICON (widget);
|
||||||
StThemeNode *theme_node = st_widget_get_theme_node (widget);
|
StThemeNode *theme_node = st_widget_get_theme_node (widget);
|
||||||
StIconPrivate *priv = self->priv;
|
StIconPrivate *priv = self->priv;
|
||||||
|
gboolean should_update = FALSE;
|
||||||
|
g_autoptr(StShadow) shadow_spec = NULL;
|
||||||
|
StIconColors *colors;
|
||||||
|
|
||||||
st_icon_clear_shadow_pipeline (self);
|
shadow_spec = st_theme_node_get_shadow (theme_node, "icon-shadow");
|
||||||
g_clear_pointer (&priv->shadow_spec, st_shadow_unref);
|
|
||||||
|
|
||||||
priv->shadow_spec = st_theme_node_get_shadow (theme_node, "icon-shadow");
|
if (shadow_spec && shadow_spec->inset)
|
||||||
|
|
||||||
if (priv->shadow_spec && priv->shadow_spec->inset)
|
|
||||||
{
|
{
|
||||||
g_warning ("The icon-shadow property does not support inset shadows");
|
g_warning ("The icon-shadow property does not support inset shadows");
|
||||||
st_shadow_unref (priv->shadow_spec);
|
g_clear_pointer (&shadow_spec, st_shadow_unref);
|
||||||
priv->shadow_spec = NULL;
|
}
|
||||||
|
|
||||||
|
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"));
|
priv->theme_icon_size = (int)(0.5 + st_theme_node_get_length (theme_node, "icon-size"));
|
||||||
st_icon_update_icon_size (self);
|
|
||||||
|
should_update |= st_icon_update_icon_size (self);
|
||||||
|
|
||||||
|
if (should_update)
|
||||||
st_icon_update (self);
|
st_icon_update (self);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user