compositor: ref-count weston_surface instances

This allows a surface to live on after its resource has been
destroyed.  The ref-count can be increased in a resource destroy signal
listener, to keep the surface around for a destroy animation, for example.
dev
Giulio Camuffo 12 years ago committed by Kristian Høgsberg
parent b1c02a80ef
commit 13b85bdb65
  1. 8
      src/compositor.c
  2. 1
      src/compositor.h

@ -287,6 +287,7 @@ weston_surface_create(struct weston_compositor *compositor)
surface->compositor = compositor;
surface->alpha = 1.0;
surface->ref_count = 1;
if (compositor->renderer->create_surface(surface) < 0) {
free(surface);
@ -1003,11 +1004,14 @@ struct weston_frame_callback {
WL_EXPORT void
weston_surface_destroy(struct weston_surface *surface)
{
wl_signal_emit(&surface->destroy_signal, &surface->resource);
struct weston_compositor *compositor = surface->compositor;
struct weston_frame_callback *cb, *next;
if (--surface->ref_count > 0)
return;
wl_signal_emit(&surface->destroy_signal, &surface->resource);
assert(wl_list_empty(&surface->geometry.child_list));
assert(wl_list_empty(&surface->subsurface_list_pending));
assert(wl_list_empty(&surface->subsurface_list));

@ -709,6 +709,7 @@ struct weston_surface {
struct wl_list layer_link;
float alpha; /* part of geometry, see below */
struct weston_plane *plane;
int32_t ref_count;
void *renderer_state;

Loading…
Cancel
Save