compositor: Add wlsc_shm_buffer_attach

dev
Benjamin Franzke 14 years ago committed by Kristian Høgsberg
parent bde55ec8e4
commit 0c347f0d72
  1. 4
      compositor/compositor.c
  2. 6
      compositor/compositor.h
  3. 24
      compositor/shm.c

@ -293,8 +293,8 @@ wlsc_buffer_attach(struct wl_buffer *buffer, struct wl_surface *surface)
struct wlsc_surface *es = (struct wlsc_surface *) surface;
struct wlsc_compositor *ec = es->compositor;
if (buffer->attach) {
buffer->attach(buffer, surface);
if (wlsc_is_shm_buffer(buffer)) {
wlsc_shm_buffer_attach(buffer, surface);
} else {
es->image = eglCreateImageKHR(ec->display, NULL,
EGL_WAYLAND_BUFFER_WL,

@ -244,6 +244,12 @@ wlsc_selection_set_focus(struct wl_selection *selection,
uint32_t
get_time(void);
int
wlsc_is_shm_buffer(struct wl_buffer *buffer);
void
wlsc_shm_buffer_attach(struct wl_buffer *buffer, struct wl_surface *surface);
struct wl_buffer *
wlsc_shm_buffer_create(struct wlsc_compositor *ec,
int32_t width, int32_t height,

@ -86,8 +86,16 @@ const static struct wl_buffer_interface buffer_interface = {
buffer_destroy
};
static void
shm_buffer_attach(struct wl_buffer *buffer_base, struct wl_surface *surface)
int
wlsc_is_shm_buffer(struct wl_buffer *buffer)
{
return buffer->resource.object.implementation ==
(void (**)(void)) &buffer_interface;
}
void
wlsc_shm_buffer_attach(struct wl_buffer *buffer_base,
struct wl_surface *surface)
{
struct wlsc_surface *es = (struct wlsc_surface *) surface;
struct wlsc_shm_buffer *buffer =
@ -121,10 +129,15 @@ wlsc_shm_buffer_init(struct wlsc_compositor *compositor,
buffer->buffer.width = width;
buffer->buffer.height = height;
buffer->buffer.visual = visual;
buffer->buffer.attach = shm_buffer_attach;
buffer->stride = stride;
buffer->data = data;
buffer->buffer.resource.object.interface = &wl_buffer_interface;
buffer->buffer.resource.object.implementation = (void (**)(void))
&buffer_interface;
buffer->buffer.resource.destroy = destroy_buffer;
return buffer;
}
@ -183,11 +196,6 @@ shm_create_buffer(struct wl_client *client, struct wl_shm *shm,
buffer->mapped = 1;
buffer->buffer.resource.object.id = id;
buffer->buffer.resource.object.interface = &wl_buffer_interface;
buffer->buffer.resource.object.implementation = (void (**)(void))
&buffer_interface;
buffer->buffer.resource.destroy = destroy_buffer;
wl_client_add_resource(client, &buffer->buffer.resource);
}

Loading…
Cancel
Save