From 0d8e94af61f11e5f6137fec1ed1fa18fed5e9e3e Mon Sep 17 00:00:00 2001 From: Marius Vlad Date: Mon, 7 Feb 2022 10:59:41 +0200 Subject: [PATCH] libweston: Rename weston_surface_destroy() to weston_surface_unref() Make it obvious that weston_surface has a reference counting happening and destruction of the weston_surface happens when the last weston_surface reference has been accounted for. Signed-off-by: Marius Vlad --- desktop-shell/shell.c | 4 ++-- include/libweston/libweston.h | 2 +- libweston/compositor.c | 8 ++++---- shell-utils/shell-utils.c | 4 ++-- tests/surface-global-test.c | 2 +- tests/surface-test.c | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c index 53d804ca..0609b86d 100644 --- a/desktop-shell/shell.c +++ b/desktop-shell/shell.c @@ -2352,7 +2352,7 @@ desktop_surface_removed(struct weston_desktop_surface *desktop_surface, fade_out_done, shsurf); return; } else { - weston_surface_destroy(surface); + weston_surface_unref(surface); } } @@ -4830,7 +4830,7 @@ desktop_shell_destroy_views_on_layer(struct weston_layer *layer) if (shsurf) desktop_shell_destroy_surface(shsurf); else if (is_black_surface_view(view, NULL)) - weston_surface_destroy(view->surface); + weston_surface_unref(view->surface); } weston_layer_fini(layer); diff --git a/include/libweston/libweston.h b/include/libweston/libweston.h index 2eec0be3..c695c250 100644 --- a/include/libweston/libweston.h +++ b/include/libweston/libweston.h @@ -2030,7 +2030,7 @@ weston_slide_run(struct weston_view *view, float start, float stop, weston_view_animation_done_func_t done, void *data); void -weston_surface_destroy(struct weston_surface *surface); +weston_surface_unref(struct weston_surface *surface); int weston_output_mode_switch_to_temporary(struct weston_output *output, diff --git a/libweston/compositor.c b/libweston/compositor.c index 1567f7f7..91425fb1 100644 --- a/libweston/compositor.c +++ b/libweston/compositor.c @@ -2296,7 +2296,7 @@ weston_view_destroy(struct weston_view *view) } WL_EXPORT void -weston_surface_destroy(struct weston_surface *surface) +weston_surface_unref(struct weston_surface *surface) { struct wl_resource *cb, *next; struct weston_view *ev, *nv; @@ -2358,7 +2358,7 @@ destroy_surface(struct wl_resource *resource) /* Set the resource to NULL, since we don't want to leave a * dangling pointer if the surface was refcounted and survives - * the weston_surface_destroy() call. */ + * the weston_surface_unref() call. */ surface->resource = NULL; if (surface->viewport_resource) @@ -2369,7 +2369,7 @@ destroy_surface(struct wl_resource *resource) NULL); } - weston_surface_destroy(surface); + weston_surface_unref(surface); } static void @@ -4213,7 +4213,7 @@ compositor_create_surface(struct wl_client *client, return; err_res: - weston_surface_destroy(surface); + weston_surface_unref(surface); err: wl_resource_post_no_memory(resource); } diff --git a/shell-utils/shell-utils.c b/shell-utils/shell-utils.c index e57ec8ac..2bf1d3bd 100644 --- a/shell-utils/shell-utils.c +++ b/shell-utils/shell-utils.c @@ -192,7 +192,7 @@ weston_curtain_create(struct weston_compositor *compositor, err_view: weston_view_destroy(view); err_surface: - weston_surface_destroy(surface); + weston_surface_unref(surface); err_curtain: free(curtain); err: @@ -206,7 +206,7 @@ weston_curtain_destroy(struct weston_curtain *curtain) struct weston_surface *surface = curtain->view->surface; weston_view_destroy(curtain->view); - weston_surface_destroy(surface); + weston_surface_unref(surface); weston_buffer_destroy_solid(curtain->buffer_ref); free(curtain); } diff --git a/tests/surface-global-test.c b/tests/surface-global-test.c index a9e4ff9d..63393986 100644 --- a/tests/surface-global-test.c +++ b/tests/surface-global-test.c @@ -90,5 +90,5 @@ PLUGIN_TEST(surface_to_from_global) assert(ix == 0 && iy == 0); /* Destroys all views too. */ - weston_surface_destroy(surface); + weston_surface_unref(surface); } diff --git a/tests/surface-test.c b/tests/surface-test.c index 68288a86..1a1db287 100644 --- a/tests/surface-test.c +++ b/tests/surface-test.c @@ -70,5 +70,5 @@ PLUGIN_TEST(surface_transform) assert(x == 200 && y == 340); /* Destroys all views too. */ - weston_surface_destroy(surface); + weston_surface_unref(surface); }