[PATCH weston 6/6] window: honour wl_buffer.release
Pekka Paalanen
ppaalanen at gmail.com
Mon Dec 3 03:55:26 PST 2012
On Tue, 27 Nov 2012 15:57:30 -0500
Kristian Høgsberg <hoegsberg at gmail.com> wrote:
> On Mon, Nov 19, 2012 at 05:16:02PM +0200, Pekka Paalanen wrote:
> > Listen for wl_buffer.release events in the shm path, and if a previously
> > posted buffer is still held by the server, allocate another one. The
> > maximum of two should be enough, since there is no point for a server to
> > hold more than one buffer at a time.
> >
> > Buffer allocation happens as needed instead of window creation time.
> >
> > Signed-off-by: Pekka Paalanen <ppaalanen at gmail.com>
> > ---
> > clients/window.c | 113 ++++++++++++++++++++++++++++++++++++------------------
> > 1 files changed, 76 insertions(+), 37 deletions(-)
> >
> > diff --git a/clients/window.c b/clients/window.c
> > index bda6866..0279aae 100644
> > --- a/clients/window.c
> > +++ b/clients/window.c
> > @@ -782,6 +782,26 @@ display_create_surface(struct display *display,
> > NULL, NULL);
> > }
> >
> > +struct shm_surface_leaf {
> > + cairo_surface_t *cairo_surface;
> > + /* 'data' is automatically destroyed, when 'cairo_surface' is */
> > + struct shm_surface_data *data;
> > +
> > + struct shm_pool *resize_pool;
> > + int busy;
> > +};
> > +
> > +static void
> > +shm_surface_leaf_release(struct shm_surface_leaf *leaf)
> > +{
> > + if (leaf->cairo_surface)
> > + cairo_surface_destroy(leaf->cairo_surface);
> > + /* leaf->data already destroyed via cairo private */
> > +
> > + if (leaf->resize_pool)
> > + shm_pool_destroy(leaf->resize_pool);
> > +}
> > +
> > struct shm_surface {
> > struct toysurface base;
> > struct display *display;
> > @@ -789,11 +809,8 @@ struct shm_surface {
> > uint32_t flags;
> > int dx, dy;
> >
> > - cairo_surface_t *cairo_surface;
> > - /* 'data' is automatically destroyed, when 'cairo_surface' is */
> > - struct shm_surface_data *data;
> > -
> > - struct shm_pool *resize_pool;
> > + struct shm_surface_leaf leaf[2];
> > + struct shm_surface_leaf *current;
> > };
> >
> > static struct shm_surface *
> > @@ -802,50 +819,78 @@ to_shm_surface(struct toysurface *base)
> > return container_of(base, struct shm_surface, base);
> > }
> >
> > +static void
> > +shm_surface_buffer_release(void *data, struct wl_buffer *buffer)
> > +{
> > + struct shm_surface_leaf *leaf = data;
> > +
> > + leaf->busy = 0;
>
> If we end up with both buffers released, should we
> shm_surface_leaf_release() it?
Hi Kristian,
in theory yes, it would be nice, but I do not think such a case can
occur with the existing backends, ever. The compositor, or backends
really, do not dynamically switch between allowing single-buffered
clients and requiring clients to double-buffer. The backends either
always require double-buffering (egl buffers, and shm buffers on rpi
with planes enabled), or they pass shm buffers only to the gl-renderer
and allow single-buffering. I also cannot imagine a realistic scenario,
where dynamic switching would be useful enough.
Do you want me to implement it still? Testing it will be a bit of a
hassle, since I need to force the compositor to dynamically change its
behaviour.
Or just add a comment stating the above?
Thanks,
pq
More information about the wayland-devel
mailing list