weston_buffer: Prepare for buffer to outlive resource

We currently allow a weston_buffer to outlive the underlying wl_buffer
iff the renderer/backend has cached it. Currently the 'is this buffer
valid?' test relies on looking for the validity of the weston_buffer
itself; shift these tests to looking at the validity of the underlying
resource.

Signed-off-by: Daniel Stone <daniels@collabora.com>
This commit is contained in:
Daniel Stone 2022-01-14 02:33:03 +00:00
parent e9c792ed64
commit 7b3efabd88
2 changed files with 6 additions and 1 deletions

View file

@ -1983,7 +1983,11 @@ weston_view_is_opaque(struct weston_view *ev, pixman_region32_t *region)
WL_EXPORT bool
weston_view_has_valid_buffer(struct weston_view *ev)
{
return ev->surface->buffer_ref.buffer != NULL;
if (!ev->surface->buffer_ref.buffer)
return false;
if (!ev->surface->buffer_ref.buffer->resource)
return false;
return true;
}
/** Check if the view matches the entire output

View file

@ -420,6 +420,7 @@ drag_surface_configure(struct weston_drag *drag,
assert((pointer != NULL && touch == NULL) ||
(pointer == NULL && touch != NULL));
/* XXX: Why are we checking for a valid buffer here too ... ? */
if (!weston_surface_is_mapped(es) && es->buffer_ref.buffer) {
if (pointer && pointer->sprite &&
weston_view_is_mapped(pointer->sprite))