[PATCH weston] compositor: ref-count weston_surface instances
Giulio Camuffo
giuliocamuffo at gmail.com
Wed Aug 14 03:40:43 PDT 2013
Yeah. I'll do a destroy fade out animation in orbital now that this is in.
Giulio
2013/8/14 Kristian Høgsberg <hoegsberg at gmail.com>
> On Tue, Aug 13, 2013 at 11:10:14PM +0200, Giulio Camuffo wrote:
> > this allows a surface to live on after its resource has been
> > destroyed if the ref-count was increased by some code that needs
> > to use the surface after the end of its life, like a destroy
> > animation.
>
> That looks fine. If you're up for it, it would be interesting to see
> a window destroy animation for weston that uses this. I broke the
> commit message into a couple of sentences, otherwise applied as is.
>
> Kristian
>
> > ---
> > src/compositor.c | 8 ++++++--
> > src/compositor.h | 1 +
> > 2 files changed, 7 insertions(+), 2 deletions(-)
> >
> > diff --git a/src/compositor.c b/src/compositor.c
> > index 3213a7b..8da348a 100644
> > --- a/src/compositor.c
> > +++ b/src/compositor.c
> > @@ -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));
> > diff --git a/src/compositor.h b/src/compositor.h
> > index 7600ce3..6db3c61 100644
> > --- a/src/compositor.h
> > +++ b/src/compositor.h
> > @@ -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;
> >
> > --
> > 1.8.3.4
> >
> > _______________________________________________
> > wayland-devel mailing list
> > wayland-devel at lists.freedesktop.org
> > http://lists.freedesktop.org/mailman/listinfo/wayland-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/wayland-devel/attachments/20130814/a21b8eee/attachment.html>
More information about the wayland-devel
mailing list