clutter/stage: Only emit "presented" on completion event

We'd emit multiple "presented" signals per frame, one for "sync" and one
for "completion". Only the latter were ever used, and removing the
differentiation eases the avoidance of cogl onscreen framebuffer frame
callback details leaking into clutter.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1285
This commit is contained in:
Jonas Ådahl 2020-05-29 23:02:20 +02:00
parent ae7cc0417f
commit 5f729ea437
5 changed files with 40 additions and 41 deletions

View File

@ -134,8 +134,7 @@ gboolean _clutter_stage_update_state (ClutterStage *stag
void _clutter_stage_set_scale_factor (ClutterStage *stage,
int factor);
void _clutter_stage_presented (ClutterStage *stage,
CoglFrameEvent frame_event,
void clutter_stage_presented (ClutterStage *stage,
ClutterFrameInfo *frame_info);
void clutter_stage_queue_actor_relayout (ClutterStage *stage,

View File

@ -2106,7 +2106,6 @@ clutter_stage_class_init (ClutterStageClass *klass)
/**
* ClutterStage::presented: (skip)
* @stage: the stage that received the event
* @frame_event: a #CoglFrameEvent
* @frame_info: a #ClutterFrameInfo
*
* Signals that the #ClutterStage was presented on the screen to the user.
@ -2115,10 +2114,10 @@ clutter_stage_class_init (ClutterStageClass *klass)
g_signal_new (I_("presented"),
G_TYPE_FROM_CLASS (gobject_class),
G_SIGNAL_RUN_LAST,
0, NULL, NULL,
_clutter_marshal_VOID__INT_POINTER,
G_TYPE_NONE, 2,
G_TYPE_INT, G_TYPE_POINTER);
0,
NULL, NULL, NULL,
G_TYPE_NONE, 1,
G_TYPE_POINTER);
klass->activate = clutter_stage_real_activate;
klass->deactivate = clutter_stage_real_deactivate;
@ -3781,12 +3780,10 @@ clutter_stage_get_frame_counter (ClutterStage *stage)
}
void
_clutter_stage_presented (ClutterStage *stage,
CoglFrameEvent frame_event,
clutter_stage_presented (ClutterStage *stage,
ClutterFrameInfo *frame_info)
{
g_signal_emit (stage, stage_signals[PRESENTED], 0,
(int) frame_event, frame_info);
g_signal_emit (stage, stage_signals[PRESENTED], 0, frame_info);
}
static void

View File

@ -131,7 +131,7 @@ _clutter_stage_cogl_presented (ClutterStageCogl *stage_cogl,
stage_cogl->refresh_rate = frame_info->refresh_rate;
}
_clutter_stage_presented (stage_cogl->wrapper, frame_event, frame_info);
clutter_stage_presented (stage_cogl->wrapper, frame_info);
if (frame_event == COGL_FRAME_EVENT_COMPLETE &&
stage_cogl->update_time != -1)

View File

@ -143,7 +143,6 @@ G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (MetaCompositor, meta_compositor,
static void
on_presented (ClutterStage *stage,
CoglFrameEvent event,
ClutterFrameInfo *frame_info,
MetaCompositor *compositor);
@ -1064,21 +1063,20 @@ meta_compositor_sync_window_geometry (MetaCompositor *compositor,
static void
on_presented (ClutterStage *stage,
CoglFrameEvent event,
ClutterFrameInfo *frame_info,
MetaCompositor *compositor)
{
MetaCompositorPrivate *priv =
meta_compositor_get_instance_private (compositor);
int64_t presentation_time_cogl = frame_info->presentation_time;
int64_t presentation_time;
GList *l;
if (event == COGL_FRAME_EVENT_COMPLETE)
{
gint64 presentation_time_cogl = frame_info->presentation_time;
gint64 presentation_time;
if (presentation_time_cogl != 0)
{
int64_t current_cogl_time;
int64_t current_monotonic_time;
/* Cogl reports presentation in terms of its own clock, which is
* guaranteed to be in nanoseconds but with no specified base. The
* normal case with the open source GPU drivers on Linux 3.8 and
@ -1088,11 +1086,12 @@ on_presented (ClutterStage *stage,
* is fairly fast, so calling it twice and subtracting to get a
* nearly-zero number is acceptable, if a litle ugly.
*/
gint64 current_cogl_time = cogl_get_clock_time (priv->context);
gint64 current_monotonic_time = g_get_monotonic_time ();
current_cogl_time = cogl_get_clock_time (priv->context);
current_monotonic_time = g_get_monotonic_time ();
presentation_time =
current_monotonic_time + (presentation_time_cogl - current_cogl_time) / 1000;
current_monotonic_time +
(presentation_time_cogl - current_cogl_time) / 1000;
}
else
{
@ -1100,7 +1099,12 @@ on_presented (ClutterStage *stage,
}
for (l = priv->windows; l; l = l->next)
meta_window_actor_frame_complete (l->data, frame_info, presentation_time);
{
ClutterActor *actor = l->data;
meta_window_actor_frame_complete (META_WINDOW_ACTOR (actor),
frame_info,
presentation_time);
}
}

View File

@ -7,7 +7,6 @@
static void
on_presented (ClutterStage *stage,
CoglFrameEvent *frame_event,
ClutterFrameInfo *frame_info,
gboolean *was_presented)
{