[PATCH weston] protocol,compositor: wl_viewport destination 1x1 min

Pekka Paalanen pekka.paalanen at collabora.co.uk
Fri Apr 4 03:35:33 PDT 2014


On Wed,  2 Apr 2014 10:18:29 +0300
Pekka Paalanen <ppaalanen at gmail.com> wrote:

> From: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
> 
> Ensure, that the resulting surface size is at least 1x1, even when
> destination size is not set and source size is zero. Previously this
> lead to zero surface size.
> 
> Tested by hacking clients/scaler.c to set src_width and src_height to 0.
> 
> Signed-off-by: Pekka Paalanen <pekka.paalanen at collabora.co.uk>

Strike this patch, I'm going to go with the alternative: zero size not
valid anywhere, negative sizes always an explicit error.

Now the question is, what do we want to pick as the "unset" values?
Width and height of 0,0 or -1,-1?

Since 0,0 can come from calloc() in a toolkit, maybe I'll pick -1,-1 so
that 0,0 will raise a protocol error if used "uninitialized", since
you're not supposed to send the request if the default state is good.


Thanks,
pq

> 
> ---
> 
> There is something wrong in the Pixman renderer, when using 0 or 1/256
> as the source width and height, but I can't investigate right now.
> ---
>  protocol/scaler.xml | 8 +++++---
>  src/compositor.c    | 7 ++++---
>  2 files changed, 9 insertions(+), 6 deletions(-)
> 
> diff --git a/protocol/scaler.xml b/protocol/scaler.xml
> index 5094616..580b026 100644
> --- a/protocol/scaler.xml
> +++ b/protocol/scaler.xml
> @@ -86,13 +86,15 @@
>        dst_width, dst_height. The source (rectangle) is scaled to exactly
>        this size. This overrides whatever the attached wl_buffer size is,
>        unless the wl_buffer is NULL. If the wl_buffer is NULL, the surface
> -      has no content and therefore no size.
> +      has no content and therefore no size. Otherwise, the size is always
> +      at least 1x1 in surface coordinates.
>  
>        If the source rectangle is set, it defines what area of the
>        wl_buffer is taken as the source. If the source rectangle is set and
>        the destination size is not set, the surface size becomes the source
> -      rectangle size rounded up to the nearest integer. If the source size
> -      is already exactly integers, this results in cropping without scaling.
> +      rectangle size rounded up to the nearest integer (note: 0
> +      destination width or height becomes 1). If the source size is
> +      already exactly integers, this results in cropping without scaling.
>  
>        The coordinate transformations from buffer pixel coordinates up to
>        the surface-local coordinates happen in the following order:
> diff --git a/src/compositor.c b/src/compositor.c
> index 016f514..a80fde9 100644
> --- a/src/compositor.c
> +++ b/src/compositor.c
> @@ -1245,9 +1245,10 @@ weston_surface_set_size_from_buffer(struct weston_surface *surface)
>  	}
>  
>  	if (vp->buffer.src_width != wl_fixed_from_int(-1)) {
> -		surface_set_size(surface,
> -				 fixed_round_up_to_int(vp->buffer.src_width),
> -				 fixed_round_up_to_int(vp->buffer.src_height));
> +		int32_t w = fixed_round_up_to_int(vp->buffer.src_width);
> +		int32_t h = fixed_round_up_to_int(vp->buffer.src_height);
> +
> +		surface_set_size(surface, w ?: 1, h ?: 1);
>  		return;
>  	}
>  



More information about the wayland-devel mailing list