stage: Add 'prepare-frame' signal

This is a signal that will be emitted between the 'before-update' and
'before-paint'. It can be used to handle things when you know whether
there is an update, and you know whether a paint or not will happen, by
looking at the current damage.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2393>
This commit is contained in:
Jonas Ådahl 2022-04-29 16:02:08 +02:00 committed by Marge Bot
parent aa8d2d6fff
commit cecf4cd87c
3 changed files with 27 additions and 0 deletions

View File

@ -49,6 +49,8 @@ void clutter_stage_paint_view (ClutterStage
void clutter_stage_emit_before_update (ClutterStage *stage, void clutter_stage_emit_before_update (ClutterStage *stage,
ClutterStageView *view); ClutterStageView *view);
void clutter_stage_emit_prepare_frame (ClutterStage *stage,
ClutterStageView *view);
void clutter_stage_emit_before_paint (ClutterStage *stage, void clutter_stage_emit_before_paint (ClutterStage *stage,
ClutterStageView *view); ClutterStageView *view);
void clutter_stage_emit_after_paint (ClutterStage *stage, void clutter_stage_emit_after_paint (ClutterStage *stage,

View File

@ -1183,6 +1183,7 @@ handle_frame_clock_frame (ClutterFrameClock *frame_clock,
frame = CLUTTER_FRAME_INIT; frame = CLUTTER_FRAME_INIT;
_clutter_stage_window_prepare_frame (stage_window, view, &frame); _clutter_stage_window_prepare_frame (stage_window, view, &frame);
clutter_stage_emit_prepare_frame (stage, view);
if (clutter_stage_view_has_redraw_clip (view)) if (clutter_stage_view_has_redraw_clip (view))
{ {

View File

@ -162,6 +162,7 @@ enum
DEACTIVATE, DEACTIVATE,
DELETE_EVENT, DELETE_EVENT,
BEFORE_UPDATE, BEFORE_UPDATE,
PREPARE_FRAME,
BEFORE_PAINT, BEFORE_PAINT,
AFTER_PAINT, AFTER_PAINT,
AFTER_UPDATE, AFTER_UPDATE,
@ -465,6 +466,13 @@ clutter_stage_emit_before_update (ClutterStage *stage,
g_signal_emit (stage, stage_signals[BEFORE_UPDATE], 0, view); g_signal_emit (stage, stage_signals[BEFORE_UPDATE], 0, view);
} }
void
clutter_stage_emit_prepare_frame (ClutterStage *stage,
ClutterStageView *view)
{
g_signal_emit (stage, stage_signals[PREPARE_FRAME], 0, view);
}
void void
clutter_stage_emit_before_paint (ClutterStage *stage, clutter_stage_emit_before_paint (ClutterStage *stage,
ClutterStageView *view) ClutterStageView *view)
@ -1408,6 +1416,22 @@ clutter_stage_class_init (ClutterStageClass *klass)
NULL, NULL, NULL, NULL, NULL, NULL,
G_TYPE_NONE, 1, G_TYPE_NONE, 1,
CLUTTER_TYPE_STAGE_VIEW); CLUTTER_TYPE_STAGE_VIEW);
/**
* ClutterStage::prepare-frame:
* @stage: the stage that received the event
* @view: a #ClutterStageView
*
* The ::prepare-frame signal is emitted after the stage is updated,
* before the stage is painted, even if it will not be painted.
*/
stage_signals[PREPARE_FRAME] =
g_signal_new (I_("prepare-frame"),
G_TYPE_FROM_CLASS (gobject_class),
G_SIGNAL_RUN_LAST,
0,
NULL, NULL, NULL,
G_TYPE_NONE, 1,
CLUTTER_TYPE_STAGE_VIEW);
/** /**
* ClutterStage::before-paint: * ClutterStage::before-paint: