[PATCH weston 09/68] compositor-drm: Reshuffle and comment plane conditions

Armin Krezović krezovic.armin at gmail.com
Fri Dec 9 20:58:30 UTC 2016


On 09.12.2016 20:57, Daniel Stone wrote:
> Try to harmonise the various plane-import paths a little bit, starting
> with reshuffling and commenting the conditions to do so.
> 
> Signed-off-by: Daniel Stone <daniels at collabora.com>
> 

This makes code more readable and understandable. So have a

Reviewed-by: Armin Krezović <krezovic.armin at gmail.com>

> Differential Revision: https://phabricator.freedesktop.org/D1413
> ---
>  libweston/compositor-drm.c | 79 ++++++++++++++++++++++++++++------------------
>  1 file changed, 48 insertions(+), 31 deletions(-)
> 
> diff --git a/libweston/compositor-drm.c b/libweston/compositor-drm.c
> index 5fb45b4..8cd9d5a 100644
> --- a/libweston/compositor-drm.c
> +++ b/libweston/compositor-drm.c
> @@ -502,18 +502,28 @@ drm_output_prepare_scanout_view(struct drm_output *output,
>  	struct gbm_bo *bo;
>  	uint32_t format;
>  
> -	if (ev->geometry.x != output->base.x ||
> -	    ev->geometry.y != output->base.y ||
> -	    buffer == NULL || b->gbm == NULL ||
> -	    buffer->width != output->base.current_mode->width ||
> -	    buffer->height != output->base.current_mode->height ||
> -	    output->base.transform != viewport->buffer.transform ||
> -	    ev->transform.enabled)
> +	/* We use GBM to import buffers. */
> +	if (b->gbm == NULL)
> +		return NULL;
> +
> +	if (buffer == NULL)
>  		return NULL;
>  
> +	/* Make sure our view is exactly compatible with the output. */
> +	if (ev->geometry.x != output->base.x ||
> +	    ev->geometry.y != output->base.y)
> +		return NULL;
> +	if (ev->transform.enabled)
> +		return NULL;
>  	if (ev->geometry.scissor_enabled)
>  		return NULL;
>  
> +	if (buffer->width != output->base.current_mode->width ||
> +	    buffer->height != output->base.current_mode->height)
> +		return NULL;
> +	if (viewport->buffer.transform != output->base.transform)
> +		return NULL;
> +
>  	bo = gbm_bo_import(b->gbm, GBM_BO_IMPORT_WL_BUFFER,
>  			   buffer->resource, GBM_BO_USE_SCANOUT);
>  
> @@ -950,34 +960,33 @@ drm_output_prepare_overlay_view(struct drm_output *output,
>  	uint32_t format;
>  	wl_fixed_t sx1, sy1, sx2, sy2;
>  
> -	if (b->gbm == NULL)
> -		return NULL;
> -
> -	if (viewport->buffer.transform != output->base.transform)
> -		return NULL;
> -
> -	if (viewport->buffer.scale != output->base.current_scale)
> -		return NULL;
> -
>  	if (b->sprites_are_broken)
>  		return NULL;
>  
> +	/* Don't import buffers which span multiple outputs. */
>  	if (ev->output_mask != (1u << output->base.id))
>  		return NULL;
>  
> -	if (ev->surface->buffer_ref.buffer == NULL)
> +	/* We can only import GBM buffers. */
> +	if (b->gbm == NULL)
>  		return NULL;
> -	buffer_resource = ev->surface->buffer_ref.buffer->resource;
>  
> -	if (ev->alpha != 1.0f)
> +	if (ev->surface->buffer_ref.buffer == NULL)
>  		return NULL;
> -
> +	buffer_resource = ev->surface->buffer_ref.buffer->resource;
>  	if (wl_shm_buffer_get(buffer_resource))
>  		return NULL;
>  
> +	if (viewport->buffer.transform != output->base.transform)
> +		return NULL;
> +	if (viewport->buffer.scale != output->base.current_scale)
> +		return NULL;
>  	if (!drm_view_transform_supported(ev))
>  		return NULL;
>  
> +	if (ev->alpha != 1.0f)
> +		return NULL;
> +
>  	wl_list_for_each(s, &b->sprite_list, link) {
>  		if (!drm_sprite_crtc_supported(output, s))
>  			continue;
> @@ -1114,23 +1123,20 @@ drm_output_prepare_cursor_view(struct drm_output *output,
>  	struct weston_buffer_viewport *viewport = &ev->surface->buffer_viewport;
>  	struct wl_shm_buffer *shmbuf;
>  
> -	if (ev->transform.enabled &&
> -	    (ev->transform.matrix.type > WESTON_MATRIX_TRANSFORM_TRANSLATE))
> -		return NULL;
> -	if (b->gbm == NULL)
> -		return NULL;
> -	if (output->base.transform != WL_OUTPUT_TRANSFORM_NORMAL)
> -		return NULL;
> -	if (viewport->buffer.scale != output->base.current_scale)
> +	if (b->cursors_are_broken)
>  		return NULL;
> +
>  	if (output->cursor_view)
>  		return NULL;
> +
> +	/* Don't import buffers which span multiple outputs. */
>  	if (ev->output_mask != (1u << output->base.id))
>  		return NULL;
> -	if (b->cursors_are_broken)
> -		return NULL;
> -	if (ev->geometry.scissor_enabled)
> +
> +	/* We use GBM to import SHM buffers. */
> +	if (b->gbm == NULL)
>  		return NULL;
> +
>  	if (ev->surface->buffer_ref.buffer == NULL)
>  		return NULL;
>  	shmbuf = wl_shm_buffer_get(ev->surface->buffer_ref.buffer->resource);
> @@ -1138,6 +1144,17 @@ drm_output_prepare_cursor_view(struct drm_output *output,
>  		return NULL;
>  	if (wl_shm_buffer_get_format(shmbuf) != WL_SHM_FORMAT_ARGB8888)
>  		return NULL;
> +
> +	if (output->base.transform != WL_OUTPUT_TRANSFORM_NORMAL)
> +		return NULL;
> +	if (ev->transform.enabled &&
> +	    (ev->transform.matrix.type > WESTON_MATRIX_TRANSFORM_TRANSLATE))
> +		return NULL;
> +	if (viewport->buffer.scale != output->base.current_scale)
> +		return NULL;
> +	if (ev->geometry.scissor_enabled)
> +		return NULL;
> +
>  	if (ev->surface->width > b->cursor_width ||
>  	    ev->surface->height > b->cursor_height)
>  		return NULL;
> 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 870 bytes
Desc: OpenPGP digital signature
URL: <https://lists.freedesktop.org/archives/wayland-devel/attachments/20161209/50968391/attachment.sig>


More information about the wayland-devel mailing list