From f086eafe57b34d717a73c2a34ecc8c84d43ea381 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Wed, 20 May 2020 21:46:23 +0200 Subject: [PATCH] Gather all time unit conversion helpers in one place We had time unit conversion helpers (e.g. us2ms(), ns2us(), etc) in multiple places. Clean that up by moving them all to a common file. That file is clutter-private.h, as it's accessible by both from clutter/ and src/. https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1285 --- clutter/clutter/clutter-frame-clock.c | 13 +------------ clutter/clutter/clutter-private.h | 24 ++++++++++++++++++++++++ src/backends/native/meta-seat-native.h | 18 ------------------ src/tests/clutter-test-utils.h | 12 ------------ 4 files changed, 25 insertions(+), 42 deletions(-) diff --git a/clutter/clutter/clutter-frame-clock.c b/clutter/clutter/clutter-frame-clock.c index 88c07cc25..d9ef9e1f0 100644 --- a/clutter/clutter/clutter-frame-clock.c +++ b/clutter/clutter/clutter-frame-clock.c @@ -20,21 +20,10 @@ #include "clutter/clutter-frame-clock.h" #include "clutter/clutter-main.h" +#include "clutter/clutter-private.h" #include "clutter/clutter-timeline-private.h" #include "cogl/cogl-trace.h" -static inline uint64_t -us (uint64_t us) -{ - return us; -} - -static inline uint64_t -ms2us (uint64_t ms) -{ - return us (ms * 1000); -} - /* Wait 2ms after vblank before starting to draw next frame */ #define SYNC_DELAY_US ms2us (2) diff --git a/clutter/clutter/clutter-private.h b/clutter/clutter/clutter-private.h index 196725fd9..a333d1453 100644 --- a/clutter/clutter/clutter-private.h +++ b/clutter/clutter/clutter-private.h @@ -316,6 +316,30 @@ gboolean _clutter_run_progress_function (GType gtype, void clutter_timeline_cancel_delay (ClutterTimeline *timeline); +static inline uint64_t +us (uint64_t us) +{ + return us; +} + +static inline uint64_t +ms2us (uint64_t ms) +{ + return us (ms * 1000); +} + +static inline uint32_t +us2ms (uint64_t us) +{ + return (uint32_t) (us / 1000); +} + +static inline uint64_t +ns2us (uint64_t ns) +{ + return us (ns / 1000); +} + G_END_DECLS #endif /* __CLUTTER_PRIVATE_H__ */ diff --git a/src/backends/native/meta-seat-native.h b/src/backends/native/meta-seat-native.h index 61e6ffd30..31a316c51 100644 --- a/src/backends/native/meta-seat-native.h +++ b/src/backends/native/meta-seat-native.h @@ -147,24 +147,6 @@ struct _MetaSeatNative G_DECLARE_FINAL_TYPE (MetaSeatNative, meta_seat_native, META, SEAT_NATIVE, ClutterSeat) -static inline uint64_t -us (uint64_t us) -{ - return us; -} - -static inline uint64_t -ms2us (uint64_t ms) -{ - return us (ms * 1000); -} - -static inline uint32_t -us2ms (uint64_t us) -{ - return (uint32_t) (us / 1000); -} - void meta_seat_native_notify_key (MetaSeatNative *seat, ClutterInputDevice *device, uint64_t time_us, diff --git a/src/tests/clutter-test-utils.h b/src/tests/clutter-test-utils.h index 9655fd113..62e8e9fdc 100644 --- a/src/tests/clutter-test-utils.h +++ b/src/tests/clutter-test-utils.h @@ -168,18 +168,6 @@ gboolean clutter_test_check_color_at_point (ClutterActor const ClutterColor *color, ClutterColor *result); -static inline uint64_t -us (uint64_t us) -{ - return us; -} - -static inline uint64_t -ms2us (uint64_t ms) -{ - return us (ms * 1000); -} - G_END_DECLS #endif /* __CLUTTER_TEST_UTILS_H__ */