[PATCH weston 1/8] compositor: add weston_surface_to_buffer_region()

Derek Foreman derekf at osg.samsung.com
Fri Mar 6 11:16:23 PST 2015


On 06/03/15 05:03 AM, Pekka Paalanen wrote:
> From: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
> 
> This will be used by pixman-renderer.
> 
> Signed-off-by: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
> ---
>  src/compositor.c | 36 ++++++++++++++++++++++++++++++++++++
>  src/compositor.h |  5 +++++
>  2 files changed, 41 insertions(+)
> 
> diff --git a/src/compositor.c b/src/compositor.c
> index 45e8f5c..1747c6f 100644
> --- a/src/compositor.c
> +++ b/src/compositor.c
> @@ -930,6 +930,42 @@ weston_surface_to_buffer_rect(struct weston_surface *surface,
>  				       rect);
>  }
>  
> +/** Transform a region from surface coordinates to buffer coordinates
> + *
> + * \param surface The surface to fetch wl_viewport and buffer transformation
> + * from.
> + * \param surface_region[in] The region in surface coordinates.
> + * \param buffer_region[out] The region coverted to buffer coordinates.

s/coverted/converted

> + *
> + * Buffer_region must be init'd, but will be completely overwritten.
> + *
> + * Viewport and buffer transformations can only do translation, scaling,
> + * and rotations in 90-degree steps. Therefore the only loss in the
> + * conversion is coordinate flooring (rounding).
> + */
> +WL_EXPORT void
> +weston_surface_to_buffer_region(struct weston_surface *surface,
> +				pixman_region32_t *surface_region,
> +				pixman_region32_t *buffer_region)
> +{
> +	pixman_box32_t *src_rects, *dest_rects;
> +	int nrects, i;
> +
> +	src_rects = pixman_region32_rectangles(surface_region, &nrects);
> +	dest_rects = malloc(nrects * sizeof(*dest_rects));
> +	if (!dest_rects)
> +		return;
> +
> +	for (i = 0; i < nrects; i++) {
> +		dest_rects[i] = weston_surface_to_buffer_rect(surface,
> +							      src_rects[i]);
> +	}
> +
> +	pixman_region32_fini(buffer_region);
> +	pixman_region32_init_rects(buffer_region, dest_rects, nrects);
> +	free(dest_rects);
> +}
> +
>  WL_EXPORT void
>  weston_view_move_to_plane(struct weston_view *view,
>  			     struct weston_plane *plane)
> diff --git a/src/compositor.h b/src/compositor.h
> index f4ba7a5..2feaafd 100644
> --- a/src/compositor.h
> +++ b/src/compositor.h
> @@ -1029,6 +1029,11 @@ weston_surface_to_buffer_rect(struct weston_surface *surface,
>  			      pixman_box32_t rect);
>  
>  void
> +weston_surface_to_buffer_region(struct weston_surface *surface,
> +				pixman_region32_t *surface_region,
> +				pixman_region32_t *buffer_region);
> +
> +void
>  weston_spring_init(struct weston_spring *spring,
>  		   double k, double current, double target);
>  void
> 



More information about the wayland-devel mailing list