From e43baf46977c4ec0fcd9df1304a6f22341f1b89c Mon Sep 17 00:00:00 2001 From: Rose Hudson Date: Fri, 28 Jul 2023 11:57:46 +0100 Subject: [PATCH] output: remove old frame scheduling --- backend/drm/drm.c | 4 --- backend/headless/output.c | 35 --------------------- backend/wayland/output.c | 2 -- backend/x11/output.c | 2 -- include/backend/headless.h | 5 --- include/wlr/interfaces/wlr_output.h | 6 ---- include/wlr/types/wlr_output.h | 10 ------ types/output/output.c | 49 ----------------------------- 8 files changed, 113 deletions(-) diff --git a/backend/drm/drm.c b/backend/drm/drm.c index 852404483..a325a484c 100644 --- a/backend/drm/drm.c +++ b/backend/drm/drm.c @@ -1709,10 +1709,6 @@ static void handle_page_flip(int fd, unsigned seq, .flags = present_flags, }; wlr_output_send_present(&conn->output, &present_event); - - if (drm->session->active) { - wlr_output_send_frame(&conn->output); - } } int handle_drm_event(int fd, uint32_t mask, void *data) { diff --git a/backend/headless/output.c b/backend/headless/output.c index e5b1e1dea..be92c7fa8 100644 --- a/backend/headless/output.c +++ b/backend/headless/output.c @@ -21,17 +21,6 @@ static struct wlr_headless_output *headless_output_from_output( return output; } -static bool output_set_custom_mode(struct wlr_headless_output *output, - int32_t width, int32_t height, int32_t refresh) { - if (refresh <= 0) { - refresh = HEADLESS_DEFAULT_REFRESH; - } - - output->frame_delay = 1000000 / refresh; - - return true; -} - static bool output_test(struct wlr_output *wlr_output, const struct wlr_output_state *state) { uint32_t unsupported = state->committed & ~SUPPORTED_OUTPUT_STATE; @@ -56,30 +45,16 @@ static bool output_test(struct wlr_output *wlr_output, static bool output_commit(struct wlr_output *wlr_output, const struct wlr_output_state *state) { - struct wlr_headless_output *output = - headless_output_from_output(wlr_output); - if (!output_test(wlr_output, state)) { return false; } - if (state->committed & WLR_OUTPUT_STATE_MODE) { - if (!output_set_custom_mode(output, - state->custom_mode.width, - state->custom_mode.height, - state->custom_mode.refresh)) { - return false; - } - } - if (state->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); - - wl_event_source_timer_update(output->frame_timer, output->frame_delay); } return true; @@ -89,7 +64,6 @@ static void output_destroy(struct wlr_output *wlr_output) { struct wlr_headless_output *output = headless_output_from_output(wlr_output); wl_list_remove(&output->link); - wl_event_source_remove(output->frame_timer); free(output); } @@ -102,12 +76,6 @@ bool wlr_output_is_headless(struct wlr_output *wlr_output) { return wlr_output->impl == &output_impl; } -static int signal_frame(void *data) { - struct wlr_headless_output *output = data; - wlr_output_send_frame(&output->wlr_output); - return 0; -} - struct wlr_output *wlr_headless_add_output(struct wlr_backend *wlr_backend, unsigned int width, unsigned int height) { struct wlr_headless_backend *backend = @@ -139,9 +107,6 @@ struct wlr_output *wlr_headless_add_output(struct wlr_backend *wlr_backend, snprintf(description, sizeof(description), "Headless output %zu", output_num); wlr_output_set_description(wlr_output, description); - struct wl_event_loop *ev = wl_display_get_event_loop(backend->display); - output->frame_timer = wl_event_loop_add_timer(ev, signal_frame, output); - wl_list_insert(&backend->outputs, &output->link); if (backend->started) { diff --git a/backend/wayland/output.c b/backend/wayland/output.c index 7854d476a..d29a21fa5 100644 --- a/backend/wayland/output.c +++ b/backend/wayland/output.c @@ -69,8 +69,6 @@ static void surface_frame_callback(void *data, struct wl_callback *cb, assert(output->frame_callback == cb); wl_callback_destroy(cb); output->frame_callback = NULL; - - wlr_output_send_frame(&output->wlr_output); } static const struct wl_callback_listener frame_listener = { diff --git a/backend/x11/output.c b/backend/x11/output.c index d95f07670..c3fa7081d 100644 --- a/backend/x11/output.c +++ b/backend/x11/output.c @@ -729,8 +729,6 @@ void handle_x11_present_event(struct wlr_x11_backend *x11, .flags = flags, }; wlr_output_send_present(&output->wlr_output, &present_event); - - wlr_output_send_frame(&output->wlr_output); break; default: wlr_log(WLR_DEBUG, "Unhandled Present event %"PRIu16, event->event_type); diff --git a/include/backend/headless.h b/include/backend/headless.h index 4c71fb608..76b43d0b3 100644 --- a/include/backend/headless.h +++ b/include/backend/headless.h @@ -4,8 +4,6 @@ #include #include -#define HEADLESS_DEFAULT_REFRESH (60 * 1000) // 60 Hz - struct wlr_headless_backend { struct wlr_backend backend; struct wl_display *display; @@ -19,9 +17,6 @@ struct wlr_headless_output { struct wlr_headless_backend *backend; struct wl_list link; - - struct wl_event_source *frame_timer; - int frame_delay; // ms }; struct wlr_headless_backend *headless_backend_from_backend( diff --git a/include/wlr/interfaces/wlr_output.h b/include/wlr/interfaces/wlr_output.h index a51312970..92802c855 100644 --- a/include/wlr/interfaces/wlr_output.h +++ b/include/wlr/interfaces/wlr_output.h @@ -108,12 +108,6 @@ void wlr_output_init(struct wlr_output *output, struct wlr_backend *backend, * output changes. */ void wlr_output_update_needs_frame(struct wlr_output *output); -/** - * Send a frame event. - * - * See wlr_output.events.frame. - */ -void wlr_output_send_frame(struct wlr_output *output); /** * Send a present event. * diff --git a/include/wlr/types/wlr_output.h b/include/wlr/types/wlr_output.h index a71bf9ca0..791cbc811 100644 --- a/include/wlr/types/wlr_output.h +++ b/include/wlr/types/wlr_output.h @@ -145,8 +145,6 @@ struct wlr_output { uint32_t render_format; bool needs_frame; - // damage for cursors and fullscreen surface, in output-local coordinates - bool frame_pending; float transform_matrix[9]; // true for example with VR headsets @@ -158,8 +156,6 @@ struct wlr_output { uint32_t commit_seq; struct { - // Request to render a frame - struct wl_signal frame; // Emitted when software cursors or backend-specific logic damage the // output struct wl_signal damage; // struct wlr_output_event_damage @@ -179,7 +175,6 @@ struct wlr_output { struct wl_signal destroy; } events; - struct wl_event_source *idle_frame; struct wl_event_source *idle_done; int attach_render_locks; // number of locks forcing rendering @@ -477,11 +472,6 @@ bool wlr_output_test_state(struct wlr_output *output, */ bool wlr_output_commit_state(struct wlr_output *output, const struct wlr_output_state *state); -/** - * Manually schedules a `frame` event. If a `frame` event is already pending, - * it is a no-op. - */ -void wlr_output_schedule_frame(struct wlr_output *output); /** * Returns the maximum length of each gamma ramp, or 0 if unsupported. */ diff --git a/types/output/output.c b/types/output/output.c index c864a8948..4dc91ead7 100644 --- a/types/output/output.c +++ b/types/output/output.c @@ -319,11 +319,6 @@ static void output_apply_state(struct wlr_output *output, output->cursor_swapchain = NULL; } - if (state->committed & WLR_OUTPUT_STATE_BUFFER) { - output->frame_pending = true; - output->needs_frame = false; - } - if (state->committed & WLR_OUTPUT_STATE_LAYERS) { for (size_t i = 0; i < state->layers_len; i++) { struct wlr_output_layer_state *layer_state = &state->layers[i]; @@ -422,7 +417,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); @@ -478,10 +472,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); } @@ -792,12 +782,6 @@ bool wlr_output_commit_state(struct wlr_output *output, return false; } - if ((pending.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); @@ -862,39 +846,6 @@ void wlr_output_attach_buffer(struct wlr_output *output, wlr_output_state_set_buffer(&output->pending, buffer); } -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. - // TODO(rose): figure out why - 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 - struct wl_event_loop *ev = wl_display_get_event_loop(output->display); - output->idle_frame = - wl_event_loop_add_idle(ev, schedule_frame_handle_idle_timer, output); -} - void wlr_output_send_present(struct wlr_output *output, struct wlr_output_event_present *event) { assert(event);