onscreen/native: Move out timeval to timestamp helper

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2777>
This commit is contained in:
Jonas Ådahl 2022-12-21 18:22:08 +01:00
parent 17a78303d0
commit a7954f4a75
2 changed files with 8 additions and 7 deletions

View File

@ -231,12 +231,6 @@ notify_view_crtc_presented (MetaRendererView *view,
meta_onscreen_native_swap_drm_fb (onscreen);
}
static int64_t
timeval_to_microseconds (const struct timeval *tv)
{
return ((int64_t) tv->tv_sec) * G_USEC_PER_SEC + tv->tv_usec;
}
static void
page_flip_feedback_flipped (MetaKmsCrtc *kms_crtc,
unsigned int sequence,
@ -258,7 +252,7 @@ page_flip_feedback_flipped (MetaKmsCrtc *kms_crtc,
kms_device = meta_kms_crtc_get_device (kms_crtc);
if (meta_kms_device_uses_monotonic_clock (kms_device))
{
presentation_time_us = timeval_to_microseconds (&page_flip_time);
presentation_time_us = meta_timeval_to_microseconds (&page_flip_time);
flags |= COGL_FRAME_INFO_FLAG_HW_CLOCK;
}
else

View File

@ -26,6 +26,7 @@
#define META_UTIL_PRIVATE_H
#include <glib/gi18n-lib.h>
#include <sys/time.h>
#include "meta/util.h"
#include "meta/common.h"
@ -44,6 +45,12 @@ char * meta_generate_random_id (GRand *rand,
void meta_init_debug_utils (void);
static inline int64_t
meta_timeval_to_microseconds (const struct timeval *tv)
{
return ((int64_t) tv->tv_sec) * G_USEC_PER_SEC + tv->tv_usec;
}
#define META_POINT_IN_RECT(xcoord, ycoord, rect) \
((xcoord) >= (rect).x && \
(xcoord) < ((rect).x + (rect).width) && \