[PATCH] client: Add a way to get a pointer to the display's default queue

Tomeu Vizoso tomeu at tomeuvizoso.net
Fri Oct 4 07:43:52 PDT 2013


Hi,

I have find myself needing this in order to make sure that wl_buffers
are destroyed when the wl_surface is, but not before the compositor
releases them.

So, the client app would be calling wl_surface_destroy, but as the
front wl_buffer is still in use by the compositor, the EGL
implementation will need to defer the destruction until the
wl_buffer.release event comes. But the wl_buffers are using the EGL
implementation's queue and only the main queue is spinning right now,
so the release wouldn't be dispatched ever and the buffer would be
destroyed only after the client is disconnected.

Mesa doesn't seem to care about it and destroys the wl_buffers right
away, which also destroys the underlying images, but I guess with
most/all DRM drivers the buffers are refcounted and it doesn't matter.

With Neil's patch I can set the wl_buffer's queue to be the main one
when the client schedules the destroy, so I eventually get the
wl_buffer.release event.

Regards,

Tomeu


On 10 September 2013 15:47, Neil Roberts <neil at linux.intel.com> wrote:
> Adds a function called wl_display_get_main_queue which just returns a
> pointer to the default event queue. This will be useful in order to
> implement the EGL_WL_create_wayland_buffer_from_image extension. The
> buffers created within Mesa's Wayland platform are created using the
> the wl_drm object as a proxy factory which means they will be set to
> use Mesa's internal event queue. However, these buffers will be owned
> by the client application so they ideally need to use the default
> event loop. This function provides a way to set the proxy's event
> queue back to the default.
> ---
>  src/wayland-client.c | 14 ++++++++++++++
>  src/wayland-client.h |  1 +
>  2 files changed, 15 insertions(+)
>
> diff --git a/src/wayland-client.c b/src/wayland-client.c
> index 04d988b..48f06c7 100644
> --- a/src/wayland-client.c
> +++ b/src/wayland-client.c
> @@ -194,6 +194,20 @@ wl_display_create_queue(struct wl_display *display)
>         return queue;
>  }
>
> +/** Get the main event queue for this display
> + *
> + * \param display The display context object
> + * \return A pointer to the main default event queue used with this
> + * display.
> + *
> + * \memberof wl_display
> + */
> +WL_EXPORT struct wl_event_queue *
> +wl_display_get_main_queue(struct wl_display *display)
> +{
> +       return &display->queue;
> +}
> +
>  /** Create a proxy object with a given interface
>   *
>   * \param factory Factory proxy object
> diff --git a/src/wayland-client.h b/src/wayland-client.h
> index cf92174..8cf6847 100644
> --- a/src/wayland-client.h
> +++ b/src/wayland-client.h
> @@ -157,6 +157,7 @@ int wl_display_get_error(struct wl_display *display);
>  int wl_display_flush(struct wl_display *display);
>  int wl_display_roundtrip(struct wl_display *display);
>  struct wl_event_queue *wl_display_create_queue(struct wl_display *display);
> +struct wl_event_queue *wl_display_get_main_queue(struct wl_display *display);
>
>  int wl_display_prepare_read_queue(struct wl_display *display,
>                                   struct wl_event_queue *queue);
> --
> 1.8.3.1
>
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/wayland-devel


More information about the wayland-devel mailing list