{
struct wayland_shm_display *shmdpy = wayland_shm_display(ndpy);
- if (shmdpy->base.config)
- FREE(shmdpy->base.config);
+ if (shmdpy->base.configs)
+ FREE(shmdpy->base.configs);
if (shmdpy->base.own_dpy)
wl_display_destroy(shmdpy->base.dpy);
FREE(shmdpy);
}
-
static struct wl_buffer *
wayland_create_shm_buffer(struct wayland_display *display,
struct wayland_surface *surface,
struct pipe_resource *resource;
struct winsys_handle wsh;
uint width, height;
- struct wl_visual *visual;
+ enum wl_shm_format format;
resource = resource_surface_get_single_resource(surface->rsurf, attachment);
resource_surface_get_size(surface->rsurf, &width, &height);
pipe_resource_reference(&resource, NULL);
- switch (surface->type) {
- case WL_WINDOW_SURFACE:
- visual = surface->win->visual;
+ switch (surface->color_format) {
+ case PIPE_FORMAT_B8G8R8A8_UNORM:
+ format = (surface->premultiplied_alpha) ?
+ WL_SHM_FORMAT_PREMULTIPLIED_ARGB32 : WL_SHM_FORMAT_ARGB32;
break;
- case WL_PIXMAP_SURFACE:
- visual = surface->pix->visual;
+ case PIPE_FORMAT_B8G8R8X8_UNORM:
+ format = WL_SHM_FORMAT_XRGB32;
break;
default:
return NULL;
+ break;
}
return wl_shm_create_buffer(shmdpy->wl_shm, wsh.fd,
width, height,
- wsh.stride, visual);
+ wsh.stride, format);
+}
+
+static void
+shm_handle_format(void *data, struct wl_shm *shm, uint32_t format)
+{
+ struct wayland_shm_display *shmdpy = data;
+
+ switch (format) {
+ case WL_SHM_FORMAT_ARGB32:
+ shmdpy->base.formats |= HAS_ARGB8888;
+ break;
+ case WL_SHM_FORMAT_XRGB8888:
+ shmdpy->base.formats |= HAS_XRGB8888;
+ break;
+ }
}
+static const struct wl_shm_listener shm_listener = {
+ shm_handle_format
+};
+
static boolean
wayland_shm_display_init_screen(struct native_display *ndpy)
{
if (!shmdpy->wl_shm)
return FALSE;
+ wl_shm_add_listener(shmdpy->wl_shm, &shm_listener, shmdpy);
+
+ if (shmdpy->base.formats == 0)
+ wl_display_roundtrip(shmdpy->base.dpy);
+ if (shmdpy->base.formats == 0)
+ return FALSE;
+
winsys = wayland_create_sw_winsys(shmdpy->base.dpy);
if (!winsys)
return FALSE;