From 2e358f3c43d2d73e2f849b50c9c18edc0e279097 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Fri, 22 May 2020 22:57:39 +0200 Subject: [PATCH] clutter/stage-view: Have each stage view create its own frame clock The frame clock is meant to eventually drive the painting of the view, in contrast to the master frame clock painting every view on the stage. Right now it's a useless place holder. https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1285 --- clutter/clutter/clutter-stage-view-private.h | 3 ++ clutter/clutter/clutter-stage-view.c | 42 ++++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/clutter/clutter/clutter-stage-view-private.h b/clutter/clutter/clutter-stage-view-private.h index 36c52e8ad..85d02e9de 100644 --- a/clutter/clutter/clutter-stage-view-private.h +++ b/clutter/clutter/clutter-stage-view-private.h @@ -19,6 +19,7 @@ #define __CLUTTER_STAGE_VIEW_PRIVATE_H__ #include "clutter/clutter-stage-view.h" +#include "clutter/clutter-types.h" void clutter_stage_view_after_paint (ClutterStageView *view, cairo_region_t *redraw_clip); @@ -62,4 +63,6 @@ void clutter_stage_view_transform_rect_to_onscreen (ClutterStageView int dst_height, cairo_rectangle_int_t *dst_rect); +ClutterFrameClock * clutter_stage_view_get_frame_clock (ClutterStageView *view); + #endif /* __CLUTTER_STAGE_VIEW_PRIVATE_H__ */ diff --git a/clutter/clutter/clutter-stage-view.c b/clutter/clutter/clutter-stage-view.c index ebe3fe92b..83ffe4e83 100644 --- a/clutter/clutter/clutter-stage-view.c +++ b/clutter/clutter/clutter-stage-view.c @@ -24,6 +24,7 @@ #include #include "clutter/clutter-damage-history.h" +#include "clutter/clutter-frame-clock.h" #include "clutter/clutter-private.h" #include "clutter/clutter-mutter.h" #include "cogl/cogl.h" @@ -76,6 +77,7 @@ typedef struct _ClutterStageViewPrivate cairo_region_t *redraw_clip; float refresh_rate; + ClutterFrameClock *frame_clock; guint dirty_viewport : 1; guint dirty_projection : 1; @@ -999,6 +1001,41 @@ clutter_stage_view_take_scanout (ClutterStageView *view) return g_steal_pointer (&priv->next_scanout); } +ClutterFrameClock * +clutter_stage_view_get_frame_clock (ClutterStageView *view) +{ + ClutterStageViewPrivate *priv = + clutter_stage_view_get_instance_private (view); + + return priv->frame_clock; +} + +static void +handle_frame_clock_before_frame (ClutterFrameClock *frame_clock, + int64_t frame_count, + gpointer user_data) +{ + ClutterStageView *view = user_data; + ClutterStageViewPrivate *priv = + clutter_stage_view_get_instance_private (view); + + _clutter_stage_process_queued_events (priv->stage); +} + +static ClutterFrameResult +handle_frame_clock_frame (ClutterFrameClock *frame_clock, + int64_t frame_count, + int64_t time_us, + gpointer user_data) +{ + return CLUTTER_FRAME_RESULT_IDLE; +} + +static const ClutterFrameListenerIface frame_clock_listener_iface = { + .before_frame = handle_frame_clock_before_frame, + .frame = handle_frame_clock_frame, +}; + static void sanity_check_framebuffer (ClutterStageView *view) { @@ -1122,6 +1159,10 @@ clutter_stage_view_constructed (GObject *object) if (priv->use_shadowfb) init_shadowfb (view); + priv->frame_clock = clutter_frame_clock_new (priv->refresh_rate, + &frame_clock_listener_iface, + view); + G_OBJECT_CLASS (clutter_stage_view_parent_class)->constructed (object); } @@ -1148,6 +1189,7 @@ clutter_stage_view_dispose (GObject *object) g_clear_pointer (&priv->offscreen, cogl_object_unref); g_clear_pointer (&priv->offscreen_pipeline, cogl_object_unref); g_clear_pointer (&priv->redraw_clip, cairo_region_destroy); + g_clear_object (&priv->frame_clock); G_OBJECT_CLASS (clutter_stage_view_parent_class)->dispose (object); }