From 4b582c7cc088a1a363cde3f01ac2b268f9efb8d0 Mon Sep 17 00:00:00 2001 From: Pekka Paalanen <pekka.paalanen@collabora.co.uk> Date: Thu, 30 Mar 2017 16:04:58 +0300 Subject: [PATCH] libweston: extend output->region lifetime MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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@collabora.co.uk> Reviewed-by: Armin Krezović <krezovic.armin@gmail.com> --- libweston/compositor.c | 32 ++++++++++---------------------- 1 file changed, 10 insertions(+), 22 deletions(-) diff --git a/libweston/compositor.c b/libweston/compositor.c index eda043406..296b02eeb 100644 --- a/libweston/compositor.c +++ b/libweston/compositor.c @@ -4426,7 +4426,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); @@ -4543,20 +4546,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 list of enabled outputs * * \param output The weston_output object that is being removed. @@ -4703,6 +4692,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. @@ -4811,8 +4803,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; } @@ -4864,10 +4854,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; } @@ -4902,11 +4890,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); } -- GitLab