[PATCH weston 13/15] libweston: extend output->region lifetime

Armin Krezović krezovic.armin at gmail.com
Tue Apr 4 20:05:25 UTC 2017


On 04.04.2017 12:58, Pekka Paalanen wrote:
> From: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
> 
> It's a little awkward to try to keep the weston_output::region and
> weston_output::previous_damage allocate exactly only when the output is
> enabled. There was also a leak: weston_output_move() was calling
> weston_output_init_geometry() on an already allocated regions without
> fini in between.
> 
> Fix both issues by allocating the regions in weston_output_init(),
> always fini/init'ing them in weston_output_init_geometry(), and fini'ing
> for good in weston_output_destroy().
> 
> This nicely gets rid of weston_output_enable_undo() so I do not need to
> try to figure out what to do with it later.
> 
> Signed-off-by: Pekka Paalanen <pekka.paalanen at collabora.co.uk>

Nice work on getting rid of weston_output_enable_undo()

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

Thanks, Armin.

> ---
>  libweston/compositor.c | 32 ++++++++++----------------------
>  1 file changed, 10 insertions(+), 22 deletions(-)
> 
> diff --git a/libweston/compositor.c b/libweston/compositor.c
> index e8d5443..cd5b6ec 100644
> --- a/libweston/compositor.c
> +++ b/libweston/compositor.c
> @@ -4421,7 +4421,10 @@ weston_output_init_geometry(struct weston_output *output, int x, int y)
>  	output->x = x;
>  	output->y = y;
>  
> +	pixman_region32_fini(&output->previous_damage);
>  	pixman_region32_init(&output->previous_damage);
> +
> +	pixman_region32_fini(&output->region);
>  	pixman_region32_init_rect(&output->region, x, y,
>  				  output->width,
>  				  output->height);
> @@ -4537,20 +4540,6 @@ weston_output_transform_coordinate(struct weston_output *output,
>  	*y = p.f[1] / p.f[3];
>  }
>  
> -/** Undoes changes to an output done by weston_output_enable()
> - *
> - * \param output The weston_output object that needs the changes undone.
> - *
> - * Removes the repaint timer.
> - * Destroys pixman regions allocated to the output.
> - */
> -static void
> -weston_output_enable_undo(struct weston_output *output)
> -{
> -	pixman_region32_fini(&output->region);
> -	pixman_region32_fini(&output->previous_damage);
> -}
> -
>  /** Removes output from compositor's live outputs list
>   *
>   * \param output The weston_output object that is being removed.
> @@ -4699,6 +4688,9 @@ weston_output_init(struct weston_output *output,
>  	output->scale = 0;
>  	/* Can't use -1 on uint32_t and 0 is valid enum value */
>  	output->transform = UINT32_MAX;
> +
> +	pixman_region32_init(&output->previous_damage);
> +	pixman_region32_init(&output->region);
>  }
>  
>  /** Adds weston_output object to pending output list.
> @@ -4807,8 +4799,6 @@ weston_output_enable(struct weston_output *output)
>  	 */
>  	if (output->enable(output) < 0) {
>  		weston_log("Enabling output \"%s\" failed.\n", output->name);
> -
> -		weston_output_enable_undo(output);
>  		return -1;
>  	}
>  
> @@ -4860,10 +4850,8 @@ weston_output_disable(struct weston_output *output)
>  	if (output->disable(output) < 0)
>  		return;
>  
> -	if (output->enabled) {
> +	if (output->enabled)
>  		weston_compositor_remove_output(output);
> -		weston_output_enable_undo(output);
> -	}
>  
>  	output->destroying = 0;
>  }
> @@ -4897,11 +4885,11 @@ weston_output_destroy(struct weston_output *output)
>  {
>  	output->destroying = 1;
>  
> -	if (output->enabled) {
> +	if (output->enabled)
>  		weston_compositor_remove_output(output);
> -		weston_output_enable_undo(output);
> -	}
>  
> +	pixman_region32_fini(&output->region);
> +	pixman_region32_fini(&output->previous_damage);
>  	wl_list_remove(&output->link);
>  	free(output->name);
>  }
> 


-------------- 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/20170404/299eb4be/attachment-0001.sig>


More information about the wayland-devel mailing list