[mutter] clutter: Record flip time



commit 63b9ac272442c7645c4940249374e26f12e3006d
Author: Ivan Molodetskikh <yalterz gmail com>
Date:   Fri Nov 27 20:48:11 2020 +0300

    clutter: Record flip time
    
    Will be used for intelligent max render time computation (aka repaint
    scheduling).
    
    Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1762>

 clutter/clutter/clutter-frame-clock.c | 10 ++++++++++
 clutter/clutter/clutter-frame-clock.h |  3 +++
 clutter/clutter/clutter-stage-view.c  |  3 +++
 3 files changed, 16 insertions(+)
---
diff --git a/clutter/clutter/clutter-frame-clock.c b/clutter/clutter/clutter-frame-clock.c
index 05e79e6626..c5acf51ad5 100644
--- a/clutter/clutter/clutter-frame-clock.c
+++ b/clutter/clutter/clutter-frame-clock.c
@@ -76,6 +76,9 @@ struct _ClutterFrameClock
   gboolean is_next_presentation_time_valid;
   int64_t next_presentation_time_us;
 
+  /* Last KMS buffer submission time. */
+  int64_t last_flip_time_us;
+
   gboolean pending_reschedule;
   gboolean pending_reschedule_now;
 
@@ -548,6 +551,13 @@ frame_clock_source_dispatch (GSource     *source,
   return G_SOURCE_CONTINUE;
 }
 
+void
+clutter_frame_clock_record_flip_time (ClutterFrameClock *frame_clock,
+                                      int64_t            flip_time_us)
+{
+  frame_clock->last_flip_time_us = flip_time_us;
+}
+
 static GSourceFuncs frame_clock_source_funcs = {
   NULL,
   NULL,
diff --git a/clutter/clutter/clutter-frame-clock.h b/clutter/clutter/clutter-frame-clock.h
index 9f91b6bfd3..b7120aade8 100644
--- a/clutter/clutter/clutter-frame-clock.h
+++ b/clutter/clutter/clutter-frame-clock.h
@@ -90,4 +90,7 @@ void clutter_frame_clock_remove_timeline (ClutterFrameClock *frame_clock,
 CLUTTER_EXPORT
 float clutter_frame_clock_get_refresh_rate (ClutterFrameClock *frame_clock);
 
+void clutter_frame_clock_record_flip_time (ClutterFrameClock *frame_clock,
+                                           int64_t            flip_time_us);
+
 #endif /* CLUTTER_FRAME_CLOCK_H */
diff --git a/clutter/clutter/clutter-stage-view.c b/clutter/clutter/clutter-stage-view.c
index b44bf88854..d6755e3c4e 100644
--- a/clutter/clutter/clutter-stage-view.c
+++ b/clutter/clutter/clutter-stage-view.c
@@ -1187,6 +1187,9 @@ handle_frame_clock_frame (ClutterFrameClock *frame_clock,
 
       _clutter_stage_window_redraw_view (stage_window, view, &frame);
 
+      clutter_frame_clock_record_flip_time (frame_clock,
+                                            g_get_monotonic_time ());
+
       clutter_stage_emit_after_paint (stage, view);
 
       if (_clutter_context_get_show_fps ())


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]