[PATCH weston 2/8] compositor: add and export weston_buffer_reference()
Pekka Paalanen
ppaalanen at gmail.com
Wed Nov 28 10:13:50 PST 2012
On Wed, 28 Nov 2012 09:49:18 -0500
Kristian Høgsberg <hoegsberg at gmail.com> wrote:
> On Fri, Nov 23, 2012 at 03:56:51PM +0200, Pekka Paalanen wrote:
> > The wl_buffer reference counting API has been inconsistent. You would
> > manually increment the refcount and register a destroy listener, as
> > opposed to calling weston_buffer_post_release(), which internally
> > decremented the refcount, and then removing a list item.
> >
> > Replace both cases with a single function:
> > weston_buffer_reference(wl_buffer **ref, wl_buffer *buffer, listener)
> >
> > Buffer is assigned to *ref, while taking care of all the refcounting and
> > release posting. You take a reference by passing a non-NULL buffer, and
> > release a reference by passing NULL as buffer. Registering and
> > de-registering the destroy listener is included.
> >
> > This is inspired by the pipe_resource_reference() of Mesa.
> >
> > Additionally, when a surface gets destroyed, the associated wl_buffer
> > will send a release event. Usually the buffer is already destroyed on
> > client side, so the event will be discarded by libwayland-client.
> >
> > Signed-off-by: Pekka Paalanen <ppaalanen at gmail.com>
>
> I think this is fine, but can we make it a struct
> weston_buffer_reference instead, that includes the struct wl_listener
> and buffer pointer? All users just set up a listener that NULLs the
> buffer pointers so we should pull that logic into the reference and
> reduce the required boilerplate code.
Cool, I can do that.
Though I might have some urgent stuff to do, so may take till next
week.
Thanks,
pq
More information about the wayland-devel
mailing list