From d82d74e71378ef3672e93d5cf6f28a7f25e02c42 Mon Sep 17 00:00:00 2001 From: Daniel Stone Date: Sat, 15 Jan 2022 17:56:15 +0000 Subject: [PATCH] pixman-renderer: Support solid-colour weston_buffers Just implemented via the same mechanism as surface_set_color. Signed-off-by: Daniel Stone --- libweston/pixman-renderer.c | 52 +++++++++++++++++++++++-------------- 1 file changed, 32 insertions(+), 20 deletions(-) diff --git a/libweston/pixman-renderer.c b/libweston/pixman-renderer.c index 32d28349..361ffa61 100644 --- a/libweston/pixman-renderer.c +++ b/libweston/pixman-renderer.c @@ -620,6 +620,26 @@ buffer_state_handle_buffer_destroy(struct wl_listener *listener, void *data) ps->buffer_destroy_listener.notify = NULL; } +static void +pixman_renderer_surface_set_color(struct weston_surface *es, + float red, float green, float blue, float alpha) +{ + struct pixman_surface_state *ps = get_surface_state(es); + pixman_color_t color; + + color.red = red * 0xffff; + color.green = green * 0xffff; + color.blue = blue * 0xffff; + color.alpha = alpha * 0xffff; + + if (ps->image) { + pixman_image_unref(ps->image); + ps->image = NULL; + } + + ps->image = pixman_image_create_solid_fill(&color); +} + static void pixman_renderer_attach(struct weston_surface *es, struct weston_buffer *buffer) { @@ -646,6 +666,18 @@ pixman_renderer_attach(struct weston_surface *es, struct weston_buffer *buffer) if (!buffer) return; + if (buffer->type == WESTON_BUFFER_SOLID) { + pixman_renderer_surface_set_color(es, + buffer->solid.r, + buffer->solid.g, + buffer->solid.b, + buffer->solid.a); + weston_buffer_reference(&ps->buffer_ref, NULL, + BUFFER_WILL_NOT_BE_ACCESSED); + weston_buffer_release_reference(&ps->buffer_release_ref, NULL); + return; + } + if (buffer->type != WESTON_BUFFER_SHM) { weston_log("Pixman renderer supports only SHM buffers\n"); weston_buffer_reference(&ps->buffer_ref, NULL, @@ -752,26 +784,6 @@ pixman_renderer_create_surface(struct weston_surface *surface) return 0; } -static void -pixman_renderer_surface_set_color(struct weston_surface *es, - float red, float green, float blue, float alpha) -{ - struct pixman_surface_state *ps = get_surface_state(es); - pixman_color_t color; - - color.red = red * 0xffff; - color.green = green * 0xffff; - color.blue = blue * 0xffff; - color.alpha = alpha * 0xffff; - - if (ps->image) { - pixman_image_unref(ps->image); - ps->image = NULL; - } - - ps->image = pixman_image_create_solid_fill(&color); -} - static void pixman_renderer_destroy(struct weston_compositor *ec) {