Merge branch 'frame-scheduler-helper' into 'master'

Draft: render: add frame scheduler helper

See merge request wlroots/wlroots!3783
This commit is contained in:
Simon Ser 2022-11-14 17:37:40 +00:00
commit e7737537ef
13 changed files with 479 additions and 7 deletions

View file

@ -10,6 +10,10 @@ int64_t timespec_to_msec(const struct timespec *a) {
return (int64_t)a->tv_sec * 1000 + a->tv_nsec / 1000000;
}
int64_t timespec_to_nsec(const struct timespec *t) {
return (int64_t)t->tv_sec * NSEC_PER_SEC + t->tv_nsec;
}
void timespec_from_nsec(struct timespec *r, int64_t nsec) {
r->tv_sec = nsec / NSEC_PER_SEC;
r->tv_nsec = nsec % NSEC_PER_SEC;
@ -21,12 +25,24 @@ uint32_t get_current_time_msec(void) {
return timespec_to_msec(&now);
}
void timespec_sub(struct timespec *r, const struct timespec *a,
void timespec_add(struct timespec *r, const struct timespec *a,
const struct timespec *b) {
r->tv_sec = a->tv_sec - b->tv_sec;
r->tv_nsec = a->tv_nsec - b->tv_nsec;
if (r->tv_nsec < 0) {
r->tv_sec = a->tv_sec + b->tv_sec;
r->tv_nsec = a->tv_nsec + b->tv_nsec;
if (r->tv_nsec >= NSEC_PER_SEC) {
r->tv_sec++;
r->tv_nsec -= NSEC_PER_SEC;
} else if (r->tv_nsec < 0) {
r->tv_sec--;
r->tv_nsec += NSEC_PER_SEC;
}
}
void timespec_sub(struct timespec *r, const struct timespec *a,
const struct timespec *b) {
struct timespec tmp = {
.tv_sec = -b->tv_sec,
.tv_nsec = -b->tv_nsec,
};
timespec_add(r, a, &tmp);
}