From 7222171d81394fbcf66bfdde138b393e2d8a1cc4 Mon Sep 17 00:00:00 2001 From: Philipp Zabel Date: Fri, 3 Feb 2023 16:55:00 +0100 Subject: [PATCH] backend-wayland: reuse backend->formats[0] as pixman/cairo/shm pixel format The pixel format stored in backends->format[0] is effectively looked up via pixel_format_get_info(DRM_FORMAT_ARGB8888). Reuse that instead of looking up the same via pixel_format_get_info_by_pixman(PIXMAN_a8r8g8b8) in multiple places. There are still two instances of hard-coded CAIRO_FORMAT_ARGB32 in wayland_output_get_shm_buffer() that currently can not be obtained from pixel_format_info. Signed-off-by: Philipp Zabel --- libweston/backend-wayland/wayland.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/libweston/backend-wayland/wayland.c b/libweston/backend-wayland/wayland.c index 9384cca24..63c72c950 100644 --- a/libweston/backend-wayland/wayland.c +++ b/libweston/backend-wayland/wayland.c @@ -297,6 +297,8 @@ wayland_output_get_shm_buffer(struct wayland_output *output) const struct weston_renderer *renderer; const struct pixman_renderer_interface *pixman; struct wayland_backend *b = output->backend; + const struct pixel_format_info *pfmt = b->formats[0]; + uint32_t shm_format = pixel_format_get_shm_format(pfmt); struct wl_shm *shm = b->parent.shm; struct wayland_shm_buffer *sb; @@ -367,7 +369,7 @@ wayland_output_get_shm_buffer(struct wayland_output *output) sb->buffer = wl_shm_pool_create_buffer(pool, 0, width, height, stride, - WL_SHM_FORMAT_ARGB8888); + shm_format); wl_buffer_add_listener(sb->buffer, &buffer_listener, sb); wl_shm_pool_destroy(pool); close(fd); @@ -393,9 +395,6 @@ wayland_output_get_shm_buffer(struct wayland_output *output) /* Address only the interior, excluding output decorations */ if (renderer->type == WESTON_RENDERER_PIXMAN) { - const struct pixel_format_info *pfmt; - - pfmt = pixel_format_get_info_by_pixman(PIXMAN_a8r8g8b8); sb->renderbuffer = pixman->create_image_from_ptr(&output->base, pfmt, area.width, area.height, @@ -786,7 +785,7 @@ wayland_output_init_pixman_renderer(struct wayland_output *output) .width = output->base.current_mode->width, .height = output->base.current_mode->height }, - .format = pixel_format_get_info_by_pixman(PIXMAN_a8r8g8b8) + .format = output->backend->formats[0] }; return renderer->pixman->output_create(&output->base, &options); }