mirror of
https://github.com/brl/mutter.git
synced 2024-11-26 10:00:45 -05:00
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>
This commit is contained in:
parent
39b2a18f90
commit
508c08fa09
@ -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 *
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user