From ca4c2865e9adf7470a470fe08a8a7372f4d17e4e Mon Sep 17 00:00:00 2001 From: Daniel Stone Date: Tue, 7 Dec 2021 16:42:02 +0000 Subject: [PATCH] backend-drm: Early-out for cursor plane format testing If we have a SHM buffer, it can only go into a cursor plane - and only then if it's of the right format. Signed-off-by: Daniel Stone --- libweston/backend-drm/state-propose.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/libweston/backend-drm/state-propose.c b/libweston/backend-drm/state-propose.c index 8e355511..f5f63feb 100644 --- a/libweston/backend-drm/state-propose.c +++ b/libweston/backend-drm/state-propose.c @@ -691,15 +691,25 @@ drm_output_prepare_plane_view(struct drm_output_state *state, buffer = ev->surface->buffer_ref.buffer; shmbuf = wl_shm_buffer_get(buffer->resource); - if (!shmbuf) + if (shmbuf) { + if (!output->cursor_plane) + return NULL; + if (wl_shm_buffer_get_format(shmbuf) != WL_SHM_FORMAT_ARGB8888) { + drm_debug(b, "\t\t\t\t[view] not placing view %p on " + "plane; SHM buffers must be ARGB8888 for " + "cursor view", ev); + return NULL; + } + } else { fb = drm_fb_get_from_view(state, ev, try_view_on_plane_failure_reasons); + } if (!shmbuf && !fb) return NULL; /* assemble a list with possible candidates */ wl_list_for_each(plane, &b->plane_list, link) { if (plane->type == WDRM_PLANE_TYPE_CURSOR && - plane != output->cursor_plane) { + (plane != output->cursor_plane || !shmbuf)) { continue; } @@ -749,15 +759,6 @@ drm_output_prepare_plane_view(struct drm_output_state *state, continue; } - if (plane->type == WDRM_PLANE_TYPE_CURSOR && - (!shmbuf || wl_shm_buffer_get_format(shmbuf) != WL_SHM_FORMAT_ARGB8888)) { - drm_debug(b, "\t\t\t\t[plane] not adding plane %d, type cursor to " - "candidate list: cursor planes only support ARGB8888" - "wl_shm buffers and the view buffer is of another type\n", - plane->plane_id); - continue; - } - if (plane->type != WDRM_PLANE_TYPE_CURSOR && (!fb || !(fb->plane_mask & (1 << plane->plane_idx)))) { *try_view_on_plane_failure_reasons |=