[mutter/wip/carlosg/unthrottled-wayland: 12/23] backends: Only reload sprite cursor on changes
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/wip/carlosg/unthrottled-wayland: 12/23] backends: Only reload sprite cursor on changes
- Date: Tue, 7 Dec 2021 18:56:11 +0000 (UTC)
commit e99a28de561f2a93ad0438380e09cdea86eb5c73
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.
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1915>
src/backends/meta-cursor-sprite-xcursor.c | 4 +++-
src/backends/meta-cursor-tracker.c | 1 +
src/backends/meta-cursor.c | 22 ++++++++++++++++++++--
src/backends/meta-cursor.h | 6 ++++--
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 ++-
7 files changed, 38 insertions(+), 9 deletions(-)
---
diff --git a/src/backends/meta-cursor-sprite-xcursor.c b/src/backends/meta-cursor-sprite-xcursor.c
index 5284f28eaa..188c7a2540 100644
--- a/src/backends/meta-cursor-sprite-xcursor.c
+++ b/src/backends/meta-cursor-sprite-xcursor.c
@@ -316,13 +316,15 @@ 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);
+
+ return TRUE;
}
MetaCursorSpriteXcursor *
diff --git a/src/backends/meta-cursor-tracker.c b/src/backends/meta-cursor-tracker.c
index 0df4d73cd4..116215195e 100644
--- a/src/backends/meta-cursor-tracker.c
+++ b/src/backends/meta-cursor-tracker.c
@@ -130,6 +130,7 @@ update_displayed_cursor (MetaCursorTracker *tracker)
if (cursor)
{
+ meta_cursor_sprite_invalidate (cursor);
g_signal_connect (cursor, "texture-changed",
G_CALLBACK (cursor_texture_updated), tracker);
}
diff --git a/src/backends/meta-cursor.c b/src/backends/meta-cursor.c
index d0fb2ba686..a0abd9cd67 100644
--- a/src/backends/meta-cursor.c
+++ b/src/backends/meta-cursor.c
@@ -81,6 +81,7 @@ meta_cursor_sprite_clear_texture (MetaCursorSprite *sprite)
meta_cursor_sprite_get_instance_private (sprite);
g_clear_pointer (&priv->texture, cogl_object_unref);
+ meta_cursor_sprite_invalidate (sprite);
}
void
@@ -98,6 +99,8 @@ meta_cursor_sprite_set_texture (MetaCursorSprite *sprite,
priv->hot_x = hot_x;
priv->hot_y = hot_y;
+ meta_cursor_sprite_invalidate (sprite);
+
g_signal_emit (sprite, signals[TEXTURE_CHANGED], 0);
}
@@ -108,6 +111,9 @@ meta_cursor_sprite_set_texture_scale (MetaCursorSprite *sprite,
MetaCursorSpritePrivate *priv =
meta_cursor_sprite_get_instance_private (sprite);
+ if (priv->texture_scale != scale)
+ meta_cursor_sprite_invalidate (sprite);
+
priv->texture_scale = scale;
}
@@ -118,6 +124,9 @@ meta_cursor_sprite_set_texture_transform (MetaCursorSprite *sprite,
MetaCursorSpritePrivate *priv =
meta_cursor_sprite_get_instance_private (sprite);
+ if (priv->texture_transform != transform)
+ meta_cursor_sprite_invalidate (sprite);
+
priv->texture_transform = transform;
}
@@ -187,10 +196,19 @@ 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);
+}
+
+void
+meta_cursor_sprite_invalidate (MetaCursorSprite *sprite)
+{
+ MetaCursorSpriteClass *sprite_class = META_CURSOR_SPRITE_GET_CLASS (sprite);
+
+ if (sprite_class->invalidate)
+ sprite_class->invalidate (sprite);
}
static void
diff --git a/src/backends/meta-cursor.h b/src/backends/meta-cursor.h
index a65e128c48..214394dd44 100644
--- a/src/backends/meta-cursor.h
+++ b/src/backends/meta-cursor.h
@@ -36,7 +36,8 @@ struct _MetaCursorSpriteClass
{
GObjectClass parent_class;
- void (* realize_texture) (MetaCursorSprite *sprite);
+ void (* invalidate) (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 +48,8 @@ void meta_cursor_sprite_prepare_at (MetaCursorSprite *sprite,
int x,
int y);
-void meta_cursor_sprite_realize_texture (MetaCursorSprite *sprite);
+void meta_cursor_sprite_invalidate (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 3f6ff48efb..8efdaf7775 100644
--- a/src/backends/native/meta-cursor-renderer-native.c
+++ b/src/backends/native/meta-cursor-renderer-native.c
@@ -1074,9 +1074,13 @@ meta_cursor_renderer_native_update_cursor (MetaCursorRenderer *renderer,
if (cursor_sprite)
{
- meta_cursor_sprite_realize_texture (cursor_sprite);
+ gboolean realized;
+
+ realized = meta_cursor_sprite_realize_texture (cursor_sprite);
gpus = calculate_cursor_sprite_gpus (renderer, cursor_sprite);
- realize_cursor_sprite (renderer, cursor_sprite, gpus);
+
+ if (realized)
+ 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]