[mutter/wip/carlosg/unthrottled-wayland: 231/240] backends: Upload xcursor texture only after invalidations and theme changes




commit 38bd72b9a8defd5e4ab1870df33f4d3c51ca7f1f
Author: Carlos Garnacho <carlosg gnome org>
Date:   Fri Aug 27 13:25:52 2021 +0200

    backends: Upload xcursor texture only after invalidations and theme changes
    
    Make realize_texture() return FALSE for the situations that we do not need
    to push again the cursor texture.

 src/backends/meta-cursor-sprite-xcursor.c | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)
---
diff --git a/src/backends/meta-cursor-sprite-xcursor.c b/src/backends/meta-cursor-sprite-xcursor.c
index 188c7a2540..c188cd16e5 100644
--- a/src/backends/meta-cursor-sprite-xcursor.c
+++ b/src/backends/meta-cursor-sprite-xcursor.c
@@ -38,6 +38,7 @@ struct _MetaCursorSpriteXcursor
 
   int theme_scale;
   gboolean theme_dirty;
+  gboolean invalidated;
 };
 
 G_DEFINE_TYPE (MetaCursorSpriteXcursor, meta_cursor_sprite_xcursor,
@@ -320,11 +321,25 @@ static gboolean
 meta_cursor_sprite_xcursor_realize_texture (MetaCursorSprite *sprite)
 {
   MetaCursorSpriteXcursor *sprite_xcursor = META_CURSOR_SPRITE_XCURSOR (sprite);
+  gboolean retval = sprite_xcursor->invalidated;
 
   if (sprite_xcursor->theme_dirty)
-    load_cursor_from_theme (sprite);
+    {
+      load_cursor_from_theme (sprite);
+      retval = TRUE;
+    }
+
+  sprite_xcursor->invalidated = FALSE;
+
+  return retval;
+}
+
+static void
+meta_cursor_sprite_xcursor_invalidate (MetaCursorSprite *sprite)
+{
+  MetaCursorSpriteXcursor *sprite_xcursor = META_CURSOR_SPRITE_XCURSOR (sprite);
 
-  return TRUE;
+  sprite_xcursor->invalidated = TRUE;
 }
 
 MetaCursorSpriteXcursor *
@@ -366,6 +381,8 @@ meta_cursor_sprite_xcursor_class_init (MetaCursorSpriteXcursorClass *klass)
 
   cursor_sprite_class->realize_texture =
     meta_cursor_sprite_xcursor_realize_texture;
+  cursor_sprite_class->invalidate =
+    meta_cursor_sprite_xcursor_invalidate;
   cursor_sprite_class->is_animated = meta_cursor_sprite_xcursor_is_animated;
   cursor_sprite_class->tick_frame = meta_cursor_sprite_xcursor_tick_frame;
   cursor_sprite_class->get_current_frame_time =


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