backend-drm: Do not overwrite plane's index when creating virtual plane

Starting with commit 4cde507be6 "backend-drm: fix plane sorting" the
plane list will have a descending order of the planes rather than ascending.

This reversed order had the side-effect of exposing the fact that we
don't set-up a plane index when creating the drm_plane using the DRM
virtual API. Without settting a plane index for that drm_plane we
effectively overwrite the plane index which has the 0 (zero) entry.

This wasn't an issue before commit 4cde507be6 "backend-drm: fix
plane sorting" as it seems we never picked up that plane index as
being a suitable one due to the fact that those were assigned to primary
planes, but after that commit, the cursor plane will be one getting
the 0 (zero) plane index.

Finally, this would trip over because we attempt to place a (cursor)
view on a primary plane (where it would've normally be a cursor
plane) and we end up with no framebuffer ref.

This is fixed trivially by assigning a plane index, different than the
ones already created by create_spirtes().

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
This commit is contained in:
Marius Vlad 2023-02-04 19:59:33 +02:00
parent ba82af938a
commit 27ce9dadd8

View File

@ -82,6 +82,20 @@ drm_virtual_crtc_destroy(struct drm_crtc *crtc)
free(crtc);
}
static uint32_t
get_drm_plane_index_maximum(struct drm_device *device)
{
uint32_t max = 0;
struct drm_plane *p;
wl_list_for_each(p, &device->plane_list, link) {
if (p->plane_idx > max)
max = p->plane_idx;
}
return max;
}
/**
* Create a drm_plane for virtual output
*
@ -127,6 +141,8 @@ drm_virtual_plane_create(struct drm_device *device, struct drm_output *output)
goto err;
weston_plane_init(&plane->base, b->compositor);
plane->plane_idx = get_drm_plane_index_maximum(device) + 1;
wl_list_insert(&device->plane_list, &plane->link);
return plane;