From 6ee6e76a0c767ff7d55e9df27c839f976d75b66f Mon Sep 17 00:00:00 2001 From: Michael Tretter Date: Wed, 3 Nov 2021 11:14:11 +0100 Subject: [PATCH] compositor: remove repaint_data from compositor The repaint_data is entirely backend specific. Moreover, it is only used by the drm backend, while other backends ignore the repaint data. There will always be only one repaint active, thus, there is no need to pass the repaint data from the outside. The repaint_data breaks with the multi-backend series, which calls repaint begin for all backends to get the repaint_data. The repaint_data of the last backend will then be passed to all other backend. At the moment, this works, because the drm backend is the only backend that implements the begin_repaint call. Another option would be to track the repaint data per backend in the compositor, but actually, it the backend needs to track state across the calls, it's its own responsibility. Signed-off-by: Michael Tretter --- include/libweston/libweston.h | 6 ++---- libweston/backend-drm/drm-internal.h | 2 +- libweston/backend-drm/drm-virtual.c | 3 +-- libweston/backend-drm/drm.c | 12 ++++-------- libweston/backend-drm/state-propose.c | 2 +- libweston/backend-headless/headless.c | 3 +-- libweston/backend-rdp/rdp.c | 3 +-- libweston/backend-wayland/wayland.c | 6 ++---- libweston/backend-x11/x11.c | 6 ++---- libweston/backend.h | 12 +++--------- libweston/compositor.c | 22 +++++++++------------- 11 files changed, 27 insertions(+), 50 deletions(-) diff --git a/include/libweston/libweston.h b/include/libweston/libweston.h index 18c1f8af..22cd81fc 100644 --- a/include/libweston/libweston.h +++ b/include/libweston/libweston.h @@ -336,11 +336,9 @@ struct weston_output { bool allow_protection; int (*start_repaint_loop)(struct weston_output *output); - int (*repaint)(struct weston_output *output, - pixman_region32_t *damage, - void *repaint_data); + int (*repaint)(struct weston_output *output, pixman_region32_t *damage); void (*destroy)(struct weston_output *output); - void (*assign_planes)(struct weston_output *output, void *repaint_data); + void (*assign_planes)(struct weston_output *output); int (*switch_mode)(struct weston_output *output, struct weston_mode *mode); /* backlight values are on 0-255 range, where higher is brighter */ diff --git a/libweston/backend-drm/drm-internal.h b/libweston/backend-drm/drm-internal.h index 0331e1de..df704926 100644 --- a/libweston/backend-drm/drm-internal.h +++ b/libweston/backend-drm/drm-internal.h @@ -790,7 +790,7 @@ void drm_plane_reset_state(struct drm_plane *plane); void -drm_assign_planes(struct weston_output *output_base, void *repaint_data); +drm_assign_planes(struct weston_output *output_base); bool drm_plane_is_available(struct drm_plane *plane, struct drm_output *output); diff --git a/libweston/backend-drm/drm-virtual.c b/libweston/backend-drm/drm-virtual.c index 1a383a54..3be2feb3 100644 --- a/libweston/backend-drm/drm-virtual.c +++ b/libweston/backend-drm/drm-virtual.c @@ -185,8 +185,7 @@ drm_virtual_output_submit_frame(struct drm_output *output, static int drm_virtual_output_repaint(struct weston_output *output_base, - pixman_region32_t *damage, - void *repaint_data) + pixman_region32_t *damage) { struct drm_output_state *state = NULL; struct drm_output *output = to_drm_output(output_base); diff --git a/libweston/backend-drm/drm.c b/libweston/backend-drm/drm.c index 0bd8f1a3..225d47e2 100644 --- a/libweston/backend-drm/drm.c +++ b/libweston/backend-drm/drm.c @@ -441,9 +441,7 @@ drm_output_render(struct drm_output_state *state, pixman_region32_t *damage) } static int -drm_output_repaint(struct weston_output *output_base, - pixman_region32_t *damage, - void *repaint_data) +drm_output_repaint(struct weston_output *output_base, pixman_region32_t *damage) { struct drm_output *output = to_drm_output(output_base); struct drm_output_state *state = NULL; @@ -610,7 +608,7 @@ finish_frame: * a new pending_state structure to own any output state created by individual * output repaint functions until the repaint is flushed or cancelled. */ -static void * +static void drm_repaint_begin(struct weston_compositor *compositor) { struct drm_backend *b = to_drm_backend(compositor); @@ -626,8 +624,6 @@ drm_repaint_begin(struct weston_compositor *compositor) drm_debug(b, "%s", dbg); free(dbg); } - - return NULL; } /** @@ -640,7 +636,7 @@ drm_repaint_begin(struct weston_compositor *compositor) * state will be freed. */ static int -drm_repaint_flush(struct weston_compositor *compositor, void *repaint_data) +drm_repaint_flush(struct weston_compositor *compositor) { struct drm_backend *b = to_drm_backend(compositor); struct drm_pending_state *pending_state = b->repaint_data; @@ -663,7 +659,7 @@ drm_repaint_flush(struct weston_compositor *compositor, void *repaint_data) * held across the repaint cycle should be discarded. */ static void -drm_repaint_cancel(struct weston_compositor *compositor, void *repaint_data) +drm_repaint_cancel(struct weston_compositor *compositor) { struct drm_backend *b = to_drm_backend(compositor); struct drm_pending_state *pending_state = b->repaint_data; diff --git a/libweston/backend-drm/state-propose.c b/libweston/backend-drm/state-propose.c index d85ef0da..953e3a9f 100644 --- a/libweston/backend-drm/state-propose.c +++ b/libweston/backend-drm/state-propose.c @@ -889,7 +889,7 @@ err: } void -drm_assign_planes(struct weston_output *output_base, void *repaint_data) +drm_assign_planes(struct weston_output *output_base) { struct drm_backend *b = to_drm_backend(output_base->compositor); struct drm_pending_state *pending_state = b->repaint_data; diff --git a/libweston/backend-headless/headless.c b/libweston/backend-headless/headless.c index 5c4e4ccb..5f2f2898 100644 --- a/libweston/backend-headless/headless.c +++ b/libweston/backend-headless/headless.c @@ -122,8 +122,7 @@ finish_frame_handler(void *data) static int headless_output_repaint(struct weston_output *output_base, - pixman_region32_t *damage, - void *repaint_data) + pixman_region32_t *damage) { struct headless_output *output = to_headless_output(output_base); struct weston_compositor *ec = output->base.compositor; diff --git a/libweston/backend-rdp/rdp.c b/libweston/backend-rdp/rdp.c index 8e333f4c..2e869662 100644 --- a/libweston/backend-rdp/rdp.c +++ b/libweston/backend-rdp/rdp.c @@ -326,8 +326,7 @@ rdp_output_start_repaint_loop(struct weston_output *output) } static int -rdp_output_repaint(struct weston_output *output_base, pixman_region32_t *damage, - void *repaint_data) +rdp_output_repaint(struct weston_output *output_base, pixman_region32_t *damage) { struct rdp_output *output = container_of(output_base, struct rdp_output, base); struct weston_compositor *ec = output->base.compositor; diff --git a/libweston/backend-wayland/wayland.c b/libweston/backend-wayland/wayland.c index a3bbfbf1..825faed3 100644 --- a/libweston/backend-wayland/wayland.c +++ b/libweston/backend-wayland/wayland.c @@ -524,8 +524,7 @@ wayland_output_start_repaint_loop(struct weston_output *output_base) #ifdef ENABLE_EGL static int wayland_output_repaint_gl(struct weston_output *output_base, - pixman_region32_t *damage, - void *repaint_data) + pixman_region32_t *damage) { struct wayland_output *output = to_wayland_output(output_base); struct weston_compositor *ec = output->base.compositor; @@ -636,8 +635,7 @@ wayland_shm_buffer_attach(struct wayland_shm_buffer *sb) static int wayland_output_repaint_pixman(struct weston_output *output_base, - pixman_region32_t *damage, - void *repaint_data) + pixman_region32_t *damage) { struct wayland_output *output = to_wayland_output(output_base); struct wayland_backend *b = diff --git a/libweston/backend-x11/x11.c b/libweston/backend-x11/x11.c index 5c82584b..38c72379 100644 --- a/libweston/backend-x11/x11.c +++ b/libweston/backend-x11/x11.c @@ -417,8 +417,7 @@ x11_output_start_repaint_loop(struct weston_output *output) static int x11_output_repaint_gl(struct weston_output *output_base, - pixman_region32_t *damage, - void *repaint_data) + pixman_region32_t *damage) { struct x11_output *output = to_x11_output(output_base); struct weston_compositor *ec = output->base.compositor; @@ -486,8 +485,7 @@ set_clip_for_output(struct weston_output *output_base, pixman_region32_t *region static int x11_output_repaint_shm(struct weston_output *output_base, - pixman_region32_t *damage, - void *repaint_data) + pixman_region32_t *damage) { struct x11_output *output = to_x11_output(output_base); struct weston_compositor *ec = output->base.compositor; diff --git a/libweston/backend.h b/libweston/backend.h index af0d6671..4b19b399 100644 --- a/libweston/backend.h +++ b/libweston/backend.h @@ -46,27 +46,21 @@ struct weston_backend { * Returns an opaque pointer, which the backend may use as private * data referring to the repaint cycle. */ - void * (*repaint_begin)(struct weston_compositor *compositor); + void (*repaint_begin)(struct weston_compositor *compositor); /** Cancel a repaint sequence * * Cancels a repaint sequence, when an error has occurred during * one output's repaint; see repaint_begin. - * - * @param repaint_data Data returned by repaint_begin */ - void (*repaint_cancel)(struct weston_compositor *compositor, - void *repaint_data); + void (*repaint_cancel)(struct weston_compositor *compositor); /** Conclude a repaint sequence * * Called on successful completion of a repaint sequence; see * repaint_begin. - * - * @param repaint_data Data returned by repaint_begin */ - int (*repaint_flush)(struct weston_compositor *compositor, - void *repaint_data); + int (*repaint_flush)(struct weston_compositor *compositor); /** Allocate a new output * diff --git a/libweston/compositor.c b/libweston/compositor.c index 2c1dcf0d..34631716 100644 --- a/libweston/compositor.c +++ b/libweston/compositor.c @@ -2865,7 +2865,7 @@ weston_output_take_feedback_list(struct weston_output *output, } static int -weston_output_repaint(struct weston_output *output, void *repaint_data) +weston_output_repaint(struct weston_output *output) { struct weston_compositor *ec = output->compositor; struct weston_paint_node *pnode; @@ -2905,7 +2905,7 @@ weston_output_repaint(struct weston_output *output, void *repaint_data) output->desired_protection = highest_requested; if (output->assign_planes && !output->disable_planes) { - output->assign_planes(output, repaint_data); + output->assign_planes(output); } else { wl_list_for_each(pnode, &output->paint_node_z_order_list, z_order_link) { @@ -2940,7 +2940,7 @@ weston_output_repaint(struct weston_output *output, void *repaint_data) if (output->dirty) weston_output_update_matrix(output); - r = output->repaint(output, &output_damage, repaint_data); + r = output->repaint(output, &output_damage); pixman_region32_fini(&output_damage); @@ -2976,8 +2976,7 @@ weston_output_schedule_repaint_reset(struct weston_output *output) } static int -weston_output_maybe_repaint(struct weston_output *output, struct timespec *now, - void *repaint_data) +weston_output_maybe_repaint(struct weston_output *output, struct timespec *now) { struct weston_compositor *compositor = output->compositor; int ret = 0; @@ -3007,7 +3006,7 @@ weston_output_maybe_repaint(struct weston_output *output, struct timespec *now, * something schedules a successful repaint later. As repainting may * take some time, re-read our clock as a courtesy to the next * output. */ - ret = weston_output_repaint(output, repaint_data); + ret = weston_output_repaint(output); weston_compositor_read_presentation_clock(compositor, now); if (ret != 0) goto err; @@ -3065,29 +3064,26 @@ output_repaint_timer_handler(void *data) struct weston_compositor *compositor = data; struct weston_output *output; struct timespec now; - void *repaint_data = NULL; int ret = 0; weston_compositor_read_presentation_clock(compositor, &now); compositor->last_repaint_start = now; if (compositor->backend->repaint_begin) - repaint_data = compositor->backend->repaint_begin(compositor); + compositor->backend->repaint_begin(compositor); wl_list_for_each(output, &compositor->output_list, link) { - ret = weston_output_maybe_repaint(output, &now, repaint_data); + ret = weston_output_maybe_repaint(output, &now); if (ret) break; } if (ret == 0) { if (compositor->backend->repaint_flush) - ret = compositor->backend->repaint_flush(compositor, - repaint_data); + ret = compositor->backend->repaint_flush(compositor); } else { if (compositor->backend->repaint_cancel) - compositor->backend->repaint_cancel(compositor, - repaint_data); + compositor->backend->repaint_cancel(compositor); } if (ret != 0) {