backend-drm: Place pixel format checks for the cursor plane in its own
authorMarius Vlad <marius.vlad@collabora.com>
Sun, 13 Oct 2019 21:29:18 +0000 (00:29 +0300)
committerDaniel Stone <daniels@collabora.com>
Mon, 11 Nov 2019 16:51:48 +0000 (16:51 +0000)
function

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
libweston/backend-drm/state-propose.c

index d794f2c0f1127484d24911061ed03cafdcc8db68..4750716fa6508f2bcf2bdfe701e516b7497c6d54 100644 (file)
@@ -152,6 +152,18 @@ drm_output_plane_has_valid_format(struct drm_plane *plane,
        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 *
 drm_output_prepare_overlay_view(struct drm_output_state *output_state,
                                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_plane *plane = output->cursor_plane;
        struct drm_plane_state *plane_state;
-       struct wl_shm_buffer *shmbuf;
        bool needs_update = false;
 
        assert(!b->cursors_are_broken);
@@ -345,18 +356,8 @@ drm_output_prepare_cursor_view(struct drm_output_state *output_state,
        if (b->gbm == NULL)
                return NULL;
 
-       shmbuf = wl_shm_buffer_get(ev->surface->buffer_ref.buffer->resource);
-       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));
+       if (!drm_output_plane_cursor_has_valid_format(ev))
                return NULL;
-       }
 
        plane_state =
                drm_output_state_get_plane(output_state, output->cursor_plane);