diff --git a/libweston/backend-drm/drm.c b/libweston/backend-drm/drm.c index 9780d7980..0e912bf35 100644 --- a/libweston/backend-drm/drm.c +++ b/libweston/backend-drm/drm.c @@ -1180,19 +1180,16 @@ drm_output_init_pixman(struct drm_output *output, struct drm_backend *b) int w = output->base.current_mode->width; int h = output->base.current_mode->height; uint32_t format = output->gbm_format; - uint32_t pixman_format; unsigned int i; const struct pixman_renderer_output_options options = { .use_shadow = b->use_pixman_shadow, .fb_size = { .width = w, .height = h }, + .format = pixel_format_get_info(format) }; switch (format) { case DRM_FORMAT_XRGB8888: - pixman_format = PIXMAN_x8r8g8b8; - break; case DRM_FORMAT_RGB565: - pixman_format = PIXMAN_r5g6b5; break; default: weston_log("Unsupported pixman format 0x%x\n", format); @@ -1210,7 +1207,7 @@ drm_output_init_pixman(struct drm_output *output, struct drm_backend *b) output->renderbuffer[i] = pixman->create_image_from_ptr(&output->base, - pixman_format, w, h, + options.format, w, h, output->dumb[i]->map, output->dumb[i]->strides[0]); if (!output->renderbuffer[i]) diff --git a/libweston/backend-headless/headless.c b/libweston/backend-headless/headless.c index e6689bf8b..8e9127407 100644 --- a/libweston/backend-headless/headless.c +++ b/libweston/backend-headless/headless.c @@ -295,24 +295,22 @@ static int headless_output_enable_pixman(struct headless_output *output) { const struct pixman_renderer_interface *pixman; - 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 }, - .drm_format = headless_formats[0] + .format = pixel_format_get_info(headless_formats[0]) }; pixman = output->base.compositor->renderer->pixman; - pfmt = pixel_format_get_info(headless_formats[0]); if (pixman->output_create(&output->base, &options) < 0) return -1; output->renderbuffer = - pixman->create_image(&output->base, pfmt->pixman_format, + pixman->create_image(&output->base, options.format, output->base.current_mode->width, output->base.current_mode->height); if (!output->renderbuffer) diff --git a/libweston/backend-rdp/rdp.c b/libweston/backend-rdp/rdp.c index b68e4fd5d..b2ac9398d 100644 --- a/libweston/backend-rdp/rdp.c +++ b/libweston/backend-rdp/rdp.c @@ -42,6 +42,7 @@ #include "shared/xalloc.h" #include #include +#include #include "pixman-renderer.h" /* These can be removed when we bump FreeRDP dependency past 3.0.0 in the future */ @@ -405,6 +406,7 @@ rdp_output_set_mode(struct weston_output *base, struct weston_mode *mode) base->native_mode = cur; if (base->enabled) { const struct pixman_renderer_interface *pixman; + const struct pixel_format_info *pfmt; pixman_image_t *old_image, *new_image; weston_renderer_resize_output(output, &(struct weston_size){ @@ -415,8 +417,9 @@ rdp_output_set_mode(struct weston_output *base, struct weston_mode *mode) old_image = pixman->renderbuffer_get_image(rdpOutput->renderbuffer); + pfmt = pixel_format_get_info_by_pixman(PIXMAN_x8r8g8b8); new_renderbuffer = - pixman->create_image_from_ptr(output, PIXMAN_x8r8g8b8, + pixman->create_image_from_ptr(output, pfmt, mode->width, mode->height, 0, mode->width * 4); new_image = pixman->renderbuffer_get_image(new_renderbuffer); @@ -483,6 +486,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) }; assert(output); @@ -494,7 +498,7 @@ rdp_output_enable(struct weston_output *base) } output->renderbuffer = - pixman->create_image_from_ptr(&output->base, PIXMAN_x8r8g8b8, + pixman->create_image_from_ptr(&output->base, options.format, output->base.current_mode->width, output->base.current_mode->height, NULL, diff --git a/libweston/backend-vnc/vnc.c b/libweston/backend-vnc/vnc.c index ace6119d2..f5e8777a9 100644 --- a/libweston/backend-vnc/vnc.c +++ b/libweston/backend-vnc/vnc.c @@ -512,8 +512,7 @@ vnc_update_buffer(struct nvnc_display *display, struct pixman_region32 *damage) pfmt = pixel_format_get_info(DRM_FORMAT_XRGB8888); fb_side_data->renderer = ec->renderer; fb_side_data->renderbuffer = - pixman->create_image_from_ptr(&output->base, - pfmt->pixman_format, + pixman->create_image_from_ptr(&output->base, pfmt, output->base.width, output->base.height, nvnc_fb_get_addr(fb), @@ -614,6 +613,7 @@ vnc_output_enable(struct weston_output *base) .width = output->base.width, .height = output->base.height, }, + .format = pixel_format_get_info(DRM_FORMAT_XRGB8888), }; assert(output); @@ -631,7 +631,7 @@ vnc_output_enable(struct weston_output *base) output->fb_pool = nvnc_fb_pool_new(output->base.width, output->base.height, - DRM_FORMAT_XRGB8888, + options.format->format, output->base.width); output->display = nvnc_display_new(0, 0); diff --git a/libweston/backend-wayland/wayland.c b/libweston/backend-wayland/wayland.c index 9f11b3477..2f13af136 100644 --- a/libweston/backend-wayland/wayland.c +++ b/libweston/backend-wayland/wayland.c @@ -61,6 +61,7 @@ #include "xdg-shell-client-protocol.h" #include "presentation-time-server-protocol.h" #include "linux-dmabuf.h" +#include #include #define WINDOW_TITLE "Weston Compositor" @@ -388,8 +389,11 @@ 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, PIXMAN_a8r8g8b8, + pixman->create_image_from_ptr(&output->base, pfmt, area.width, area.height, (uint32_t *)(data + area.y * stride) + area.x, stride); diff --git a/libweston/backend-x11/x11.c b/libweston/backend-x11/x11.c index edb2abb05..a7836c63c 100644 --- a/libweston/backend-x11/x11.c +++ b/libweston/backend-x11/x11.c @@ -63,6 +63,7 @@ #include "presentation-time-server-protocol.h" #include "linux-dmabuf.h" #include "linux-explicit-synchronization.h" +#include #include #define DEFAULT_AXIS_STEP_DISTANCE 10 @@ -731,7 +732,7 @@ x11_output_init_shm(struct x11_backend *b, struct x11_output *output, xcb_generic_error_t *err; const xcb_query_extension_reply_t *ext; int bitsperpixel = 0; - pixman_format_code_t pixman_format; + const struct pixel_format_info *pfmt; /* Check if SHM is available */ ext = xcb_get_extension_data(b->conn, &xcb_shm_id); @@ -773,13 +774,13 @@ x11_output_init_shm(struct x11_backend *b, struct x11_output *output, visual_type->green_mask == 0x00ff00 && visual_type->blue_mask == 0x0000ff) { weston_log("Will use x8r8g8b8 format for SHM surfaces\n"); - pixman_format = PIXMAN_x8r8g8b8; + pfmt = pixel_format_get_info_by_pixman(PIXMAN_x8r8g8b8); } else if (bitsperpixel == 16 && visual_type->red_mask == 0x00f800 && visual_type->green_mask == 0x0007e0 && visual_type->blue_mask == 0x00001f) { weston_log("Will use r5g6b5 format for SHM surfaces\n"); - pixman_format = PIXMAN_r5g6b5; + pfmt = pixel_format_get_info_by_pixman(PIXMAN_r5g6b5); } else { weston_log("Can't find appropriate format for SHM pixmap\n"); errno = ENOTSUP; @@ -813,8 +814,8 @@ x11_output_init_shm(struct x11_backend *b, struct x11_output *output, /* Now create pixman image */ output->renderbuffer = renderer->pixman->create_image_from_ptr(&output->base, - pixman_format, width, - height, output->buf, + pfmt, width, height, + output->buf, width * (bitsperpixel / 8)); output->gc = xcb_generate_id(b->conn); diff --git a/libweston/pixman-renderer.c b/libweston/pixman-renderer.c index 643f79456..b3bbfdce5 100644 --- a/libweston/pixman-renderer.c +++ b/libweston/pixman-renderer.c @@ -1109,7 +1109,7 @@ pixman_renderer_output_create(struct weston_output *output, weston_output_update_capture_info(output, WESTON_OUTPUT_CAPTURE_SOURCE_FRAMEBUFFER, area.width, area.height, - options->drm_format); + options->format->format); return 0; } @@ -1138,8 +1138,9 @@ pixman_renderer_renderbuffer_destroy(struct weston_renderbuffer *renderbuffer); static struct weston_renderbuffer * pixman_renderer_create_image_from_ptr(struct weston_output *output, - pixman_format_code_t format, int width, - int height, uint32_t *ptr, int rowstride) + const struct pixel_format_info *format, + int width, int height, uint32_t *ptr, + int rowstride) { struct pixman_output_state *po = get_output_state(output); struct pixman_renderbuffer *renderbuffer; @@ -1148,8 +1149,9 @@ pixman_renderer_create_image_from_ptr(struct weston_output *output, renderbuffer = xzalloc(sizeof(*renderbuffer)); - renderbuffer->image = pixman_image_create_bits(format, width, height, - ptr, rowstride); + renderbuffer->image = pixman_image_create_bits(format->pixman_format, + width, height, ptr, + rowstride); if (!renderbuffer->image) { free(renderbuffer); return NULL; @@ -1165,7 +1167,8 @@ pixman_renderer_create_image_from_ptr(struct weston_output *output, static struct weston_renderbuffer * pixman_renderer_create_image(struct weston_output *output, - pixman_format_code_t format, int width, int height) + const struct pixel_format_info *format, int width, + int height) { struct pixman_output_state *po = get_output_state(output); struct pixman_renderbuffer *renderbuffer; @@ -1175,8 +1178,8 @@ pixman_renderer_create_image(struct weston_output *output, renderbuffer = xzalloc(sizeof(*renderbuffer)); renderbuffer->image = - pixman_image_create_bits_no_clear(format, width, height, - NULL, 0); + pixman_image_create_bits_no_clear(format->pixman_format, width, + height, NULL, 0); if (!renderbuffer->image) { free(renderbuffer); return NULL; diff --git a/libweston/pixman-renderer.h b/libweston/pixman-renderer.h index e67501add..e508ef87e 100644 --- a/libweston/pixman-renderer.h +++ b/libweston/pixman-renderer.h @@ -38,8 +38,8 @@ struct pixman_renderer_output_options { bool use_shadow; /** Initial framebuffer size */ struct weston_size fb_size; - /** Initial DRM pixel format */ - uint32_t drm_format; + /** Initial pixel format */ + const struct pixel_format_info *format; }; struct pixman_renderer_interface { @@ -48,13 +48,13 @@ struct pixman_renderer_interface { void (*output_destroy)(struct weston_output *output); struct weston_renderbuffer *(*create_image_from_ptr)(struct weston_output *output, - pixman_format_code_t format, + const struct pixel_format_info *format, int width, int height, uint32_t *ptr, int stride); struct weston_renderbuffer *(*create_image)(struct weston_output *output, - pixman_format_code_t format, + const struct pixel_format_info *format, int width, int height); pixman_image_t *(*renderbuffer_get_image)(struct weston_renderbuffer *renderbuffer); };