From dbe5b5376683cb64ea2ead625b7391b6198829e3 Mon Sep 17 00:00:00 2001 From: Philipp Zabel Date: Thu, 15 Jun 2023 15:38:25 +0200 Subject: [PATCH] backend-rdp: add pixel format info array Store pixel formats on the backend and stop open coding Pixman format codes. Signed-off-by: Philipp Zabel --- libweston/backend-rdp/meson.build | 1 + libweston/backend-rdp/rdp.c | 19 +++++++++++++------ libweston/backend-rdp/rdp.h | 3 +++ 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/libweston/backend-rdp/meson.build b/libweston/backend-rdp/meson.build index 9b2ed030..4245252c 100644 --- a/libweston/backend-rdp/meson.build +++ b/libweston/backend-rdp/meson.build @@ -24,6 +24,7 @@ deps_rdp = [ dep_frdp, dep_frdp_server, dep_wpr, + dep_libdrm_headers, ] srcs_rdp = [ 'rdp.c', diff --git a/libweston/backend-rdp/rdp.c b/libweston/backend-rdp/rdp.c index 7ebe78ab..91100811 100644 --- a/libweston/backend-rdp/rdp.c +++ b/libweston/backend-rdp/rdp.c @@ -26,6 +26,7 @@ #include "config.h" #include +#include #include #include #include @@ -401,15 +402,13 @@ rdp_output_set_mode(struct weston_output *base, struct weston_mode *mode) base->native_mode = cur; if (base->enabled) { const struct weston_renderer *renderer; - const struct pixel_format_info *pfmt; pixman_image_t *new_image; weston_renderer_resize_output(output, &(struct weston_size){ .width = output->current_mode->width, .height = output->current_mode->height }, NULL); - pfmt = pixel_format_get_info_by_pixman(PIXMAN_x8r8g8b8); - new_image = pixman_image_create_bits(pfmt->pixman_format, + new_image = pixman_image_create_bits(b->formats[0]->pixman_format, mode->width, mode->height, NULL, mode->width * 4); renderer = b->compositor->renderer; @@ -419,7 +418,7 @@ rdp_output_set_mode(struct weston_output *base, struct weston_mode *mode) pixman = renderer->pixman; new_renderbuffer = - pixman->create_image_from_ptr(output, pfmt, + pixman->create_image_from_ptr(output, b->formats[0], mode->width, mode->height, pixman_image_get_data(new_image), mode->width * 4); @@ -493,7 +492,7 @@ rdp_output_enable(struct weston_output *base) b = output->backend; - output->shadow_surface = pixman_image_create_bits(PIXMAN_x8r8g8b8, + output->shadow_surface = pixman_image_create_bits(b->formats[0]->pixman_format, output->base.current_mode->width, output->base.current_mode->height, NULL, @@ -506,7 +505,7 @@ rdp_output_enable(struct weston_output *base) .width = output->base.current_mode->width, .height = output->base.current_mode->height }, - .format = pixel_format_get_info_by_pixman(PIXMAN_x8r8g8b8) + .format = b->formats[0], }; if (renderer->pixman->output_create(&output->base, &options) < 0) { @@ -1822,6 +1821,11 @@ static const struct weston_rdp_output_api api = { rdp_output_set_mode, }; +static const uint32_t rdp_formats[] = { + DRM_FORMAT_XRGB8888, + DRM_FORMAT_ARGB8888, +}; + static struct rdp_backend * rdp_backend_create(struct weston_compositor *compositor, struct weston_rdp_backend_config *config) @@ -1900,6 +1904,9 @@ rdp_backend_create(struct weston_compositor *compositor, if (weston_compositor_set_presentation_clock_software(compositor) < 0) goto err_compositor; + b->formats_count = ARRAY_LENGTH(rdp_formats); + b->formats = pixel_format_get_array(rdp_formats, b->formats_count); + switch (config->renderer) { case WESTON_RENDERER_PIXMAN: case WESTON_RENDERER_AUTO: diff --git a/libweston/backend-rdp/rdp.h b/libweston/backend-rdp/rdp.h index 6433b615..195e3f8e 100644 --- a/libweston/backend-rdp/rdp.h +++ b/libweston/backend-rdp/rdp.h @@ -99,6 +99,9 @@ struct rdp_backend { rdp_audio_out_teardown audio_out_teardown; uint32_t head_index; + + const struct pixel_format_info **formats; + unsigned int formats_count; }; enum peer_item_flags {