[PATCH weston 1/2] window: change boolean to flags in toysurface::prepare()

Kristian Høgsberg hoegsberg at gmail.com
Fri Nov 30 11:16:53 PST 2012


On Fri, Nov 30, 2012 at 01:37:27PM +0200, Pekka Paalanen wrote:
> Change the boolean parameter 'resize_hint' into a bitmask 'flags'.
> 
> Note, that this flags is very different to the other flags used in
> creating the toysurface implementations. They do not make sense to mix
> one way or the other. Prepare() cannot change the surface type, and
> surface constructors do not care for dynamic hint flags.

Thanks,
Kristian

> Signed-off-by: Pekka Paalanen <ppaalanen at gmail.com>
> ---
>  clients/window.c |   21 ++++++++++++++++-----
>  1 files changed, 16 insertions(+), 5 deletions(-)
> 
> diff --git a/clients/window.c b/clients/window.c
> index 3469fe6..b11399c 100644
> --- a/clients/window.c
> +++ b/clients/window.c
> @@ -147,17 +147,22 @@ struct window_output {
>  	struct wl_list link;
>  };
>  
> +enum toysurface_prepare_flags {
> +	SURFACE_HINT_RESIZE = 0x01,
> +};
> +
>  struct toysurface {
>  	/*
>  	 * Prepare the surface for drawing. Makes sure there is a surface
>  	 * of the right size available for rendering, and returns it.
>  	 * dx,dy are the x,y of wl_surface.attach.
>  	 * width,height are the new surface size.
> -	 * If resize_hint is non-zero, the user is doing continuous resizing.
> +	 * If flags has SURFACE_HINT_RESIZE set, the user is
> +	 * doing continuous resizing.
>  	 * Returns the Cairo surface to draw to.
>  	 */
>  	cairo_surface_t *(*prepare)(struct toysurface *base, int dx, int dy,
> -				    int width, int height, int resize_hint);
> +				    int width, int height, uint32_t flags);
>  
>  	/*
>  	 * Post the surface to the server, returning the server allocation
> @@ -411,7 +416,7 @@ to_egl_window_surface(struct toysurface *base)
>  
>  static cairo_surface_t *
>  egl_window_surface_prepare(struct toysurface *base, int dx, int dy,
> -			   int width, int height, int resize_hint)
> +			   int width, int height, uint32_t flags)
>  {
>  	struct egl_window_surface *surface = to_egl_window_surface(base);
>  
> @@ -833,8 +838,9 @@ static const struct wl_buffer_listener shm_surface_buffer_listener = {
>  
>  static cairo_surface_t *
>  shm_surface_prepare(struct toysurface *base, int dx, int dy,
> -		    int width, int height, int resize_hint)
> +		    int width, int height, uint32_t flags)
>  {
> +	int resize_hint = !!(flags & SURFACE_HINT_RESIZE);
>  	struct shm_surface *surface = to_shm_surface(base);
>  	struct rectangle rect = { 0, 0, width, height };
>  	struct shm_surface_leaf *leaf;
> @@ -1201,12 +1207,17 @@ window_create_surface(struct window *window)
>  							window->surface, flags,
>  							&window->allocation);
>  
> +	if (window->resizing)
> +		flags = SURFACE_HINT_RESIZE;
> +	else
> +		flags = 0;
> +
>  	window_get_resize_dx_dy(window, &dx, &dy);
>  	window->cairo_surface =
>  		window->toysurface->prepare(window->toysurface, dx, dy,
>  					    window->allocation.width,
>  					    window->allocation.height,
> -					    window->resizing);
> +					    flags);
>  }
>  
>  static void frame_destroy(struct frame *frame);
> -- 
> 1.7.8.6
> 


More information about the wayland-devel mailing list