[mutter] clutter: Store vblank duration in ClutterFrameClock



commit 3aa0e3074f1a15febe67ecf8d829271b29a5dcef
Author: Ivan Molodetskikh <yalterz gmail com>
Date:   Wed Jan 6 15:20:01 2021 +0300

    clutter: Store vblank duration in ClutterFrameClock
    
    Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1762>

 clutter/clutter/clutter-frame-clock.c            |  6 ++++++
 clutter/clutter/clutter-frame-clock.h            |  1 +
 clutter/clutter/clutter-stage-view.c             |  1 +
 src/tests/clutter/conform/frame-clock-timeline.c |  3 +++
 src/tests/clutter/conform/frame-clock.c          | 11 +++++++++++
 5 files changed, 22 insertions(+)
---
diff --git a/clutter/clutter/clutter-frame-clock.c b/clutter/clutter/clutter-frame-clock.c
index c5acf51ad5..9dbed99ba4 100644
--- a/clutter/clutter/clutter-frame-clock.c
+++ b/clutter/clutter/clutter-frame-clock.c
@@ -76,6 +76,10 @@ struct _ClutterFrameClock
   gboolean is_next_presentation_time_valid;
   int64_t next_presentation_time_us;
 
+  /* Buffer must be submitted to KMS and GPU rendering must be finished
+   * this amount of time before the next presentation time.
+   */
+  int64_t vblank_duration_us;
   /* Last KMS buffer submission time. */
   int64_t last_flip_time_us;
 
