From 6757bae0f34926be6b3abf56e7887226e6ff33b6 Mon Sep 17 00:00:00 2001 From: Philipp Zabel Date: Wed, 11 Jan 2023 23:01:15 +0100 Subject: [PATCH] pixman-renderer: set renderbuffer via new repaint_output parameter Add a struct weston_renderbuffer parameter to repaint_output and make backends set the pixman image renderbuffer through this parameter instead of using pixman_renderer_output_set_buffer() Turn pixman_renderer_output_set_buffer() static. Signed-off-by: Philipp Zabel --- libweston/backend-drm/drm-gbm.c | 2 +- libweston/backend-drm/drm.c | 5 ++--- libweston/backend-headless/headless.c | 11 ++++++++--- libweston/backend-rdp/rdp.c | 5 ++--- libweston/backend-vnc/vnc.c | 6 ++---- libweston/backend-wayland/wayland.c | 6 +++--- libweston/backend-x11/x11.c | 5 ++--- libweston/libweston-internal.h | 3 ++- libweston/noop-renderer.c | 3 ++- libweston/pixman-renderer.c | 13 +++++++++++-- libweston/pixman-renderer.h | 4 ---- libweston/renderer-gl/gl-renderer.c | 3 ++- 12 files changed, 37 insertions(+), 29 deletions(-) diff --git a/libweston/backend-drm/drm-gbm.c b/libweston/backend-drm/drm-gbm.c index a46d59a1..bfd72b63 100644 --- a/libweston/backend-drm/drm-gbm.c +++ b/libweston/backend-drm/drm-gbm.c @@ -296,7 +296,7 @@ drm_output_render_gl(struct drm_output_state *state, pixman_region32_t *damage) struct drm_fb *ret; output->base.compositor->renderer->repaint_output(&output->base, - damage); + damage, NULL); bo = gbm_surface_lock_front_buffer(output->gbm_surface); if (!bo) { diff --git a/libweston/backend-drm/drm.c b/libweston/backend-drm/drm.c index e4999495..3060e73d 100644 --- a/libweston/backend-drm/drm.c +++ b/libweston/backend-drm/drm.c @@ -343,12 +343,11 @@ drm_output_render_pixman(struct drm_output_state *state, output->current_image ^= 1; - pixman_renderer_output_set_buffer(&output->base, - output->renderbuffer[output->current_image]->image); pixman_renderer_output_set_hw_extra_damage(&output->base, &output->previous_damage); - ec->renderer->repaint_output(&output->base, damage); + ec->renderer->repaint_output(&output->base, damage, + output->renderbuffer[output->current_image]); pixman_region32_copy(&output->previous_damage, damage); diff --git a/libweston/backend-headless/headless.c b/libweston/backend-headless/headless.c index 67ae6a0c..23a62a31 100644 --- a/libweston/backend-headless/headless.c +++ b/libweston/backend-headless/headless.c @@ -47,6 +47,7 @@ #include "shared/weston-egl-ext.h" #include "shared/cairo-util.h" #include "linux-dmabuf.h" +#include "output-capture.h" #include "presentation-time-server-protocol.h" #include @@ -159,7 +160,8 @@ headless_output_repaint(struct weston_output *output_base, headless_output_update_gl_border(output); - ec->renderer->repaint_output(&output->base, damage); + ec->renderer->repaint_output(&output->base, damage, + output->renderbuffer); pixman_region32_subtract(&ec->primary_plane.damage, &ec->primary_plane.damage, damage); @@ -315,8 +317,11 @@ headless_output_enable_pixman(struct headless_output *output) if (pixman->output_create(&output->base, &options) < 0) goto err_renderer; - pixman_renderer_output_set_buffer(&output->base, - output->renderbuffer->image); + weston_output_update_capture_info(&output->base, + WESTON_OUTPUT_CAPTURE_SOURCE_FRAMEBUFFER, + output->base.current_mode->width, + output->base.current_mode->height, + pfmt); return 0; diff --git a/libweston/backend-rdp/rdp.c b/libweston/backend-rdp/rdp.c index e3d7c4f3..8193a706 100644 --- a/libweston/backend-rdp/rdp.c +++ b/libweston/backend-rdp/rdp.c @@ -295,9 +295,8 @@ rdp_output_repaint(struct weston_output *output_base, pixman_region32_t *damage) assert(output); - pixman_renderer_output_set_buffer(output_base, - output->renderbuffer->image); - ec->renderer->repaint_output(&output->base, damage); + ec->renderer->repaint_output(&output->base, damage, + output->renderbuffer); if (pixman_region32_not_empty(damage)) { pixman_region32_t transformed_damage; diff --git a/libweston/backend-vnc/vnc.c b/libweston/backend-vnc/vnc.c index 41055bbd..806fd349 100644 --- a/libweston/backend-vnc/vnc.c +++ b/libweston/backend-vnc/vnc.c @@ -527,10 +527,8 @@ vnc_update_buffer(struct nvnc_display *display, struct pixman_region32 *damage) wl_list_insert(&output->fb_side_data_list, &fb_side_data->link); } - pixman_renderer_output_set_buffer(&output->base, - fb_side_data->renderbuffer->image); - - ec->renderer->repaint_output(&output->base, &fb_side_data->damage); + ec->renderer->repaint_output(&output->base, &fb_side_data->damage, + fb_side_data->renderbuffer); /* Convert to local coordinates before clearing accumulated damage */ pixman_region_init(&local_damage); diff --git a/libweston/backend-wayland/wayland.c b/libweston/backend-wayland/wayland.c index 7615adff..544595af 100644 --- a/libweston/backend-wayland/wayland.c +++ b/libweston/backend-wayland/wayland.c @@ -515,7 +515,7 @@ wayland_output_repaint_gl(struct weston_output *output_base, wayland_output_update_gl_border(output); - ec->renderer->repaint_output(&output->base, damage); + ec->renderer->repaint_output(&output->base, damage, NULL); pixman_region32_subtract(&ec->primary_plane.damage, &ec->primary_plane.damage, damage); @@ -630,8 +630,8 @@ wayland_output_repaint_pixman(struct weston_output *output_base, sb = wayland_output_get_shm_buffer(output); wayland_output_update_shm_border(sb); - pixman_renderer_output_set_buffer(output_base, sb->renderbuffer->image); - b->compositor->renderer->repaint_output(output_base, &sb->damage); + b->compositor->renderer->repaint_output(output_base, &sb->damage, + sb->renderbuffer); wayland_shm_buffer_attach(sb); diff --git a/libweston/backend-x11/x11.c b/libweston/backend-x11/x11.c index 22e3db26..880ebf7f 100644 --- a/libweston/backend-x11/x11.c +++ b/libweston/backend-x11/x11.c @@ -435,7 +435,7 @@ x11_output_repaint_gl(struct weston_output *output_base, ec = output->base.compositor; - ec->renderer->repaint_output(output_base, damage); + ec->renderer->repaint_output(output_base, damage, NULL); pixman_region32_subtract(&ec->primary_plane.damage, &ec->primary_plane.damage, damage); @@ -512,8 +512,7 @@ x11_output_repaint_shm(struct weston_output *output_base, ec = output->base.compositor; b = output->backend; - pixman_renderer_output_set_buffer(output_base, image); - ec->renderer->repaint_output(output_base, damage); + ec->renderer->repaint_output(output_base, damage, output->renderbuffer); pixman_region32_subtract(&ec->primary_plane.damage, &ec->primary_plane.damage, damage); diff --git a/libweston/libweston-internal.h b/libweston/libweston-internal.h index fc70577f..00a4e130 100644 --- a/libweston/libweston-internal.h +++ b/libweston/libweston-internal.h @@ -59,7 +59,8 @@ struct weston_renderer { uint32_t x, uint32_t y, uint32_t width, uint32_t height); void (*repaint_output)(struct weston_output *output, - pixman_region32_t *output_damage); + pixman_region32_t *output_damage, + struct weston_renderbuffer *renderbuffer); /** See weston_renderer_resize_output() * diff --git a/libweston/noop-renderer.c b/libweston/noop-renderer.c index be9d78f6..7a07fb10 100644 --- a/libweston/noop-renderer.c +++ b/libweston/noop-renderer.c @@ -47,7 +47,8 @@ noop_renderer_read_pixels(struct weston_output *output, static void noop_renderer_repaint_output(struct weston_output *output, - pixman_region32_t *output_damage) + pixman_region32_t *output_damage, + struct weston_renderbuffer *renderbuffer) { } diff --git a/libweston/pixman-renderer.c b/libweston/pixman-renderer.c index bac60802..9bad4652 100644 --- a/libweston/pixman-renderer.c +++ b/libweston/pixman-renderer.c @@ -617,13 +617,22 @@ pixman_renderer_do_capture_tasks(struct weston_output *output, } } +static void +pixman_renderer_output_set_buffer(struct weston_output *output, + pixman_image_t *buffer); + static void pixman_renderer_repaint_output(struct weston_output *output, - pixman_region32_t *output_damage) + pixman_region32_t *output_damage, + struct weston_renderbuffer *renderbuffer) { struct pixman_output_state *po = get_output_state(output); pixman_region32_t hw_damage; + assert(renderbuffer); + + pixman_renderer_output_set_buffer(output, renderbuffer->image); + assert(output->from_blend_to_output_by_backend || output->color_outcome->from_blend_to_output == NULL); @@ -1018,7 +1027,7 @@ pixman_renderer_init(struct weston_compositor *ec) return 0; } -WL_EXPORT void +static void pixman_renderer_output_set_buffer(struct weston_output *output, pixman_image_t *buffer) { diff --git a/libweston/pixman-renderer.h b/libweston/pixman-renderer.h index 8b5e7f05..a54ce6aa 100644 --- a/libweston/pixman-renderer.h +++ b/libweston/pixman-renderer.h @@ -40,10 +40,6 @@ struct pixman_renderer_output_options { struct weston_size fb_size; }; -void -pixman_renderer_output_set_buffer(struct weston_output *output, - pixman_image_t *buffer); - void pixman_renderer_output_set_hw_extra_damage(struct weston_output *output, pixman_region32_t *extra_damage); diff --git a/libweston/renderer-gl/gl-renderer.c b/libweston/renderer-gl/gl-renderer.c index 6afb7af6..5eeb56df 100644 --- a/libweston/renderer-gl/gl-renderer.c +++ b/libweston/renderer-gl/gl-renderer.c @@ -1716,7 +1716,8 @@ blit_shadow_to_output(struct weston_output *output, */ static void gl_renderer_repaint_output(struct weston_output *output, - pixman_region32_t *output_damage) + pixman_region32_t *output_damage, + struct weston_renderbuffer *renderbuffer) { struct gl_output_state *go = get_output_state(output); struct weston_compositor *compositor = output->compositor;