[RFC mesa] wayland-drm: Update wl_drm_buffer to use the new version of wl_buffer based on a wl_resource pointer

Jason Ekstrand jason at jlekstrand.net
Tue Mar 19 12:18:06 PDT 2013


---
 src/egl/wayland/wayland-drm/wayland-drm.c | 20 ++++++++------------
 1 file changed, 8 insertions(+), 12 deletions(-)

diff --git a/src/egl/wayland/wayland-drm/wayland-drm.c b/src/egl/wayland/wayland-drm/wayland-drm.c
index d02aab6..8d4972a 100644
--- a/src/egl/wayland/wayland-drm/wayland-drm.c
+++ b/src/egl/wayland/wayland-drm/wayland-drm.c
@@ -82,6 +82,7 @@ create_buffer(struct wl_client *client, struct wl_resource *resource,
 		return;
 	}
 
+	buffer->buffer.implementation = &drm_buffer_interface;
 	buffer->drm = drm;
 	buffer->buffer.width = width;
 	buffer->buffer.height = height;
@@ -101,16 +102,12 @@ create_buffer(struct wl_client *client, struct wl_resource *resource,
 		return;
 	}
 
-	buffer->buffer.resource.object.id = id;
-	buffer->buffer.resource.object.interface = &wl_buffer_interface;
-	buffer->buffer.resource.object.implementation =
-		(void (**)(void)) &drm_buffer_interface;
-	buffer->buffer.resource.data = buffer;
+	buffer->buffer.resource = wl_client_add_object(wl_resource_get_client(resource),
+						       &wl_buffer_interface,
+						       &drm_buffer_interface,
+						       id, buffer);
 
-	buffer->buffer.resource.destroy = destroy_buffer;
-	buffer->buffer.resource.client = resource->client;
-
-	wl_client_add_resource(resource->client, &buffer->buffer.resource);
+	wl_resource_set_destructor(buffer->buffer.resource, destroy_buffer);
 }
 
 static void
@@ -167,7 +164,7 @@ static void
 drm_authenticate(struct wl_client *client,
 		 struct wl_resource *resource, uint32_t id)
 {
-	struct wl_drm *drm = resource->data;
+	struct wl_drm *drm = wl_resource_get_user_data(resource);
 
 	if (drm->callbacks->authenticate(drm->user_data, id) < 0)
 		wl_resource_post_error(resource,
@@ -237,8 +234,7 @@ wayland_drm_uninit(struct wl_drm *drm)
 int
 wayland_buffer_is_drm(struct wl_buffer *buffer)
 {
-	return buffer->resource.object.implementation == 
-		(void (**)(void)) &drm_buffer_interface;
+	return buffer->implementation == &drm_buffer_interface;
 }
 
 uint32_t
-- 
1.8.1.4



More information about the wayland-devel mailing list