Skip to content
This repository has been archived by the owner on Nov 1, 2021. It is now read-only.

Commit

Permalink
output: add presented flag to presentation event
Browse files Browse the repository at this point in the history
  • Loading branch information
Kirill Primak authored and emersion committed Oct 15, 2021
1 parent 1089b7b commit 2af8cc7
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions backend/drm/drm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1465,6 +1465,7 @@ static void handle_page_flip(int fd, unsigned seq,
/* The DRM backend guarantees that the presentation event will be for
* the last submitted frame. */
.commit_seq = conn->output.commit_seq,
.presented = true,
.when = &present_time,
.seq = seq,
.refresh = mhz_to_nsec(conn->output.refresh),
Expand Down
1 change: 1 addition & 0 deletions backend/headless/output.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ static bool output_commit(struct wlr_output *wlr_output) {
if (wlr_output->pending.committed & WLR_OUTPUT_STATE_BUFFER) {
struct wlr_output_event_present present_event = {
.commit_seq = wlr_output->commit_seq + 1,
.presented = true,
};
wlr_output_send_present(wlr_output, &present_event);
}
Expand Down
3 changes: 3 additions & 0 deletions backend/wayland/output.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ static void presentation_feedback_handle_presented(void *data,
};
struct wlr_output_event_present event = {
.commit_seq = feedback->commit_seq,
.presented = true,
.when = &t,
.seq = ((uint64_t)seq_hi << 32) | seq_lo,
.refresh = refresh_ns,
Expand All @@ -91,6 +92,7 @@ static void presentation_feedback_handle_discarded(void *data,

struct wlr_output_event_present event = {
.commit_seq = feedback->commit_seq,
.presented = false,
};
wlr_output_send_present(&feedback->output->wlr_output, &event);

Expand Down Expand Up @@ -350,6 +352,7 @@ static bool output_commit(struct wlr_output *wlr_output) {
} else {
struct wlr_output_event_present present_event = {
.commit_seq = wlr_output->commit_seq + 1,
.presented = true,
};
wlr_output_send_present(wlr_output, &present_event);
}
Expand Down
2 changes: 2 additions & 0 deletions backend/x11/output.c
Original file line number Diff line number Diff line change
Expand Up @@ -690,9 +690,11 @@ void handle_x11_present_event(struct wlr_x11_backend *x11,
flags |= WLR_OUTPUT_PRESENT_ZERO_COPY;
}

bool presented = complete_notify->mode != XCB_PRESENT_COMPLETE_MODE_SKIP;
struct wlr_output_event_present present_event = {
.output = &output->wlr_output,
.commit_seq = complete_notify->serial,
.presented = presented,
.when = &t,
.seq = complete_notify->msc,
.flags = flags,
Expand Down
2 changes: 2 additions & 0 deletions include/wlr/types/wlr_output.h
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,8 @@ struct wlr_output_event_present {
// Frame submission for which this presentation event is for (see
// wlr_output.commit_seq).
uint32_t commit_seq;
// Whether the frame was presented at all.
bool presented;
// Time when the content update turned into light the first time.
struct timespec *when;
// Vertical retrace counter. Zero if unavailable.
Expand Down
4 changes: 2 additions & 2 deletions types/wlr_output.c
Original file line number Diff line number Diff line change
Expand Up @@ -959,8 +959,8 @@ void wlr_output_send_present(struct wlr_output *output,
assert(event);
event->output = output;

struct timespec now;
if (event->when == NULL) {
if (event->presented && event->when == NULL) {
struct timespec now;
clockid_t clock = wlr_backend_get_presentation_clock(output->backend);
errno = 0;
if (clock_gettime(clock, &now) != 0) {
Expand Down

0 comments on commit 2af8cc7

Please sign in to comment.