From 5f729ea4379ccbc69de036927b4b214fc39f3cb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Fri, 29 May 2020 23:02:20 +0200 Subject: [PATCH] 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 --- clutter/clutter/clutter-stage-private.h | 3 +- clutter/clutter/clutter-stage.c | 17 +++---- clutter/clutter/cogl/clutter-stage-cogl.c | 2 +- src/compositor/compositor.c | 58 ++++++++++++----------- src/tests/clutter/conform/actor-clone.c | 1 - 5 files changed, 40 insertions(+), 41 deletions(-) diff --git a/clutter/clutter/clutter-stage-private.h b/clutter/clutter/clutter-stage-private.h index 866731100..0c4c7066b 100644 --- a/clutter/clutter/clutter-stage-private.h +++ b/clutter/clutter/clutter-stage-private.h @@ -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, diff --git a/clutter/clutter/clutter-stage.c b/clutter/clutter/clutter-stage.c index 1d08cd4fa..1f5f03987 100644 --- a/clutter/clutter/clutter-stage.c +++ b/clutter/clutter/clutter-stage.c @@ -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, - ClutterFrameInfo *frame_info) +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 diff --git a/clutter/clutter/cogl/clutter-stage-cogl.c b/clutter/clutter/cogl/clutter-stage-cogl.c index af3a6da74..6aa912e71 100644 --- a/clutter/clutter/cogl/clutter-stage-cogl.c +++ b/clutter/clutter/cogl/clutter-stage-cogl.c @@ -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) diff --git a/src/compositor/compositor.c b/src/compositor/compositor.c index a72ecee1c..ad37fa03e 100644 --- a/src/compositor/compositor.c +++ b/src/compositor/compositor.c @@ -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,43 +1063,48 @@ 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) + if (presentation_time_cogl != 0) { - gint64 presentation_time_cogl = frame_info->presentation_time; - gint64 presentation_time; + int64_t current_cogl_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 - * normal case with the open source GPU drivers on Linux 3.8 and - * newer is that the base of cogl_get_clock_time() is that of - * clock_gettime(CLOCK_MONOTONIC), so the same as g_get_monotonic_time), - * but there's no exposure of that through the API. clock_gettime() - * 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 (); + /* 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 + * newer is that the base of cogl_get_clock_time() is that of + * clock_gettime(CLOCK_MONOTONIC), so the same as g_get_monotonic_time), + * but there's no exposure of that through the API. clock_gettime() + * 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 (); - presentation_time = - current_monotonic_time + (presentation_time_cogl - current_cogl_time) / 1000; - } - else - { - presentation_time = 0; - } + presentation_time = + current_monotonic_time + + (presentation_time_cogl - current_cogl_time) / 1000; + } + else + { + presentation_time = 0; + } - for (l = priv->windows; l; l = l->next) - meta_window_actor_frame_complete (l->data, frame_info, presentation_time); + for (l = priv->windows; l; l = l->next) + { + ClutterActor *actor = l->data; + + meta_window_actor_frame_complete (META_WINDOW_ACTOR (actor), + frame_info, + presentation_time); } } diff --git a/src/tests/clutter/conform/actor-clone.c b/src/tests/clutter/conform/actor-clone.c index e78bf9baf..6a27c5199 100644 --- a/src/tests/clutter/conform/actor-clone.c +++ b/src/tests/clutter/conform/actor-clone.c @@ -7,7 +7,6 @@ static void on_presented (ClutterStage *stage, - CoglFrameEvent *frame_event, ClutterFrameInfo *frame_info, gboolean *was_presented) {