From c9253c00129ea2e266299f3a71868649fc28a937 Mon Sep 17 00:00:00 2001 From: Daniel Stone Date: Wed, 19 Jan 2022 03:11:40 +0000 Subject: [PATCH] renderer: Set surface->is_opaque in the core No need for the renderers to do this now that we know what all of the formats are. Signed-off-by: Daniel Stone --- libweston/compositor.c | 4 ++++ libweston/pixman-renderer.c | 2 -- libweston/renderer-gl/gl-renderer.c | 20 -------------------- 3 files changed, 4 insertions(+), 22 deletions(-) diff --git a/libweston/compositor.c b/libweston/compositor.c index c0b8f428..a9f043ba 100644 --- a/libweston/compositor.c +++ b/libweston/compositor.c @@ -2656,6 +2656,7 @@ weston_surface_attach_solid(struct weston_surface *surface, surface->is_opaque = true; pixman_region32_init_rect(&surface->opaque, 0, 0, w, h); } else { + surface->is_opaque = false; pixman_region32_init(&surface->opaque); } } @@ -2688,6 +2689,9 @@ weston_surface_attach(struct weston_surface *surface, weston_surface_calculate_size_from_buffer(surface); weston_presentation_feedback_discard_list(&surface->feedback_list); + + if (buffer) + surface->is_opaque = pixel_format_is_opaque(buffer->pixel_format); } /** weston_compositor_damage_all diff --git a/libweston/pixman-renderer.c b/libweston/pixman-renderer.c index 64d6bd17..c1ed560f 100644 --- a/libweston/pixman-renderer.c +++ b/libweston/pixman-renderer.c @@ -714,8 +714,6 @@ pixman_renderer_attach(struct weston_surface *es, struct weston_buffer *buffer) return; } - es->is_opaque = pixel_format_is_opaque(pixel_info); - ps->image = pixman_image_create_bits(pixel_info->pixman_format, buffer->width, buffer->height, wl_shm_buffer_get_data(shm_buffer), diff --git a/libweston/renderer-gl/gl-renderer.c b/libweston/renderer-gl/gl-renderer.c index 0c784537..8abbce71 100644 --- a/libweston/renderer-gl/gl-renderer.c +++ b/libweston/renderer-gl/gl-renderer.c @@ -1994,21 +1994,18 @@ gl_renderer_attach_shm(struct weston_surface *es, struct weston_buffer *buffer) pitch = wl_shm_buffer_get_stride(shm_buffer) / 4; gl_format[0] = GL_BGRA_EXT; gl_pixel_type = GL_UNSIGNED_BYTE; - es->is_opaque = true; break; case WL_SHM_FORMAT_ARGB8888: gb->shader_variant = SHADER_VARIANT_RGBA; pitch = wl_shm_buffer_get_stride(shm_buffer) / 4; gl_format[0] = GL_BGRA_EXT; gl_pixel_type = GL_UNSIGNED_BYTE; - es->is_opaque = false; break; case WL_SHM_FORMAT_RGB565: gb->shader_variant = SHADER_VARIANT_RGBX; pitch = wl_shm_buffer_get_stride(shm_buffer) / 2; gl_format[0] = GL_RGB; gl_pixel_type = GL_UNSIGNED_SHORT_5_6_5; - es->is_opaque = true; break; #if __BYTE_ORDER == __LITTLE_ENDIAN case WL_SHM_FORMAT_ABGR2101010: @@ -2019,7 +2016,6 @@ gl_renderer_attach_shm(struct weston_surface *es, struct weston_buffer *buffer) pitch = wl_shm_buffer_get_stride(shm_buffer) / 4; gl_format[0] = using_glesv2 ? GL_RGBA : GL_RGB10_A2; gl_pixel_type = GL_UNSIGNED_INT_2_10_10_10_REV_EXT; - es->is_opaque = false; break; case WL_SHM_FORMAT_XBGR2101010: if (!gr->has_texture_type_2_10_10_10_rev) { @@ -2029,7 +2025,6 @@ gl_renderer_attach_shm(struct weston_surface *es, struct weston_buffer *buffer) pitch = wl_shm_buffer_get_stride(shm_buffer) / 4; gl_format[0] = using_glesv2 ? GL_RGBA : GL_RGB10_A2; gl_pixel_type = GL_UNSIGNED_INT_2_10_10_10_REV_EXT; - es->is_opaque = true; break; case WL_SHM_FORMAT_ABGR16161616F: if (!gr->gl_supports_color_transforms) @@ -2038,7 +2033,6 @@ gl_renderer_attach_shm(struct weston_surface *es, struct weston_buffer *buffer) pitch = wl_shm_buffer_get_stride(shm_buffer) / 8; gl_format[0] = GL_RGBA16F; gl_pixel_type = GL_HALF_FLOAT; - es->is_opaque = false; break; case WL_SHM_FORMAT_XBGR16161616F: if (!gr->gl_supports_color_transforms) @@ -2047,7 +2041,6 @@ gl_renderer_attach_shm(struct weston_surface *es, struct weston_buffer *buffer) pitch = wl_shm_buffer_get_stride(shm_buffer) / 8; gl_format[0] = GL_RGBA16F; gl_pixel_type = GL_HALF_FLOAT; - es->is_opaque = true; break; case WL_SHM_FORMAT_ABGR16161616: if (!gr->has_texture_norm16) @@ -2056,7 +2049,6 @@ gl_renderer_attach_shm(struct weston_surface *es, struct weston_buffer *buffer) pitch = wl_shm_buffer_get_stride(shm_buffer) / 8; gl_format[0] = GL_RGBA16_EXT; gl_pixel_type = GL_UNSIGNED_SHORT; - es->is_opaque = false; break; case WL_SHM_FORMAT_XBGR16161616: if (!gr->has_texture_norm16) @@ -2065,7 +2057,6 @@ gl_renderer_attach_shm(struct weston_surface *es, struct weston_buffer *buffer) pitch = wl_shm_buffer_get_stride(shm_buffer) / 8; gl_format[0] = GL_RGBA16_EXT; gl_pixel_type = GL_UNSIGNED_SHORT; - es->is_opaque = true; break; #endif case WL_SHM_FORMAT_YUV420: @@ -2090,7 +2081,6 @@ gl_renderer_attach_shm(struct weston_surface *es, struct weston_buffer *buffer) gl_format[1] = GL_LUMINANCE; gl_format[2] = GL_LUMINANCE; } - es->is_opaque = true; break; case WL_SHM_FORMAT_NV12: pitch = wl_shm_buffer_get_stride(shm_buffer); @@ -2109,7 +2099,6 @@ gl_renderer_attach_shm(struct weston_surface *es, struct weston_buffer *buffer) gl_format[0] = GL_LUMINANCE; gl_format[1] = GL_LUMINANCE_ALPHA; } - es->is_opaque = true; break; case WL_SHM_FORMAT_YUYV: gb->shader_variant = SHADER_VARIANT_Y_XUXV; @@ -2124,7 +2113,6 @@ gl_renderer_attach_shm(struct weston_surface *es, struct weston_buffer *buffer) else gl_format[0] = GL_LUMINANCE_ALPHA; gl_format[1] = GL_BGRA_EXT; - es->is_opaque = true; break; case WL_SHM_FORMAT_XYUV8888: /* @@ -2135,7 +2123,6 @@ gl_renderer_attach_shm(struct weston_surface *es, struct weston_buffer *buffer) pitch = wl_shm_buffer_get_stride(shm_buffer) / 4; gl_format[0] = GL_RGBA; gl_pixel_type = GL_UNSIGNED_BYTE; - es->is_opaque = true; break; default: unsupported: @@ -2251,7 +2238,6 @@ gl_renderer_attach_egl(struct weston_surface *es, struct weston_buffer *buffer) egl_image_unref(gb->images[i]); gb->images[i] = NULL; } - es->is_opaque = false; if (!gr->has_bind_display || !gr->query_buffer(gr->egl_display, buffer->legacy_buffer, @@ -2263,7 +2249,6 @@ gl_renderer_attach_egl(struct weston_surface *es, struct weston_buffer *buffer) switch (format) { case EGL_TEXTURE_RGB: - es->is_opaque = true; /* fallthrough */ case EGL_TEXTURE_RGBA: default: @@ -2277,17 +2262,14 @@ gl_renderer_attach_egl(struct weston_surface *es, struct weston_buffer *buffer) case EGL_TEXTURE_Y_UV_WL: num_planes = 2; gb->shader_variant = SHADER_VARIANT_Y_UV; - es->is_opaque = true; break; case EGL_TEXTURE_Y_U_V_WL: num_planes = 3; gb->shader_variant = SHADER_VARIANT_Y_U_V; - es->is_opaque = true; break; case EGL_TEXTURE_Y_XUXV_WL: num_planes = 2; gb->shader_variant = SHADER_VARIANT_Y_XUXV; - es->is_opaque = true; break; } @@ -2895,7 +2877,6 @@ gl_renderer_attach_dmabuf(struct weston_surface *surface, gb->num_images = 0; gb->direct_display = dmabuf->direct_display; - surface->is_opaque = pixel_format_is_opaque(buffer->pixel_format); if (dmabuf->direct_display) return true; @@ -3058,7 +3039,6 @@ out: glDeleteTextures(gs->num_textures, gs->textures); gs->num_textures = 0; gb->direct_display = false; - es->is_opaque = false; } static uint32_t