[gnome-shell/gnome-41] st/entry: Compare shadow spec before invalidating shadow on style change



commit 7d4163702f494e2b0c0f04bc8a3bc37b751fe61c
Author: Jonas Dreßler <verdre v0yd nl>
Date:   Fri Mar 5 12:35:26 2021 +0100

    st/entry: Compare shadow spec before invalidating shadow on style change
    
    Instead of doing a lot of useless work every time we receive the
    style-changed signal, only invalidate our text shadow pipeline in case
    the shadow actually changed.
    
    (cherry picked from commit ba774e1fa21f560827ed03d6702de9a70d0d6d3b)
    
    Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2180>

 src/st/st-entry.c | 24 +++++++++++++++++-------
 1 file changed, 17 insertions(+), 7 deletions(-)
---
diff --git a/src/st/st-entry.c b/src/st/st-entry.c
index 6496336ddd..ab4af65298 100644
--- a/src/st/st-entry.c
+++ b/src/st/st-entry.c
@@ -105,6 +105,8 @@ struct _StEntryPrivate
 
   gboolean      has_ibeam;
 
+  StShadow     *shadow_spec;
+
   CoglPipeline *text_shadow_material;
   gfloat        shadow_width;
   gfloat        shadow_height;
@@ -242,13 +244,23 @@ st_entry_style_changed (StWidget *self)
 {
   StEntryPrivate *priv = ST_ENTRY_PRIV (self);
   StThemeNode *theme_node;
+  StShadow *shadow_spec;
   ClutterColor color;
   gdouble size;
 
-  cogl_clear_object (&priv->text_shadow_material);
-
   theme_node = st_widget_get_theme_node (self);
 
+  shadow_spec = st_theme_node_get_text_shadow (theme_node);
+  if (!priv->shadow_spec || !shadow_spec ||
+      !st_shadow_equal (shadow_spec, priv->shadow_spec))
+    {
+      g_clear_pointer (&priv->text_shadow_material, cogl_object_unref);
+
+      g_clear_pointer (&priv->shadow_spec, st_shadow_unref);
+      if (shadow_spec)
+        priv->shadow_spec = st_shadow_ref (shadow_spec);
+    }
+
   _st_set_text_from_style (CLUTTER_TEXT (priv->entry), theme_node);
 
   if (st_theme_node_lookup_length (theme_node, "caret-size", TRUE, &size))
@@ -799,13 +811,11 @@ st_entry_paint (ClutterActor        *actor,
                 ClutterPaintContext *paint_context)
 {
   StEntryPrivate *priv = ST_ENTRY_PRIV (actor);
-  StThemeNode *theme_node = st_widget_get_theme_node (ST_WIDGET (actor));
-  StShadow *shadow_spec = st_theme_node_get_text_shadow (theme_node);
   ClutterActorClass *parent_class;
 
   st_widget_paint_background (ST_WIDGET (actor), paint_context);
 
-  if (shadow_spec)
+  if (priv->shadow_spec)
     {
       ClutterActorBox allocation;
       float width, height;
@@ -821,7 +831,7 @@ st_entry_paint (ClutterActor        *actor,
 
           cogl_clear_object (&priv->text_shadow_material);
 
-          material = _st_create_shadow_pipeline_from_actor (shadow_spec,
+          material = _st_create_shadow_pipeline_from_actor (priv->shadow_spec,
                                                             priv->entry);
 
           priv->shadow_width = width;
@@ -834,7 +844,7 @@ st_entry_paint (ClutterActor        *actor,
           CoglFramebuffer *framebuffer =
             clutter_paint_context_get_framebuffer (paint_context);
 
-          _st_paint_shadow_with_opacity (shadow_spec,
+          _st_paint_shadow_with_opacity (priv->shadow_spec,
                                          framebuffer,
                                          priv->text_shadow_material,
                                          &allocation,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]