diff --git a/libweston/backend-drm/state-propose.c b/libweston/backend-drm/state-propose.c index 6a01f44b..148397e9 100644 --- a/libweston/backend-drm/state-propose.c +++ b/libweston/backend-drm/state-propose.c @@ -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)))) diff --git a/libweston/compositor.c b/libweston/compositor.c index 6336c589..794253f6 100644 --- a/libweston/compositor.c +++ b/libweston/compositor.c @@ -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 diff --git a/libweston/libweston-internal.h b/libweston/libweston-internal.h index c804120b..4c8e35bd 100644 --- a/libweston/libweston-internal.h +++ b/libweston/libweston-internal.h @@ -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);