libweston: extend output->region lifetime
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>
This commit is contained in:
parent
2210ad006c
commit
4b582c7cc0
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user