[mutter/wip/carlosg/unthrottled-wayland: 9/14] backends: Only reload sprite cursor on changes




commit de495ccbaacd87b884571cd11f88569928dd6531
Author: Carlos Garnacho <carlosg gnome org>
Date:   Mon Jul 5 15:47:58 2021 +0200

    backends: Only reload sprite cursor on changes
    
    Let the meta_cursor_sprite_realize() function return a boolean value
    telling whether there was an actual change in the sprite cursor. E.g.
    the surface/icon for it changed in between.
    
    This is used in the native backend to avoid converting/uploading again
    the cursor surface.

 src/backends/meta-cursor-sprite-xcursor.c         | 9 +++++++--
 src/backends/meta-cursor.c                        | 4 ++--
 src/backends/meta-cursor.h                        | 4 ++--
 src/backends/native/meta-cursor-renderer-native.c | 8 +++++---
 src/backends/x11/cm/meta-cursor-sprite-xfixes.c   | 3 ++-
 src/wayland/meta-cursor-sprite-wayland.c          | 3 ++-
 6 files changed, 20 insertions(+), 11 deletions(-)
---
diff --git a/src/backends/meta-cursor-sprite-xcursor.c b/src/backends/meta-cursor-sprite-xcursor.c
index 5284f28eaa..96942e3fe1 100644
--- a/src/backends/meta-cursor-sprite-xcursor.c
+++ b/src/backends/meta-cursor-sprite-xcursor.c
@@ -316,13 +316,18 @@ load_cursor_from_theme (MetaCursorSprite *sprite)
   load_from_current_xcursor_image (sprite_xcursor);
 }
 
-static void
+static gboolean
 meta_cursor_sprite_xcursor_realize_texture (MetaCursorSprite *sprite)
 {
   MetaCursorSpriteXcursor *sprite_xcursor = META_CURSOR_SPRITE_XCURSOR (sprite);
 
   if (sprite_xcursor->theme_dirty)
-    load_cursor_from_theme (sprite);
+    {
+      load_cursor_from_theme (sprite);
+      return TRUE;
+    }
+
+  return FALSE;
 }
 
 MetaCursorSpriteXcursor *
diff --git a/src/backends/meta-cursor.c b/src/backends/meta-cursor.c
index d0fb2ba686..6cdd46e1e9 100644
--- a/src/backends/meta-cursor.c
+++ b/src/backends/meta-cursor.c
@@ -187,10 +187,10 @@ meta_cursor_sprite_prepare_at (MetaCursorSprite   *sprite,
   g_signal_emit (sprite, signals[PREPARE_AT], 0, best_scale, x, y);
 }
 
-void
+gboolean
 meta_cursor_sprite_realize_texture (MetaCursorSprite *sprite)
 {
-  META_CURSOR_SPRITE_GET_CLASS (sprite)->realize_texture (sprite);
+  return META_CURSOR_SPRITE_GET_CLASS (sprite)->realize_texture (sprite);
 }
 
 static void
diff --git a/src/backends/meta-cursor.h b/src/backends/meta-cursor.h
index a65e128c48..e62f3c8057 100644
--- a/src/backends/meta-cursor.h
+++ b/src/backends/meta-cursor.h
@@ -36,7 +36,7 @@ struct _MetaCursorSpriteClass
 {
   GObjectClass parent_class;
 
-  void (* realize_texture) (MetaCursorSprite *sprite);
+  gboolean (* realize_texture) (MetaCursorSprite *sprite);
   gboolean (* is_animated) (MetaCursorSprite *sprite);
   void (* tick_frame) (MetaCursorSprite *sprite);
   unsigned int (* get_current_frame_time) (MetaCursorSprite *sprite);
@@ -47,7 +47,7 @@ void meta_cursor_sprite_prepare_at (MetaCursorSprite *sprite,
                                     int               x,
                                     int               y);
 
-void meta_cursor_sprite_realize_texture (MetaCursorSprite *sprite);
+gboolean meta_cursor_sprite_realize_texture (MetaCursorSprite *sprite);
 
 void meta_cursor_sprite_clear_texture (MetaCursorSprite *sprite);
 
diff --git a/src/backends/native/meta-cursor-renderer-native.c 
b/src/backends/native/meta-cursor-renderer-native.c
index effa0851dc..860df6067d 100644
--- a/src/backends/native/meta-cursor-renderer-native.c
+++ b/src/backends/native/meta-cursor-renderer-native.c
@@ -1077,9 +1077,11 @@ meta_cursor_renderer_native_update_cursor (MetaCursorRenderer *renderer,
 
   if (cursor_sprite)
     {
-      meta_cursor_sprite_realize_texture (cursor_sprite);
-      gpus = calculate_cursor_sprite_gpus (renderer, cursor_sprite);
-      realize_cursor_sprite (renderer, cursor_sprite, gpus);
+      if (meta_cursor_sprite_realize_texture (cursor_sprite))
+        {
+          gpus = calculate_cursor_sprite_gpus (renderer, cursor_sprite);
+          realize_cursor_sprite (renderer, cursor_sprite, gpus);
+        }
     }
 
   maybe_schedule_cursor_sprite_animation_frame (native, cursor_sprite);
diff --git a/src/backends/x11/cm/meta-cursor-sprite-xfixes.c b/src/backends/x11/cm/meta-cursor-sprite-xfixes.c
index 0c524668e0..ae6e2b6acb 100644
--- a/src/backends/x11/cm/meta-cursor-sprite-xfixes.c
+++ b/src/backends/x11/cm/meta-cursor-sprite-xfixes.c
@@ -52,9 +52,10 @@ G_DEFINE_TYPE_WITH_CODE (MetaCursorSpriteXfixes,
                          G_IMPLEMENT_INTERFACE (G_TYPE_INITABLE,
                                                 meta_screen_cast_xfixes_init_initable_iface))
 
-static void
+static gboolean
 meta_cursor_sprite_xfixes_realize_texture (MetaCursorSprite *sprite)
 {
+  return TRUE;
 }
 
 static gboolean
diff --git a/src/wayland/meta-cursor-sprite-wayland.c b/src/wayland/meta-cursor-sprite-wayland.c
index 7c14960ffb..c4e532b0f4 100644
--- a/src/wayland/meta-cursor-sprite-wayland.c
+++ b/src/wayland/meta-cursor-sprite-wayland.c
@@ -31,9 +31,10 @@ G_DEFINE_TYPE (MetaCursorSpriteWayland,
                meta_cursor_sprite_wayland,
                META_TYPE_CURSOR_SPRITE)
 
-static void
+static gboolean
 meta_cursor_sprite_wayland_realize_texture (MetaCursorSprite *sprite)
 {
+  return TRUE;
 }
 
 static gboolean


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