EGLint err;
int32_t plane;
- buffer = wayland_drm_buffer_get((struct wl_resource *) _buffer);
+ buffer = wayland_drm_buffer_get(dri2_dpy->wl_server_drm,
+ (struct wl_resource *) _buffer);
if (!buffer)
return NULL;
if (!dri2_dpy->wl_server_drm)
return EGL_FALSE;
+ /* We have to share the wl_drm instance with gbm, so gbm can convert
+ * wl_buffers to gbm bos. */
+ dri2_dpy->gbm_dri->wl_drm = dri2_dpy->wl_server_drm;
+
return EGL_TRUE;
}
struct wl_resource *buffer_resource,
EGLint attribute, EGLint *value)
{
+ struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
struct wl_drm_buffer *buffer;
const struct wl_drm_components_descriptor *format;
- buffer = wayland_drm_buffer_get(buffer_resource);
+ buffer = wayland_drm_buffer_get(dri2_dpy->wl_server_drm, buffer_resource);
if (!buffer)
return EGL_FALSE;
uint32_t flags;
struct wayland_drm_callbacks *callbacks;
+
+ struct wl_buffer_interface buffer_interface;
};
static void
wl_resource_destroy(resource);
}
-const static struct wl_buffer_interface drm_buffer_interface = {
- buffer_destroy
-};
-
static void
create_buffer(struct wl_client *client, struct wl_resource *resource,
uint32_t id, uint32_t name, int fd,
}
wl_resource_set_implementation(buffer->resource,
- (void (**)(void)) &drm_buffer_interface,
+ (void (**)(void)) &drm->buffer_interface,
buffer, destroy_buffer);
}
}
struct wl_drm_buffer *
-wayland_drm_buffer_get(struct wl_resource *resource)
+wayland_drm_buffer_get(struct wl_drm *drm, struct wl_resource *resource)
{
+ struct wl_drm_buffer *buffer;
+
if (resource == NULL)
return NULL;
- if (wl_resource_instance_of(resource, &wl_buffer_interface,
- &drm_buffer_interface))
+ if (wl_resource_instance_of(resource, &wl_buffer_interface,
+ &drm->buffer_interface))
return wl_resource_get_user_data(resource);
- else
+ else
return NULL;
}
drm->user_data = user_data;
drm->flags = flags;
+ drm->buffer_interface.destroy = buffer_destroy;
+
wl_global_create(display, &wl_drm_interface, 2, drm, bind_drm);
return drm;
enum { WAYLAND_DRM_PRIME = 0x01 };
struct wl_drm_buffer *
-wayland_drm_buffer_get(struct wl_resource *resource);
+wayland_drm_buffer_get(struct wl_drm *drm, struct wl_resource *resource);
struct wl_drm *
wayland_drm_init(struct wl_display *display, char *device_name,
wayland_drm_bufmgr_wl_buffer_get_resource(struct native_display *ndpy,
struct wl_resource *buffer_resource)
{
- struct wl_drm_buffer *buffer = wayland_drm_buffer_get(buffer_resource);
+ struct wayland_drm_bufmgr *bufmgr;
+ struct wl_drm_buffer *buffer;
+
+ bufmgr = wayland_drm_bufmgr(ndpy->wayland_bufmgr);
+ buffer = wayland_drm_buffer_get(bufmgr->wl_server_drm, buffer_resource);
if (!buffer)
return NULL;
struct wl_resource *buffer_resource,
int attribute, int *value)
{
- struct wl_drm_buffer *buffer = wayland_drm_buffer_get(buffer_resource);
+ struct wayland_drm_bufmgr *bufmgr;
+ struct wl_drm_buffer *buffer;
struct pipe_resource *resource;
+ bufmgr = wayland_drm_bufmgr(ndpy->wayland_bufmgr);
+ buffer = wayland_drm_buffer_get(bufmgr->wl_server_drm, buffer_resource);
if (!buffer)
return FALSE;
{
struct wl_drm_buffer *wb;
- wb = wayland_drm_buffer_get((struct wl_resource *) buffer);
+ if (!dri->wl_drm)
+ return NULL;
+
+ wb = wayland_drm_buffer_get(dri->wl_drm, (struct wl_resource *) buffer);
if (!wb)
return NULL;
int *width, int *height,
unsigned int *attachments, int count,
int *out_count, void *data);
+
+ struct wl_drm *wl_drm;
};
struct gbm_dri_bo {