[gtk/matthiasc/for-master: 12/16] Add gdk_frame_clock_get_fps
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/matthiasc/for-master: 12/16] Add gdk_frame_clock_get_fps
- Date: Mon, 14 Sep 2020 03:45:02 +0000 (UTC)
commit b1669996833320eb7402415b15cd4a19d2310c25
Author: Matthias Clasen <mclasen redhat com>
Date: Sun Sep 13 23:31:17 2020 -0400
Add gdk_frame_clock_get_fps
We already have more than one copy of this code
in GTK, so just export this function.
docs/reference/gdk/gdk4-sections.txt | 1 +
gdk/gdkframeclock.c | 17 ++++++++++++-----
gdk/gdkframeclock.h | 3 +++
3 files changed, 16 insertions(+), 5 deletions(-)
---
diff --git a/docs/reference/gdk/gdk4-sections.txt b/docs/reference/gdk/gdk4-sections.txt
index c601c44407..68343f9923 100644
--- a/docs/reference/gdk/gdk4-sections.txt
+++ b/docs/reference/gdk/gdk4-sections.txt
@@ -1036,6 +1036,7 @@ gdk_frame_clock_get_history_start
gdk_frame_clock_get_timings
gdk_frame_clock_get_current_timings
gdk_frame_clock_get_refresh_info
+gdk_frame_clock_get_fps
<SUBSECTION Private>
GDK_FRAME_CLOCK
diff --git a/gdk/gdkframeclock.c b/gdk/gdkframeclock.c
index 9ecb8707fb..4d05da780c 100644
--- a/gdk/gdkframeclock.c
+++ b/gdk/gdkframeclock.c
@@ -718,7 +718,6 @@ _gdk_frame_clock_emit_resume_events (GdkFrameClock *frame_clock)
g_signal_emit (frame_clock, signals[RESUME_EVENTS], 0);
}
-#ifdef HAVE_SYSPROF
static gint64
guess_refresh_interval (GdkFrameClock *frame_clock)
{
@@ -753,8 +752,17 @@ guess_refresh_interval (GdkFrameClock *frame_clock)
return interval;
}
-static double
-frame_clock_get_fps (GdkFrameClock *frame_clock)
+/**
+ * gdk_frame_clock_get_fps:
+ * @frame_clock: a #GdkFrameClock
+ *
+ * Calculates the current frames-per-second, based on the
+ * frame timings of @frame_clock.
+ *
+ * Returns: the current fps, as a double
+ */
+double
+gdk_frame_clock_get_fps (GdkFrameClock *frame_clock)
{
GdkFrameTimings *start, *end;
gint64 start_counter, end_counter;
@@ -788,7 +796,6 @@ frame_clock_get_fps (GdkFrameClock *frame_clock)
return ((double) end_counter - start_counter) * G_USEC_PER_SEC / (end_timestamp - start_timestamp);
}
-#endif
void
_gdk_frame_clock_add_timings_to_profiler (GdkFrameClock *clock,
@@ -804,5 +811,5 @@ _gdk_frame_clock_add_timings_to_profiler (GdkFrameClock *clock,
gdk_profiler_add_mark (1000 * timings->presentation_time, 0, "presented window", NULL);
}
- gdk_profiler_set_counter (fps_counter, frame_clock_get_fps (clock));
+ gdk_profiler_set_counter (fps_counter, gdk_frame_clock_get_fps (clock));
}
diff --git a/gdk/gdkframeclock.h b/gdk/gdkframeclock.h
index 962bf0c189..a2eba246ad 100644
--- a/gdk/gdkframeclock.h
+++ b/gdk/gdkframeclock.h
@@ -103,6 +103,9 @@ void gdk_frame_clock_get_refresh_info (GdkFrameClock *frame_clock,
gint64 *refresh_interval_return,
gint64 *presentation_time_return);
+GDK_AVAILABLE_IN_ALL
+double gdk_frame_clock_get_fps (GdkFrameClock *frame_clock);
+
G_END_DECLS
#endif /* __GDK_FRAME_CLOCK_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]