mutter/0002-clutter-Add-ms2ns-helper.patch

90 lines
1.8 KiB
Diff

From 555d200c63051228062367316859e255abf6ab00 Mon Sep 17 00:00:00 2001
From: Ray Strode <rstrode@redhat.com>
Date: Fri, 29 Sep 2023 10:53:50 -0400
Subject: [PATCH 2/3] clutter: Add ms2ns helper
Some system apis we're going to need in the future use
nanoseconds, but we're never going to need more timing
precision that milliseconds.
In preparate for that, this commit adds a new helper ns2ms
to help avoid bugs in unit conversion.
---
clutter/clutter/clutter-private.h | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/clutter/clutter/clutter-private.h b/clutter/clutter/clutter-private.h
index 9d5e68c8c..007e15eba 100644
--- a/clutter/clutter/clutter-private.h
+++ b/clutter/clutter/clutter-private.h
@@ -219,60 +219,66 @@ gboolean _clutter_run_progress_function (GType gtype,
const GValue *final,
gdouble progress,
GValue *retval);
void clutter_timeline_cancel_delay (ClutterTimeline *timeline);
static inline void
clutter_round_to_256ths (float *f)
{
*f = roundf ((*f) * 256) / 256;
}
static inline uint64_t
ns (uint64_t ns)
{
return ns;
}
static inline int64_t
us (int64_t us)
{
return us;
}
static inline int64_t
ms (int64_t ms)
{
return ms;
}
+static inline int64_t
+ms2ns (int64_t ms)
+{
+ return ns (us (ms * 1000) * 1000);
+}
+
static inline int64_t
ms2us (int64_t ms)
{
return us (ms * 1000);
}
static inline int64_t
us2ns (int64_t us)
{
return ns (us * 1000);
}
static inline int64_t
us2ms (int64_t us)
{
return (int64_t) (us / 1000);
}
static inline int64_t
ns2us (int64_t ns)
{
return us (ns / 1000);
}
static inline int64_t
s2us (int64_t s)
{
return s * G_USEC_PER_SEC;
}
--
2.41.0