From 627ab247210b6ec3e186c27091c8a8926323a942 Mon Sep 17 00:00:00 2001 From: Dor Askayo Date: Sat, 3 Feb 2024 19:31:32 +0200 Subject: [PATCH] surface-actor: Add meta_surface_actor_schedule_update() This function allows scheduling a stage update in the context of a surface actor and emit the "update-scheduled" signal. This signal is similar to "repaint-scheduled", but can be used to be notified of updates that do not necessarily result in a repaint. With variable refresh rate, any update potentially affecting the frame pacing of a surface actor needs to be handled differently depending on whether that surface actor drives the refresh rate or not. Part-of: --- src/compositor/meta-surface-actor.c | 20 ++++++++++++++++++++ src/compositor/meta-surface-actor.h | 2 ++ 2 files changed, 22 insertions(+) diff --git a/src/compositor/meta-surface-actor.c b/src/compositor/meta-surface-actor.c index e9bfa8126..8ffc2cd8a 100644 --- a/src/compositor/meta-surface-actor.c +++ b/src/compositor/meta-surface-actor.c @@ -62,6 +62,7 @@ G_DEFINE_ABSTRACT_TYPE_WITH_CODE (MetaSurfaceActor, meta_surface_actor, CLUTTER_ enum { REPAINT_SCHEDULED, + UPDATE_SCHEDULED, SIZE_CHANGED, LAST_SIGNAL, @@ -293,6 +294,14 @@ meta_surface_actor_class_init (MetaSurfaceActorClass *klass) NULL, NULL, NULL, G_TYPE_NONE, 0); + signals[UPDATE_SCHEDULED] = g_signal_new ("update-scheduled", + G_TYPE_FROM_CLASS (object_class), + G_SIGNAL_RUN_LAST, + 0, + NULL, NULL, NULL, + G_TYPE_NONE, 0); + + signals[SIZE_CHANGED] = g_signal_new ("size-changed", G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST, @@ -393,6 +402,17 @@ meta_surface_actor_get_texture (MetaSurfaceActor *self) return priv->texture; } +void +meta_surface_actor_schedule_update (MetaSurfaceActor *self) +{ + ClutterStage *stage = + CLUTTER_STAGE (clutter_actor_get_stage (CLUTTER_ACTOR (self))); + + clutter_stage_schedule_update (stage); + + g_signal_emit (self, signals[UPDATE_SCHEDULED], 0); +} + void meta_surface_actor_update_area (MetaSurfaceActor *self, int x, diff --git a/src/compositor/meta-surface-actor.h b/src/compositor/meta-surface-actor.h index 2823076b3..7c5b5b80b 100644 --- a/src/compositor/meta-surface-actor.h +++ b/src/compositor/meta-surface-actor.h @@ -49,6 +49,8 @@ void meta_surface_actor_set_opaque_region (MetaSurfaceActor *self, MtkRegion *region); MtkRegion * meta_surface_actor_get_opaque_region (MetaSurfaceActor *self); +void meta_surface_actor_schedule_update (MetaSurfaceActor *self); + void meta_surface_actor_process_damage (MetaSurfaceActor *actor, int x, int y, int width, int height);