From f4559b076008c7b562ba5a455250a9e557d097e6 Mon Sep 17 00:00:00 2001 From: Pekka Paalanen Date: Fri, 22 Jul 2022 14:47:03 +0300 Subject: [PATCH] pixman-renderer: pass initial size explicitly In a journey to decouple renderer from weston_output, pass the initial framebuffer size to Pixman-renderer explicitly. Now Pixman-renderer will never look into weston_output::current_mode. Signed-off-by: Pekka Paalanen --- libweston/backend-drm/drm.c | 1 + libweston/backend-headless/headless.c | 4 ++++ libweston/backend-rdp/rdp.c | 9 ++++++++- libweston/backend-wayland/wayland.c | 4 ++++ libweston/backend-x11/x11.c | 8 ++++++++ libweston/pixman-renderer.c | 10 +++------- libweston/pixman-renderer.h | 2 ++ 7 files changed, 30 insertions(+), 8 deletions(-) diff --git a/libweston/backend-drm/drm.c b/libweston/backend-drm/drm.c index b1b4e1c4..96b0373a 100644 --- a/libweston/backend-drm/drm.c +++ b/libweston/backend-drm/drm.c @@ -1186,6 +1186,7 @@ drm_output_init_pixman(struct drm_output *output, struct drm_backend *b) unsigned int i; const struct pixman_renderer_output_options options = { .use_shadow = b->use_pixman_shadow, + .fb_size = { .width = w, .height = h }, }; switch (format) { diff --git a/libweston/backend-headless/headless.c b/libweston/backend-headless/headless.c index 210b9564..c62d5d95 100644 --- a/libweston/backend-headless/headless.c +++ b/libweston/backend-headless/headless.c @@ -235,6 +235,10 @@ headless_output_enable_pixman(struct headless_output *output) const struct pixel_format_info *pfmt; const struct pixman_renderer_output_options options = { .use_shadow = true, + .fb_size = { + .width = output->base.current_mode->width, + .height = output->base.current_mode->height + }, }; pfmt = pixel_format_get_info(headless_formats[0]); diff --git a/libweston/backend-rdp/rdp.c b/libweston/backend-rdp/rdp.c index 894ae5d2..a704c0d3 100644 --- a/libweston/backend-rdp/rdp.c +++ b/libweston/backend-rdp/rdp.c @@ -345,7 +345,7 @@ rdp_switch_mode(struct weston_output *output, struct weston_mode *target_mode) rdpSettings *settings; pixman_image_t *new_shadow_buffer; struct weston_mode *local_mode; - const struct pixman_renderer_output_options options = { .use_shadow = true, }; + struct pixman_renderer_output_options options = { .use_shadow = true, }; assert(output); @@ -364,6 +364,9 @@ rdp_switch_mode(struct weston_output *output, struct weston_mode *target_mode) output->current_mode->flags |= WL_OUTPUT_MODE_CURRENT; pixman_renderer_output_destroy(output); + + options.fb_size.width = output->current_mode->width; + options.fb_size.height = output->current_mode->height; pixman_renderer_output_create(output, &options); new_shadow_buffer = pixman_image_create_bits(PIXMAN_x8r8g8b8, target_mode->width, @@ -442,6 +445,10 @@ rdp_output_enable(struct weston_output *base) struct wl_event_loop *loop; const struct pixman_renderer_output_options options = { .use_shadow = true, + .fb_size = { + .width = output->base.current_mode->width, + .height = output->base.current_mode->height + }, }; assert(output); diff --git a/libweston/backend-wayland/wayland.c b/libweston/backend-wayland/wayland.c index bc4b5ed5..edf61828 100644 --- a/libweston/backend-wayland/wayland.c +++ b/libweston/backend-wayland/wayland.c @@ -823,6 +823,10 @@ wayland_output_init_pixman_renderer(struct wayland_output *output) { const struct pixman_renderer_output_options options = { .use_shadow = true, + .fb_size = { + .width = output->base.current_mode->width, + .height = output->base.current_mode->height + }, }; return pixman_renderer_output_create(&output->base, &options); } diff --git a/libweston/backend-x11/x11.c b/libweston/backend-x11/x11.c index e63705f9..d589a778 100644 --- a/libweston/backend-x11/x11.c +++ b/libweston/backend-x11/x11.c @@ -859,6 +859,10 @@ x11_output_switch_mode(struct weston_output *base, struct weston_mode *mode) if (b->use_pixman) { const struct pixman_renderer_output_options options = { .use_shadow = true, + .fb_size = { + .width = output->base.current_mode->width, + .height = output->base.current_mode->height + }, }; pixman_renderer_output_destroy(&output->base); x11_output_deinit_shm(b, output); @@ -1049,6 +1053,10 @@ x11_output_enable(struct weston_output *base) if (b->use_pixman) { const struct pixman_renderer_output_options options = { .use_shadow = true, + .fb_size = { + .width = mode->width, + .height = mode->height + }, }; if (x11_output_init_shm(b, output, mode->width, mode->height) < 0) { diff --git a/libweston/pixman-renderer.c b/libweston/pixman-renderer.c index 8c52e59f..dd0a70d0 100644 --- a/libweston/pixman-renderer.c +++ b/libweston/pixman-renderer.c @@ -986,12 +986,8 @@ pixman_renderer_output_create(struct weston_output *output, struct weston_geometry area = { .x = 0, .y = 0, - .width = output->current_mode->width, - .height = output->current_mode->height - }; - struct weston_size fb_size = { - .width = area.width, - .height = area.height + .width = options->fb_size.width, + .height = options->fb_size.height }; po = zalloc(sizeof *po); @@ -1003,7 +999,7 @@ pixman_renderer_output_create(struct weston_output *output, if (options->use_shadow) po->shadow_format = pixel_format_get_info(DRM_FORMAT_XRGB8888); - if (!pixman_renderer_resize_output(output, &fb_size, &area)) { + if (!pixman_renderer_resize_output(output, &options->fb_size, &area)) { output->renderer_state = NULL; free(po); return -1; diff --git a/libweston/pixman-renderer.h b/libweston/pixman-renderer.h index 2b81dde5..3449048c 100644 --- a/libweston/pixman-renderer.h +++ b/libweston/pixman-renderer.h @@ -35,6 +35,8 @@ pixman_renderer_init(struct weston_compositor *ec); struct pixman_renderer_output_options { /** Composite into a shadow buffer, copying to the hardware buffer */ bool use_shadow; + /** Initial framebuffer size */ + struct weston_size fb_size; }; int