summaryrefslogtreecommitdiff
path: root/gdk
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2020-09-13 23:31:17 -0400
committerMatthias Clasen <mclasen@redhat.com>2020-09-13 23:35:01 -0400
commitb1669996833320eb7402415b15cd4a19d2310c25 (patch)
tree709da5d7bf9a6f88ec8a7987b8237ffbfcf228ca /gdk
parent4b589b6afbe84ca24824a681d1bb089f3a60515d (diff)
downloadgtk+-b1669996833320eb7402415b15cd4a19d2310c25.tar.gz
Add gdk_frame_clock_get_fps
We already have more than one copy of this code in GTK, so just export this function.
Diffstat (limited to 'gdk')
-rw-r--r--gdk/gdkframeclock.c17
-rw-r--r--gdk/gdkframeclock.h3
2 files changed, 15 insertions, 5 deletions
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__ */