Merge remote-tracking branch 'bnf/buffer.release'

This commit is contained in:
Kristian Høgsberg 2011-06-21 12:15:31 -04:00
commit 7dc36984af
3 changed files with 9 additions and 4 deletions

View file

@ -144,6 +144,9 @@
<!-- Destroy a buffer. This will invalidate the object id. --> <!-- Destroy a buffer. This will invalidate the object id. -->
<request name="destroy" type="destructor"/> <request name="destroy" type="destructor"/>
<!-- Sent when an attached buffer is no longer used by the compositor. -->
<event name="release"/>
</interface> </interface>
<interface name="wl_shell" version="1"> <interface name="wl_shell" version="1">

View file

@ -134,9 +134,10 @@ struct wl_resource {
struct wl_buffer { struct wl_buffer {
struct wl_resource resource; struct wl_resource resource;
struct wl_compositor *compositor; struct wl_client *client;
struct wl_visual *visual; struct wl_visual *visual;
int32_t width, height; int32_t width, height;
uint32_t busy_count;
void *user_data; void *user_data;
}; };

View file

@ -80,20 +80,21 @@ const static struct wl_buffer_interface shm_buffer_interface = {
}; };
static struct wl_shm_buffer * static struct wl_shm_buffer *
wl_shm_buffer_init(struct wl_shm *shm, uint32_t id, wl_shm_buffer_init(struct wl_shm *shm, struct wl_client *client, uint32_t id,
int32_t width, int32_t height, int32_t width, int32_t height,
int32_t stride, struct wl_visual *visual, int32_t stride, struct wl_visual *visual,
void *data) void *data)
{ {
struct wl_shm_buffer *buffer; struct wl_shm_buffer *buffer;
buffer = malloc(sizeof *buffer); buffer = calloc(1, sizeof *buffer);
if (buffer == NULL) if (buffer == NULL)
return NULL; return NULL;
buffer->buffer.width = width; buffer->buffer.width = width;
buffer->buffer.height = height; buffer->buffer.height = height;
buffer->buffer.visual = visual; buffer->buffer.visual = visual;
buffer->buffer.client = client;
buffer->stride = stride; buffer->stride = stride;
buffer->data = data; buffer->data = data;
@ -147,7 +148,7 @@ shm_create_buffer(struct wl_client *client, struct wl_shm *shm,
return; return;
} }
buffer = wl_shm_buffer_init(shm, id, buffer = wl_shm_buffer_init(shm, client, id,
width, height, stride, visual, width, height, stride, visual,
data); data);
if (buffer == NULL) { if (buffer == NULL) {