backend-drm: Place pixel format checks for the cursor plane in its own

function

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
dev
Marius Vlad 5 years ago committed by Daniel Stone
parent 4eeb402553
commit 3b13f56a1d
  1. 25
      libweston/backend-drm/state-propose.c

@ -152,6 +152,18 @@ drm_output_plane_has_valid_format(struct drm_plane *plane,
return false; return false;
} }
static bool
drm_output_plane_cursor_has_valid_format(struct weston_view *ev)
{
struct wl_shm_buffer *shmbuf =
wl_shm_buffer_get(ev->surface->buffer_ref.buffer->resource);
if (shmbuf && wl_shm_buffer_get_format(shmbuf) == WL_SHM_FORMAT_ARGB8888)
return true;
return false;
}
static struct drm_plane_state * static struct drm_plane_state *
drm_output_prepare_overlay_view(struct drm_output_state *output_state, drm_output_prepare_overlay_view(struct drm_output_state *output_state,
struct weston_view *ev, struct weston_view *ev,
@ -327,7 +339,6 @@ drm_output_prepare_cursor_view(struct drm_output_state *output_state,
struct drm_backend *b = to_drm_backend(output->base.compositor); struct drm_backend *b = to_drm_backend(output->base.compositor);
struct drm_plane *plane = output->cursor_plane; struct drm_plane *plane = output->cursor_plane;
struct drm_plane_state *plane_state; struct drm_plane_state *plane_state;
struct wl_shm_buffer *shmbuf;
bool needs_update = false; bool needs_update = false;
assert(!b->cursors_are_broken); assert(!b->cursors_are_broken);
@ -345,18 +356,8 @@ drm_output_prepare_cursor_view(struct drm_output_state *output_state,
if (b->gbm == NULL) if (b->gbm == NULL)
return NULL; return NULL;
shmbuf = wl_shm_buffer_get(ev->surface->buffer_ref.buffer->resource); if (!drm_output_plane_cursor_has_valid_format(ev))
if (!shmbuf) {
drm_debug(b, "\t\t\t\t[cursor] not assigning view %p to cursor plane "
"(buffer isn't SHM)\n", ev);
return NULL;
}
if (wl_shm_buffer_get_format(shmbuf) != WL_SHM_FORMAT_ARGB8888) {
drm_debug(b, "\t\t\t\t[cursor] not assigning view %p to cursor plane "
"(format 0x%lx unsuitable)\n",
ev, (unsigned long) wl_shm_buffer_get_format(shmbuf));
return NULL; return NULL;
}
plane_state = plane_state =
drm_output_state_get_plane(output_state, output->cursor_plane); drm_output_state_get_plane(output_state, output->cursor_plane);

Loading…
Cancel
Save