[PATCH v14 32/41] compositor-drm: Split drm_assign_planes in two

Pekka Paalanen ppaalanen at gmail.com
Fri Jan 26 11:49:16 UTC 2018


On Wed, 20 Dec 2017 12:26:49 +0000
Daniel Stone <daniels at collabora.com> wrote:

> Move drm_assign_planes into two functions: one which proposes a plane
> configuration, and another which applies that state to the Weston
> internal structures. This will be used to try multiple configurations
> and see which is supported.
> 
> Signed-off-by: Daniel Stone <daniels at collabora.com>
> ---
>  libweston/compositor-drm.c | 109 ++++++++++++++++++++++++++++++---------------
>  1 file changed, 74 insertions(+), 35 deletions(-)
> 
> diff --git a/libweston/compositor-drm.c b/libweston/compositor-drm.c
> index 3ff06c01c..049c80932 100644
> --- a/libweston/compositor-drm.c
> +++ b/libweston/compositor-drm.c
> @@ -357,6 +357,8 @@ struct drm_plane_state {
>  
>  	struct drm_fb *fb;
>  
> +	struct weston_view *ev; /**< maintained for drm_assign_planes only */
> +
>  	int32_t src_x, src_y;
>  	uint32_t src_w, src_h;
>  	int32_t dest_x, dest_y;

> +static void
> +drm_assign_planes(struct weston_output *output_base, void *repaint_data)
> +{
> +	struct drm_backend *b = to_drm_backend(output_base->compositor);
> +	struct drm_pending_state *pending_state = repaint_data;
> +	struct drm_output *output = to_drm_output(output_base);
> +	struct drm_output_state *state;
> +	struct drm_plane_state *plane_state;
> +	struct weston_view *ev;
> +	struct weston_plane *primary = &output_base->compositor->primary_plane;
> +
> +	state = drm_output_propose_state(output_base, pending_state);
>  
> -		if (next_plane == primary ||
> -		    (output->cursor_plane &&
> -		     next_plane == &output->cursor_plane->base)) {
> -			/* cursor plane involves a copy */
> +	wl_list_for_each(ev, &output_base->compositor->view_list, link) {
> +		struct drm_plane *target_plane = NULL;
> +
> +		/* Test whether this buffer can ever go into a plane:
> +		 * non-shm, or small enough to be a cursor.
> +		 *
> +		 * Also, keep a reference when using the pixman renderer.
> +		 * That makes it possible to do a seamless switch to the GL
> +		 * renderer and since the pixman renderer keeps a reference
> +		 * to the buffer anyway, there is no side effects.
> +		 */
> +		if (b->use_pixman ||
> +		    (ev->surface->buffer_ref.buffer &&
> +		    (!wl_shm_buffer_get(ev->surface->buffer_ref.buffer->resource) ||
> +		     (ev->surface->width <= b->cursor_width &&
> +		      ev->surface->height <= b->cursor_height))))
> +			ev->surface->keep_buffer = true;
> +		else
> +			ev->surface->keep_buffer = false;
> +
> +		/* This is a bit unpleasant, but lacking a temporary place to
> +		 * hang a plane off the view, we have to do a nested walk.
> +		 * Our first-order iteration has to be planes rather than
> +		 * views, because otherwise we won't reset views which were
> +		 * previously on planes to being on the primary plane. */
> +		wl_list_for_each(plane_state, &state->plane_list, link) {

I believe the plane list will be short enough for the foreseeable
future to not warrant a more complicated solution. One option would be
to hang data off the view destroy signal, but then looking that data up
is probably in the same order of magnitude than this trivial loop.

> +			if (plane_state->ev == ev) {
> +				plane_state->ev = NULL;
> +				target_plane = plane_state->plane;
> +				break;
> +			}
> +		}
> +
> +		if (target_plane)
> +			weston_view_move_to_plane(ev, &target_plane->base);
> +		else
> +			weston_view_move_to_plane(ev, primary);
> +
> +		if (!target_plane ||
> +		    target_plane->type == WDRM_PLANE_TYPE_CURSOR) {
> +			/* cursor plane & renderer involve a copy */
>  			ev->psf_flags = 0;
>  		} else {

Reviewed-by: Pekka Paalanen <pekka.paalanen at collabora.co.uk>


Thanks,
pq
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <https://lists.freedesktop.org/archives/wayland-devel/attachments/20180126/72ecb0ed/attachment.sig>


More information about the wayland-devel mailing list