1
0
Fork 0

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, void _clutter_stage_set_scale_factor (ClutterStage *stage,
int factor); int factor);
void _clutter_stage_presented (ClutterStage *stage, void clutter_stage_presented (ClutterStage *stage,
CoglFrameEvent frame_event,
ClutterFrameInfo *frame_info); ClutterFrameInfo *frame_info);
void clutter_stage_queue_actor_relayout (ClutterStage *stage, void clutter_stage_queue_actor_relayout (ClutterStage *stage,

View file

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

View file

@ -131,7 +131,7 @@ _clutter_stage_cogl_presented (ClutterStageCogl *stage_cogl,
stage_cogl->refresh_rate = frame_info->refresh_rate; 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 && if (frame_event == COGL_FRAME_EVENT_COMPLETE &&
stage_cogl->update_time != -1) stage_cogl->update_time != -1)

View file

@ -143,7 +143,6 @@ G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (MetaCompositor, meta_compositor,
static void static void
on_presented (ClutterStage *stage, on_presented (ClutterStage *stage,
CoglFrameEvent event,
ClutterFrameInfo *frame_info, ClutterFrameInfo *frame_info,
MetaCompositor *compositor); MetaCompositor *compositor);
@ -1064,43 +1063,48 @@ meta_compositor_sync_window_geometry (MetaCompositor *compositor,
static void static void
on_presented (ClutterStage *stage, on_presented (ClutterStage *stage,
CoglFrameEvent event,
ClutterFrameInfo *frame_info, ClutterFrameInfo *frame_info,
MetaCompositor *compositor) MetaCompositor *compositor)
{ {
MetaCompositorPrivate *priv = MetaCompositorPrivate *priv =
meta_compositor_get_instance_private (compositor); meta_compositor_get_instance_private (compositor);
int64_t presentation_time_cogl = frame_info->presentation_time;
int64_t presentation_time;
GList *l; GList *l;
if (event == COGL_FRAME_EVENT_COMPLETE) if (presentation_time_cogl != 0)
{ {
gint64 presentation_time_cogl = frame_info->presentation_time; int64_t current_cogl_time;
gint64 presentation_time; int64_t current_monotonic_time;
if (presentation_time_cogl != 0) /* Cogl reports presentation in terms of its own clock, which is
{ * guaranteed to be in nanoseconds but with no specified base. The
/* Cogl reports presentation in terms of its own clock, which is * normal case with the open source GPU drivers on Linux 3.8 and
* guaranteed to be in nanoseconds but with no specified base. The * newer is that the base of cogl_get_clock_time() is that of
* normal case with the open source GPU drivers on Linux 3.8 and * clock_gettime(CLOCK_MONOTONIC), so the same as g_get_monotonic_time),
* newer is that the base of cogl_get_clock_time() is that of * but there's no exposure of that through the API. clock_gettime()
* clock_gettime(CLOCK_MONOTONIC), so the same as g_get_monotonic_time), * is fairly fast, so calling it twice and subtracting to get a
* but there's no exposure of that through the API. clock_gettime() * nearly-zero number is acceptable, if a litle ugly.
* is fairly fast, so calling it twice and subtracting to get a */
* nearly-zero number is acceptable, if a litle ugly. current_cogl_time = cogl_get_clock_time (priv->context);
*/ current_monotonic_time = g_get_monotonic_time ();
gint64 current_cogl_time = cogl_get_clock_time (priv->context);
gint64 current_monotonic_time = g_get_monotonic_time ();
presentation_time = presentation_time =
current_monotonic_time + (presentation_time_cogl - current_cogl_time) / 1000; current_monotonic_time +
} (presentation_time_cogl - current_cogl_time) / 1000;
else }
{ else
presentation_time = 0; {
} presentation_time = 0;
}
for (l = priv->windows; l; l = l->next) 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 static void
on_presented (ClutterStage *stage, on_presented (ClutterStage *stage,
CoglFrameEvent *frame_event,
ClutterFrameInfo *frame_info, ClutterFrameInfo *frame_info,
gboolean *was_presented) gboolean *was_presented)
{ {