@@ -587,6 +591,7 @@ init_frame_clock_source (ClutterFrameClock *frame_clock)
 
 ClutterFrameClock *
 clutter_frame_clock_new (float                            refresh_rate,
+                         int64_t                          vblank_duration_us,
                          const ClutterFrameListenerIface *iface,
                          gpointer                         user_data)
 {
@@ -602,6 +607,7 @@ clutter_frame_clock_new (float                            refresh_rate,
   init_frame_clock_source (frame_clock);
 
   frame_clock->refresh_rate = refresh_rate;
+  frame_clock->vblank_duration_us = vblank_duration_us;
 
   return frame_clock;
 }
diff --git a/clutter/clutter/clutter-frame-clock.h b/clutter/clutter/clutter-frame-clock.h
index b7120aade8..c825ecad94 100644
--- a/clutter/clutter/clutter-frame-clock.h
+++ b/clutter/clutter/clutter-frame-clock.h
@@ -56,6 +56,7 @@ typedef struct _ClutterFrameListenerIface
 
 CLUTTER_EXPORT
 ClutterFrameClock * clutter_frame_clock_new (float                            refresh_rate,
+                                             int64_t                          vblank_duration_us,
                                              const ClutterFrameListenerIface *iface,
                                              gpointer                         user_data);
 
diff --git a/clutter/clutter/clutter-stage-view.c b/clutter/clutter/clutter-stage-view.c
index 0f8f7c6ee7..2b2cadd684 100644
--- a/clutter/clutter/clutter-stage-view.c
+++ b/clutter/clutter/clutter-stage-view.c
@@ -1365,6 +1365,7 @@ clutter_stage_view_constructed (GObject *object)
     init_shadowfb (view);
 
   priv->frame_clock = clutter_frame_clock_new (priv->refresh_rate,
+                                               priv->vblank_duration_us,
                                                &frame_clock_listener_iface,
                                                view);
 
diff --git a/src/tests/clutter/conform/frame-clock-timeline.c 
b/src/tests/clutter/conform/frame-clock-timeline.c
index bf99cd17b4..0f9f04d794 100644
--- a/src/tests/clutter/conform/frame-clock-timeline.c
+++ b/src/tests/clutter/conform/frame-clock-timeline.c
@@ -64,6 +64,7 @@ frame_clock_timeline_basic (void)
 
   main_loop = g_main_loop_new (NULL, FALSE);
   frame_clock = clutter_frame_clock_new (refresh_rate,
+                                         0,
                                          &timeline_frame_listener_iface,
                                          NULL);
   g_object_add_weak_pointer (G_OBJECT (frame_clock), (gpointer *) &frame_clock);
@@ -143,10 +144,12 @@ frame_clock_timeline_switch (void)
   main_loop = g_main_loop_new (NULL, FALSE);
 
   frame_clock1 = clutter_frame_clock_new (refresh_rate,
+                                          0,
                                           &timeline_frame_listener_iface,
                                           NULL);
   g_object_add_weak_pointer (G_OBJECT (frame_clock1), (gpointer *) &frame_clock1);
   frame_clock2 = clutter_frame_clock_new (refresh_rate,
+                                          0,
                                           &timeline_frame_listener_iface,
                                           NULL);
   g_object_add_weak_pointer (G_OBJECT (frame_clock2), (gpointer *) &frame_clock2);
diff --git a/src/tests/clutter/conform/frame-clock.c b/src/tests/clutter/conform/frame-clock.c
index 45d21ccec2..810c39a02c 100644
--- a/src/tests/clutter/conform/frame-clock.c
+++ b/src/tests/clutter/conform/frame-clock.c
@@ -146,6 +146,7 @@ frame_clock_schedule_update (void)
 
   test.main_loop = g_main_loop_new (NULL, FALSE);
   frame_clock = clutter_frame_clock_new (refresh_rate,
+                                         0,
                                          &frame_listener_iface,
                                          &test);
 
@@ -228,6 +229,7 @@ frame_clock_immediate_present (void)
 
   main_loop = g_main_loop_new (NULL, FALSE);
   frame_clock = clutter_frame_clock_new (refresh_rate,
+                                         0,
                                          &immediate_frame_listener_iface,
                                          main_loop);
 
@@ -306,6 +308,7 @@ frame_clock_delayed_damage (void)
 
   test.main_loop = g_main_loop_new (NULL, FALSE);
   frame_clock = clutter_frame_clock_new (refresh_rate,
+                                         0,
                                          &delayed_damage_frame_listener_iface,
                                          &test);
 
@@ -366,6 +369,7 @@ frame_clock_no_damage (void)
 
   main_loop = g_main_loop_new (NULL, FALSE);
   frame_clock = clutter_frame_clock_new (refresh_rate,
+                                         0,
                                          &no_damage_frame_listener_iface,
                                          NULL);
 
@@ -452,6 +456,7 @@ frame_clock_schedule_update_now (void)
 
   test.base.main_loop = g_main_loop_new (NULL, FALSE);
   frame_clock = clutter_frame_clock_new (refresh_rate,
+                                         0,
                                          &update_now_frame_listener_iface,
                                          &test);
 
@@ -534,6 +539,7 @@ frame_clock_before_frame (void)
 
   main_loop = g_main_loop_new (NULL, FALSE);
   frame_clock = clutter_frame_clock_new (refresh_rate,
+                                         0,
                                          &before_frame_frame_listener_iface,
                                          &expected_frame_count);
 
@@ -615,6 +621,7 @@ frame_clock_inhibit (void)
 
   test.main_loop = g_main_loop_new (NULL, FALSE);
   test.frame_clock = clutter_frame_clock_new (refresh_rate,
+                                              0,
                                               &inhibit_frame_listener_iface,
                                               &test);
 
@@ -678,6 +685,7 @@ frame_clock_reschedule_on_idle (void)
 
   test.base.main_loop = g_main_loop_new (NULL, FALSE);
   frame_clock = clutter_frame_clock_new (refresh_rate,
+                                         0,
                                          &reschedule_on_idle_listener_iface,
                                          &test);
   fake_hw_clock = fake_hw_clock_new (frame_clock, NULL, NULL);
@@ -714,6 +722,7 @@ frame_clock_destroy_signal (void)
   /* Test that the destroy signal is emitted when removing last reference. */
 
   frame_clock = clutter_frame_clock_new (refresh_rate,
+                                         0,
                                          &dummy_frame_listener_iface,
                                          NULL);
 
@@ -732,6 +741,7 @@ frame_clock_destroy_signal (void)
    */
 
   frame_clock = clutter_frame_clock_new (refresh_rate,
+                                         0,
                                          &dummy_frame_listener_iface,
                                          NULL);
   frame_clock_backup = frame_clock;
@@ -802,6 +812,7 @@ frame_clock_notify_ready (void)
 
   main_loop = g_main_loop_new (NULL, FALSE);
   frame_clock = clutter_frame_clock_new (refresh_rate,
+                                         0,
                                          &frame_clock_ready_listener_iface,
                                          main_loop);
 


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