From 43554c1966bec7c85bf222d93ebc15eafbeb6b3b Mon Sep 17 00:00:00 2001 From: YaoBing Xiao Date: Tue, 20 Aug 2024 17:45:13 +0800 Subject: [PATCH] types/wlr_output: removing the useless pointer --- backend/drm/drm.c | 9 ++++----- backend/wayland/output.c | 9 ++++----- backend/x11/output.c | 5 +---- include/wlr/types/wlr_output.h | 2 +- types/output/output.c | 6 ++---- types/wlr_presentation_time.c | 4 ++-- 6 files changed, 14 insertions(+), 21 deletions(-) diff --git a/backend/drm/drm.c b/backend/drm/drm.c index 1ba8939af..6e3b5e99f 100644 --- a/backend/drm/drm.c +++ b/backend/drm/drm.c @@ -2062,16 +2062,15 @@ static void handle_page_flip(int fd, unsigned seq, present_flags |= WLR_OUTPUT_PRESENT_ZERO_COPY; } - struct timespec present_time = { - .tv_sec = tv_sec, - .tv_nsec = tv_usec * 1000, - }; struct wlr_output_event_present present_event = { /* The DRM backend guarantees that the presentation event will be for * the last submitted frame. */ .commit_seq = conn->output.commit_seq, .presented = drm->session->active, - .when = &present_time, + .when = { + .tv_sec = tv_sec, + .tv_nsec = tv_usec * 1000, + }, .seq = seq, .refresh = mhz_to_nsec(conn->refresh), .flags = present_flags, diff --git a/backend/wayland/output.c b/backend/wayland/output.c index 39803eae9..e672028b7 100644 --- a/backend/wayland/output.c +++ b/backend/wayland/output.c @@ -94,14 +94,13 @@ static void presentation_feedback_handle_presented(void *data, uint32_t seq_hi, uint32_t seq_lo, uint32_t flags) { struct wlr_wl_presentation_feedback *feedback = data; - struct timespec t = { - .tv_sec = ((uint64_t)tv_sec_hi << 32) | tv_sec_lo, - .tv_nsec = tv_nsec, - }; struct wlr_output_event_present event = { .commit_seq = feedback->commit_seq, .presented = true, - .when = &t, + .when = { + .tv_sec = ((uint64_t)tv_sec_hi << 32) | tv_sec_lo, + .tv_nsec = tv_nsec, + }, .seq = ((uint64_t)seq_hi << 32) | seq_lo, .refresh = refresh_ns, .flags = flags, diff --git a/backend/x11/output.c b/backend/x11/output.c index 51a8459d1..b400f3df9 100644 --- a/backend/x11/output.c +++ b/backend/x11/output.c @@ -747,9 +747,6 @@ void handle_x11_present_event(struct wlr_x11_backend *x11, output->last_msc = complete_notify->msc; - struct timespec t; - timespec_from_nsec(&t, complete_notify->ust * 1000); - uint32_t flags = 0; if (complete_notify->mode == XCB_PRESENT_COMPLETE_MODE_FLIP) { flags |= WLR_OUTPUT_PRESENT_ZERO_COPY; @@ -760,10 +757,10 @@ void handle_x11_present_event(struct wlr_x11_backend *x11, .output = &output->wlr_output, .commit_seq = complete_notify->serial, .presented = presented, - .when = &t, .seq = complete_notify->msc, .flags = flags, }; + timespec_from_nsec(&present_event.when, complete_notify->ust * 1000); wlr_output_send_present(&output->wlr_output, &present_event); wlr_output_send_frame(&output->wlr_output); diff --git a/include/wlr/types/wlr_output.h b/include/wlr/types/wlr_output.h index bf80f585a..6227f0476 100644 --- a/include/wlr/types/wlr_output.h +++ b/include/wlr/types/wlr_output.h @@ -263,7 +263,7 @@ struct wlr_output_event_present { // Whether the frame was presented at all. bool presented; // Time when the content update turned into light the first time. - struct timespec *when; + struct timespec when; // Vertical retrace counter. Zero if unavailable. unsigned seq; // Prediction of how many nanoseconds after `when` the very next output diff --git a/types/output/output.c b/types/output/output.c index 6755493fb..2dcd24229 100644 --- a/types/output/output.c +++ b/types/output/output.c @@ -794,14 +794,12 @@ void wlr_output_send_present(struct wlr_output *output, assert(event); event->output = output; - struct timespec now; - if (event->presented && event->when == NULL) { - if (clock_gettime(CLOCK_MONOTONIC, &now) != 0) { + if (event->presented && (event->when.tv_sec == 0 && event->when.tv_nsec == 0)) { + if (clock_gettime(CLOCK_MONOTONIC, &event->when) != 0) { wlr_log_errno(WLR_ERROR, "failed to send output present event: " "failed to read clock"); return; } - event->when = &now; } wl_signal_emit_mutable(&output->events.present, event); diff --git a/types/wlr_presentation_time.c b/types/wlr_presentation_time.c index 35b960d02..94e379a54 100644 --- a/types/wlr_presentation_time.c +++ b/types/wlr_presentation_time.c @@ -239,8 +239,8 @@ void wlr_presentation_event_from_output(struct wlr_presentation_event *event, const struct wlr_output_event_present *output_event) { *event = (struct wlr_presentation_event){ .output = output_event->output, - .tv_sec = (uint64_t)output_event->when->tv_sec, - .tv_nsec = (uint32_t)output_event->when->tv_nsec, + .tv_sec = (uint64_t)output_event->when.tv_sec, + .tv_nsec = (uint32_t)output_event->when.tv_nsec, .refresh = (uint32_t)output_event->refresh, .seq = (uint64_t)output_event->seq, .flags = output_event->flags,