libweston: Add a new helper weston_view_has_valid_buffer

Helper to determine if the buffer attached to the view is valid.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
This commit is contained in:
Marius Vlad 2019-09-11 16:41:04 +03:00 committed by Daniel Stone
parent e83e750183
commit 5f6bee49ed
3 changed files with 18 additions and 3 deletions

View file

@ -278,7 +278,7 @@ drm_output_prepare_cursor_view(struct drm_output_state *output_state,
if (b->gbm == NULL)
return NULL;
if (ev->surface->buffer_ref.buffer == NULL) {
if (!weston_view_has_valid_buffer(ev)) {
drm_debug(b, "\t\t\t\t[cursor] not assigning view %p to cursor plane "
"(no buffer available)\n", ev);
return NULL;
@ -546,7 +546,7 @@ drm_output_propose_state(struct weston_output *output_base,
force_renderer = true;
}
if (!ev->surface->buffer_ref.buffer) {
if (!weston_view_has_valid_buffer(ev)) {
drm_debug(b, "\t\t\t\t[view] not assigning view %p to plane "
"(no buffer available)\n", ev);
force_renderer = true;
@ -764,7 +764,7 @@ drm_assign_planes(struct weston_output *output_base, void *repaint_data)
* to the buffer anyway, there is no side effects.
*/
if (b->use_pixman ||
(ev->surface->buffer_ref.buffer &&
(weston_view_has_valid_buffer(ev) &&
(!wl_shm_buffer_get(ev->surface->buffer_ref.buffer->resource) ||
(ev->surface->width <= b->cursor_width &&
ev->surface->height <= b->cursor_height))))

View file

@ -1852,6 +1852,18 @@ weston_view_is_opaque(struct weston_view *ev, pixman_region32_t *region)
return ret;
}
/** Check if the view has a valid buffer available
*
* @param ev The view to check if it has a valid buffer.
*
* Returns true if the view has a valid buffer or false otherwise.
*/
WL_EXPORT bool
weston_view_has_valid_buffer(struct weston_view *ev)
{
return ev->surface->buffer_ref.buffer != NULL;
}
/* Check if a surface has a view assigned to it
*
* The indicator is set manually when mapping

View file

@ -287,6 +287,9 @@ weston_view_from_global_float(struct weston_view *view,
bool
weston_view_is_opaque(struct weston_view *ev, pixman_region32_t *region);
bool
weston_view_has_valid_buffer(struct weston_view *ev);
void
weston_view_move_to_plane(struct weston_view *view,
struct weston_plane *plane);