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); }