Merge branch 'scheduling-2-better-this-time' into 'master'

Add new frame scheduler interface

See merge request wlroots/wlroots!4307
This commit is contained in:
Rose Hudson 2024-04-24 15:04:24 +00:00
commit a06c728a05
29 changed files with 507 additions and 153 deletions

View file

@ -354,7 +354,6 @@ void wlr_output_init(struct wlr_output *output, struct wlr_backend *backend,
wl_list_init(&output->cursors);
wl_list_init(&output->layers);
wl_list_init(&output->resources);
wl_signal_init(&output->events.frame);
wl_signal_init(&output->events.damage);
wl_signal_init(&output->events.needs_frame);
wl_signal_init(&output->events.precommit);
@ -410,10 +409,6 @@ void wlr_output_destroy(struct wlr_output *output) {
wlr_swapchain_destroy(output->swapchain);
if (output->idle_frame != NULL) {
wl_event_source_remove(output->idle_frame);
}
if (output->idle_done != NULL) {
wl_event_source_remove(output->idle_done);
}
@ -669,12 +664,6 @@ bool output_prepare_commit(struct wlr_output *output, const struct wlr_output_st
return false;
}
if ((state->committed & WLR_OUTPUT_STATE_BUFFER) &&
output->idle_frame != NULL) {
wl_event_source_remove(output->idle_frame);
output->idle_frame = NULL;
}
struct timespec now;
clock_gettime(CLOCK_MONOTONIC, &now);
@ -691,11 +680,6 @@ bool output_prepare_commit(struct wlr_output *output, const struct wlr_output_st
void output_apply_commit(struct wlr_output *output, const struct wlr_output_state *state) {
output->commit_seq++;
if (output_pending_enabled(output, state)) {
output->frame_pending = true;
output->needs_frame = false;
}
output_apply_state(output, state);
struct timespec now;
@ -747,37 +731,6 @@ bool wlr_output_commit_state(struct wlr_output *output,
return true;
}
void wlr_output_send_frame(struct wlr_output *output) {
output->frame_pending = false;
if (output->enabled) {
wl_signal_emit_mutable(&output->events.frame, output);
}
}
static void schedule_frame_handle_idle_timer(void *data) {
struct wlr_output *output = data;
output->idle_frame = NULL;
if (!output->frame_pending) {
wlr_output_send_frame(output);
}
}
void wlr_output_schedule_frame(struct wlr_output *output) {
// Make sure the compositor commits a new frame. This is necessary to make
// clients which ask for frame callbacks without submitting a new buffer
// work.
wlr_output_update_needs_frame(output);
if (output->frame_pending || output->idle_frame != NULL) {
return;
}
// We're using an idle timer here in case a buffer swap happens right after
// this function is called
output->idle_frame = wl_event_loop_add_idle(output->event_loop,
schedule_frame_handle_idle_timer, output);
}
void wlr_output_send_present(struct wlr_output *output,
struct wlr_output_event_present *event) {
assert(event);
@ -860,10 +813,6 @@ size_t wlr_output_get_gamma_size(struct wlr_output *output) {
}
void wlr_output_update_needs_frame(struct wlr_output *output) {
if (output->needs_frame) {
return;
}
output->needs_frame = true;
wl_signal_emit_mutable(&output->events.needs_frame, output);
}