From 83107668456a83d7a7ae429c021cd7c090be1819 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Fri, 27 Aug 2021 13:25:52 +0200 Subject: [PATCH] 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. Part-of: --- 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 188c7a254..c188cd16e 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; + } - return TRUE; + sprite_xcursor->invalidated = FALSE; + + return retval; +} + +static void +meta_cursor_sprite_xcursor_invalidate (MetaCursorSprite *sprite) +{ + MetaCursorSpriteXcursor *sprite_xcursor = META_CURSOR_SPRITE_XCURSOR (sprite); + + 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 =