<div dir="ltr">NEGLECT THIS PATCH<br><br>New one to come<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Jun 20, 2013 at 8:16 PM, Jason Ekstrand <span dir="ltr"><<a href="mailto:jason@jlekstrand.net" target="_blank">jason@jlekstrand.net</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">This commit adds a weston_buffer structure to replace wl_buffer.  This way<br>
we can hold onto buffers by just their resource.  In order to do this, the<br>
every renderer.attach function has to fill in the weston_buffer.width and<br>
weston_buffer.height fields.<br>
---<br>
<br>
NOTE: While this patch touches compositor-drm and rpi-renderer, I have NOT<br>
tested this patch on DRM/KMS or on the Rhaspbery Pi.  This is because I do<br>
not own a Rhaspbery Pi and my laptop is refusing to do DRM/KMS right now<br>
for some unknown reason.<br>
<br>
 src/compositor-drm.c  | 14 ++++++-------<br>
 src/compositor.c      | 57 ++++++++++++++++++++++++++++++++++++++++++---------<br>
 src/compositor.h      | 25 ++++++++++++++++++----<br>
 src/gl-renderer.c     | 29 ++++++++++++++++----------<br>
 src/noop-renderer.c   |  2 +-<br>
 src/pixman-renderer.c | 21 ++++++++++++-------<br>
 src/rpi-renderer.c    | 30 ++++++++++++++++-----------<br>
 src/screenshooter.c   | 15 +++++++++-----<br>
 8 files changed, 136 insertions(+), 57 deletions(-)<br>
<br>
diff --git a/src/compositor-drm.c b/src/compositor-drm.c<br>
index 8787723..5e5c51c 100644<br>
--- a/src/compositor-drm.c<br>
+++ b/src/compositor-drm.c<br>
@@ -371,7 +371,7 @@ err_free:<br>
 }<br>
<br>
 static void<br>
-drm_fb_set_buffer(struct drm_fb *fb, struct wl_buffer *buffer)<br>
+drm_fb_set_buffer(struct drm_fb *fb, struct weston_buffer *buffer)<br>
 {<br>
        assert(fb->buffer_ref.buffer == NULL);<br>
<br>
@@ -437,7 +437,7 @@ drm_output_prepare_scanout_surface(struct weston_output *_output,<br>
        struct drm_output *output = (struct drm_output *) _output;<br>
        struct drm_compositor *c =<br>
                (struct drm_compositor *) output->base.compositor;<br>
-       struct wl_buffer *buffer = es->buffer_ref.buffer;<br>
+       struct weston_buffer *buffer = es->buffer_ref.buffer;<br>
        struct gbm_bo *bo;<br>
        uint32_t format;<br>
<br>
@@ -791,7 +791,7 @@ drm_output_prepare_overlay_surface(struct weston_output *output_base,<br>
        if (es->alpha != 1.0f)<br>
                return NULL;<br>
<br>
-       if (wl_buffer_is_shm(es->buffer_ref.buffer))<br>
+       if (wl_shm_buffer_get(es->buffer_ref.buffer->resource))<br>
                return NULL;<br>
<br>
        if (!drm_surface_transform_supported(es))<br>
@@ -915,7 +915,7 @@ drm_output_prepare_cursor_surface(struct weston_output *output_base,<br>
        if (c->cursors_are_broken)<br>
                return NULL;<br>
        if (es->buffer_ref.buffer == NULL ||<br>
-           !wl_buffer_is_shm(es->buffer_ref.buffer) ||<br>
+           !wl_shm_buffer_get(es->buffer_ref.buffer->resource) ||<br>
            es->geometry.width > 64 || es->geometry.height > 64)<br>
                return NULL;<br>
<br>
@@ -949,8 +949,8 @@ drm_output_set_cursor(struct drm_output *output)<br>
                output->current_cursor ^= 1;<br>
                bo = output->cursor_bo[output->current_cursor];<br>
                memset(buf, 0, sizeof buf);<br>
-               stride = wl_shm_buffer_get_stride(es->buffer_ref.buffer);<br>
-               s = wl_shm_buffer_get_data(es->buffer_ref.buffer);<br>
+               stride = wl_shm_buffer_get_stride(es->buffer_ref.buffer->shm_buffer);<br>
+               s = wl_shm_buffer_get_data(es->buffer_ref.buffer->shm_buffer);<br>
                for (i = 0; i < es->geometry.height; i++)<br>
                        memcpy(buf + i * 64, s + i * stride,<br>
                               es->geometry.width * 4);<br>
@@ -1008,7 +1008,7 @@ drm_assign_planes(struct weston_output *output)<br>
                 * non-shm, or small enough to be a cursor<br>
                 */<br>
                if ((es->buffer_ref.buffer &&<br>
-                    !wl_buffer_is_shm(es->buffer_ref.buffer)) ||<br>
+                    !wl_shm_buffer_get(es->buffer_ref.buffer->resource)) ||<br>
                    (es->geometry.width <= 64 && es->geometry.height <= 64))<br>
                        es->keep_buffer = 1;<br>
                else<br>
diff --git a/src/compositor.c b/src/compositor.c<br>
index 5c82413..af273b9 100644<br>
--- a/src/compositor.c<br>
+++ b/src/compositor.c<br>
@@ -1053,6 +1053,42 @@ destroy_surface(struct wl_resource *resource)<br>
 }<br>
<br>
 static void<br>
+weston_buffer_destroy_handler(struct wl_listener *listener, void *data)<br>
+{<br>
+       struct weston_buffer *buffer =<br>
+               container_of(listener, struct weston_buffer, destroy_listener);<br>
+<br>
+       wl_signal_emit(&buffer->destroy_signal, buffer);<br>
+       free(buffer);<br>
+}<br>
+<br>
+struct weston_buffer *<br>
+weston_buffer_from_resource(struct wl_resource *resource)<br>
+{<br>
+       struct weston_buffer *buffer;<br>
+       struct wl_listener *listener;<br>
+<br>
+       listener = wl_resource_get_destroy_listener(resource,<br>
+                                                   weston_buffer_destroy_handler);<br>
+<br>
+       if (listener) {<br>
+               buffer = container_of(listener, struct weston_buffer,<br>
+                                     destroy_listener);<br>
+       } else {<br>
+               buffer = malloc(sizeof *buffer);<br>
+               memset(buffer, 0, sizeof *buffer);<br>
+<br>
+               buffer->resource = resource;<br>
+               wl_signal_init(&buffer->destroy_signal);<br>
+               buffer->destroy_listener.notify = weston_buffer_destroy_handler;<br>
+               wl_resource_add_destroy_listener(resource,<br>
+                                                &buffer->destroy_listener);<br>
+       }<br>
+<br>
+       return buffer;<br>
+}<br>
+<br>
+static void<br>
 weston_buffer_reference_handle_destroy(struct wl_listener *listener,<br>
                                       void *data)<br>
 {<br>
@@ -1060,19 +1096,19 @@ weston_buffer_reference_handle_destroy(struct wl_listener *listener,<br>
                container_of(listener, struct weston_buffer_reference,<br>
                             destroy_listener);<br>
<br>
-       assert((struct wl_buffer *)data == ref->buffer);<br>
+       assert((struct weston_buffer *)data == ref->buffer);<br>
        ref->buffer = NULL;<br>
 }<br>
<br>
 WL_EXPORT void<br>
 weston_buffer_reference(struct weston_buffer_reference *ref,<br>
-                       struct wl_buffer *buffer)<br>
+                       struct weston_buffer *buffer)<br>
 {<br>
        if (ref->buffer && buffer != ref->buffer) {<br>
                ref->buffer->busy_count--;<br>
                if (ref->buffer->busy_count == 0) {<br>
-                       assert(ref->buffer->resource.client != NULL);<br>
-                       wl_resource_queue_event(&ref->buffer->resource,<br>
+                       assert(wl_resource_get_client(ref->buffer->resource));<br>
+                       wl_resource_queue_event(ref->buffer->resource,<br>
                                                WL_BUFFER_RELEASE);<br>
                }<br>
                wl_list_remove(&ref->destroy_listener.link);<br>
@@ -1080,7 +1116,7 @@ weston_buffer_reference(struct weston_buffer_reference *ref,<br>
<br>
        if (buffer && buffer != ref->buffer) {<br>
                buffer->busy_count++;<br>
-               wl_signal_add(&buffer->resource.destroy_signal,<br>
+               wl_signal_add(&buffer->destroy_signal,<br>
                              &ref->destroy_listener);<br>
        }<br>
<br>
@@ -1089,7 +1125,8 @@ weston_buffer_reference(struct weston_buffer_reference *ref,<br>
 }<br>
<br>
 static void<br>
-weston_surface_attach(struct weston_surface *surface, struct wl_buffer *buffer)<br>
+weston_surface_attach(struct weston_surface *surface,<br>
+                     struct weston_buffer *buffer)<br>
 {<br>
        weston_buffer_reference(&surface->buffer_ref, buffer);<br>
<br>
@@ -1135,7 +1172,7 @@ surface_accumulate_damage(struct weston_surface *surface,<br>
                          pixman_region32_t *opaque)<br>
 {<br>
        if (surface->buffer_ref.buffer &&<br>
-           wl_buffer_is_shm(surface->buffer_ref.buffer))<br>
+           wl_shm_buffer_get(surface->buffer_ref.buffer->resource))<br>
                surface->compositor->renderer->flush_damage(surface);<br>
<br>
        if (surface->transform.enabled) {<br>
@@ -1398,10 +1435,10 @@ surface_attach(struct wl_client *client,<br>
               struct wl_resource *buffer_resource, int32_t sx, int32_t sy)<br>
 {<br>
        struct weston_surface *surface = wl_resource_get_user_data(resource);<br>
-       struct wl_buffer *buffer = NULL;<br>
+       struct weston_buffer *buffer = NULL;<br>
<br>
        if (buffer_resource)<br>
-               buffer = buffer_resource->data;<br>
+               buffer = weston_buffer_from_resource(buffer_resource);<br>
<br>
        /* Attach, attach, without commit in between does not send<br>
         * wl_buffer.release. */<br>
@@ -1413,7 +1450,7 @@ surface_attach(struct wl_client *client,<br>
        surface->pending.buffer = buffer;<br>
        surface->pending.newly_attached = 1;<br>
        if (buffer) {<br>
-               wl_signal_add(&buffer->resource.destroy_signal,<br>
+               wl_signal_add(&buffer->destroy_signal,<br>
                              &surface->pending.buffer_destroy_listener);<br>
        }<br>
 }<br>
diff --git a/src/compositor.h b/src/compositor.h<br>
index 774fb96..a419d4f 100644<br>
--- a/src/compositor.h<br>
+++ b/src/compositor.h<br>
@@ -48,6 +48,7 @@ struct weston_transform {<br>
 };<br>
<br>
 struct weston_surface;<br>
+struct weston_buffer;<br>
 struct shell_surface;<br>
 struct weston_seat;<br>
 struct weston_output;<br>
@@ -488,7 +489,7 @@ struct weston_renderer {<br>
        void (*repaint_output)(struct weston_output *output,<br>
                               pixman_region32_t *output_damage);<br>
        void (*flush_damage)(struct weston_surface *surface);<br>
-       void (*attach)(struct weston_surface *es, struct wl_buffer *buffer);<br>
+       void (*attach)(struct weston_surface *es, struct weston_buffer *buffer);<br>
        int (*create_surface)(struct weston_surface *surface);<br>
        void (*surface_set_color)(struct weston_surface *surface,<br>
                               float red, float green,<br>
@@ -573,8 +574,21 @@ struct weston_compositor {<br>
        struct weston_xkb_info xkb_info;<br>
 };<br>
<br>
+struct weston_buffer {<br>
+       struct wl_resource *resource;<br>
+       struct wl_signal destroy_signal;<br>
+       struct wl_listener destroy_listener;<br>
+<br>
+       union {<br>
+               struct wl_shm_buffer *shm_buffer;<br>
+               struct wl_buffer *legacy_buffer;<br>
+       };<br>
+       int32_t width, height;<br>
+       uint32_t busy_count;<br>
+};<br>
+<br>
 struct weston_buffer_reference {<br>
-       struct wl_buffer *buffer;<br>
+       struct weston_buffer *buffer;<br>
        struct wl_listener destroy_listener;<br>
 };<br>
<br>
@@ -739,7 +753,7 @@ struct weston_surface {<br>
        struct {<br>
                /* wl_surface.attach */<br>
                int newly_attached;<br>
-               struct wl_buffer *buffer;<br>
+               struct weston_buffer *buffer;<br>
                struct wl_listener buffer_destroy_listener;<br>
                int32_t sx;<br>
                int32_t sy;<br>
@@ -1016,9 +1030,12 @@ weston_surface_unmap(struct weston_surface *surface);<br>
 struct weston_surface *<br>
 weston_surface_get_main_surface(struct weston_surface *surface);<br>
<br>
+struct weston_buffer *<br>
+weston_buffer_from_resource(struct wl_resource *resource);<br>
+<br>
 void<br>
 weston_buffer_reference(struct weston_buffer_reference *ref,<br>
-                       struct wl_buffer *buffer);<br>
+                       struct weston_buffer *buffer);<br>
<br>
 uint32_t<br>
 weston_compositor_get_time(void);<br>
diff --git a/src/gl-renderer.c b/src/gl-renderer.c<br>
index 7d27a97..6b88d6a 100644<br>
--- a/src/gl-renderer.c<br>
+++ b/src/gl-renderer.c<br>
@@ -1100,7 +1100,7 @@ gl_renderer_flush_damage(struct weston_surface *surface)<br>
 {<br>
        struct gl_renderer *gr = get_renderer(surface->compositor);<br>
        struct gl_surface_state *gs = get_surface_state(surface);<br>
-       struct wl_buffer *buffer = gs->buffer_ref.buffer;<br>
+       struct weston_buffer *buffer = gs->buffer_ref.buffer;<br>
<br>
 #ifdef GL_UNPACK_ROW_LENGTH<br>
        pixman_box32_t *rectangles;<br>
@@ -1131,7 +1131,7 @@ gl_renderer_flush_damage(struct weston_surface *surface)<br>
                glTexImage2D(GL_TEXTURE_2D, 0, GL_BGRA_EXT,<br>
                             gs->pitch, buffer->height, 0,<br>
                             GL_BGRA_EXT, GL_UNSIGNED_BYTE,<br>
-                            wl_shm_buffer_get_data(buffer));<br>
+                            wl_shm_buffer_get_data(buffer->shm_buffer));<br>
<br>
                goto done;<br>
        }<br>
@@ -1139,7 +1139,7 @@ gl_renderer_flush_damage(struct weston_surface *surface)<br>
 #ifdef GL_UNPACK_ROW_LENGTH<br>
        /* Mesa does not define GL_EXT_unpack_subimage */<br>
        glPixelStorei(GL_UNPACK_ROW_LENGTH, gs->pitch);<br>
-       data = wl_shm_buffer_get_data(buffer);<br>
+       data = wl_shm_buffer_get_data(buffer->shm_buffer);<br>
        rectangles = pixman_region32_rectangles(&gs->texture_damage, &n);<br>
        for (i = 0; i < n; i++) {<br>
                pixman_box32_t r;<br>
@@ -1182,11 +1182,12 @@ ensure_textures(struct gl_surface_state *gs, int num_textures)<br>
 }<br>
<br>
 static void<br>
-gl_renderer_attach(struct weston_surface *es, struct wl_buffer *buffer)<br>
+gl_renderer_attach(struct weston_surface *es, struct weston_buffer *buffer)<br>
 {<br>
        struct weston_compositor *ec = es->compositor;<br>
        struct gl_renderer *gr = get_renderer(ec);<br>
        struct gl_surface_state *gs = get_surface_state(es);<br>
+       struct wl_shm_buffer *shm_buffer;<br>
        EGLint attribs[3], format;<br>
        int i, num_planes;<br>
<br>
@@ -1203,16 +1204,21 @@ gl_renderer_attach(struct weston_surface *es, struct wl_buffer *buffer)<br>
                return;<br>
        }<br>
<br>
-       if (wl_buffer_is_shm(buffer)) {<br>
+       shm_buffer = wl_shm_buffer_get(buffer->resource);<br>
+       if (shm_buffer) {<br>
+               buffer->shm_buffer = shm_buffer;<br>
+               buffer->width = wl_shm_buffer_get_width(shm_buffer);<br>
+               buffer->height = wl_shm_buffer_get_height(shm_buffer);<br>
+<br>
                /* Only allocate a texture if it doesn't match existing one.<br>
                 * If gs->num_images is not 0, then a switch from DRM allocated<br>
                 * buffer to a SHM buffer is happening, and we need to allocate<br>
                 * a new texture buffer. */<br>
-               if (wl_shm_buffer_get_stride(buffer) / 4 != gs->pitch ||<br>
-                   wl_shm_buffer_get_height(buffer) != gs->height ||<br>
+               if (wl_shm_buffer_get_stride(shm_buffer) / 4 != gs->pitch ||<br>
+                   buffer->height != gs->height ||<br>
                    gs->num_images > 0) {<br>
-                       gs->pitch = wl_shm_buffer_get_stride(buffer) / 4;<br>
-                       gs->height = wl_shm_buffer_get_height(buffer);<br>
+                       gs->pitch =  wl_shm_buffer_get_stride(shm_buffer) / 4;<br>
+                       gs->height = buffer->height;<br>
                        gs->target = GL_TEXTURE_2D;<br>
<br>
                        ensure_textures(gs, 1);<br>
@@ -1227,11 +1233,12 @@ gl_renderer_attach(struct weston_surface *es, struct wl_buffer *buffer)<br>
                                                   gs->height / es->buffer_scale);<br>
                }<br>
<br>
-               if (wl_shm_buffer_get_format(buffer) == WL_SHM_FORMAT_XRGB8888)<br>
+               if (wl_shm_buffer_get_format(shm_buffer) == WL_SHM_FORMAT_XRGB8888)<br>
                        gs->shader = &gr->texture_shader_rgbx;<br>
                else<br>
                        gs->shader = &gr->texture_shader_rgba;<br>
-       } else if (gr->query_buffer(gr->egl_display, buffer,<br>
+       } else if (gr->query_buffer(gr->egl_display,<br>
+                                   (struct wl_buffer *)buffer->resource,<br>
                                    EGL_TEXTURE_FORMAT, &format)) {<br>
                for (i = 0; i < gs->num_images; i++)<br>
                        gr->destroy_image(gr->egl_display, gs->images[i]);<br>
diff --git a/src/noop-renderer.c b/src/noop-renderer.c<br>
index c0765f2..91659f5 100644<br>
--- a/src/noop-renderer.c<br>
+++ b/src/noop-renderer.c<br>
@@ -47,7 +47,7 @@ noop_renderer_flush_damage(struct weston_surface *surface)<br>
 }<br>
<br>
 static void<br>
-noop_renderer_attach(struct weston_surface *es, struct wl_buffer *buffer)<br>
+noop_renderer_attach(struct weston_surface *es, struct weston_buffer *buffer)<br>
 {<br>
 }<br>
<br>
diff --git a/src/pixman-renderer.c b/src/pixman-renderer.c<br>
index 0bae1a4..25bffbe 100644<br>
--- a/src/pixman-renderer.c<br>
+++ b/src/pixman-renderer.c<br>
@@ -529,9 +529,10 @@ pixman_renderer_flush_damage(struct weston_surface *surface)<br>
 }<br>
<br>
 static void<br>
-pixman_renderer_attach(struct weston_surface *es, struct wl_buffer *buffer)<br>
+pixman_renderer_attach(struct weston_surface *es, struct weston_buffer *buffer)<br>
 {<br>
        struct pixman_surface_state *ps = get_surface_state(es);<br>
+       struct wl_shm_buffer *shm_buffer;<br>
        pixman_format_code_t pixman_format;<br>
<br>
        weston_buffer_reference(&ps->buffer_ref, buffer);<br>
@@ -543,14 +544,16 @@ pixman_renderer_attach(struct weston_surface *es, struct wl_buffer *buffer)<br>
<br>
        if (!buffer)<br>
                return;<br>
+<br>
+       shm_buffer = wl_shm_buffer_get(buffer->resource);<br>
<br>
-       if (!wl_buffer_is_shm(buffer)) {<br>
+       if (! shm_buffer) {<br>
                weston_log("Pixman renderer supports only SHM buffers\n");<br>
                weston_buffer_reference(&ps->buffer_ref, NULL);<br>
                return;<br>
        }<br>
<br>
-       switch (wl_shm_buffer_get_format(buffer)) {<br>
+       switch (wl_shm_buffer_get_format(shm_buffer)) {<br>
        case WL_SHM_FORMAT_XRGB8888:<br>
                pixman_format = PIXMAN_x8r8g8b8;<br>
                break;<br>
@@ -563,11 +566,15 @@ pixman_renderer_attach(struct weston_surface *es, struct wl_buffer *buffer)<br>
                return;<br>
        break;<br>
        }<br>
+<br>
+       buffer->shm_buffer = shm_buffer;<br>
+       buffer->width = wl_shm_buffer_get_width(shm_buffer);<br>
+       buffer->height = wl_shm_buffer_get_height(shm_buffer);<br>
+<br>
        ps->image = pixman_image_create_bits(pixman_format,<br>
-               wl_shm_buffer_get_width(buffer),<br>
-               wl_shm_buffer_get_height(buffer),<br>
-               wl_shm_buffer_get_data(buffer),<br>
-               wl_shm_buffer_get_stride(buffer));<br>
+               buffer->width, buffer->height,<br>
+               wl_shm_buffer_get_data(shm_buffer),<br>
+               wl_shm_buffer_get_stride(shm_buffer));<br>
 }<br>
<br>
 static int<br>
diff --git a/src/rpi-renderer.c b/src/rpi-renderer.c<br>
index c361185..919ecc5 100644<br>
--- a/src/rpi-renderer.c<br>
+++ b/src/rpi-renderer.c<br>
@@ -226,7 +226,7 @@ rpi_resource_realloc(struct rpi_resource *resource, VC_IMAGE_TYPE_T ifmt,<br>
 #define PREMULT_ALPHA_FLAG (1 << 31)<br>
<br>
 static VC_IMAGE_TYPE_T<br>
-shm_buffer_get_vc_format(struct wl_buffer *buffer)<br>
+shm_buffer_get_vc_format(struct wl_shm_buffer *buffer)<br>
 {<br>
        switch (wl_shm_buffer_get_format(buffer)) {<br>
        case WL_SHM_FORMAT_XRGB8888:<br>
@@ -240,7 +240,7 @@ shm_buffer_get_vc_format(struct wl_buffer *buffer)<br>
 }<br>
<br>
 static int<br>
-rpi_resource_update(struct rpi_resource *resource, struct wl_buffer *buffer,<br>
+rpi_resource_update(struct rpi_resource *resource, struct weston_buffer *buffer,<br>
                    pixman_region32_t *region)<br>
 {<br>
        pixman_region32_t write_region;<br>
@@ -259,11 +259,11 @@ rpi_resource_update(struct rpi_resource *resource, struct wl_buffer *buffer,<br>
        if (!buffer)<br>
                return -1;<br>
<br>
-       ifmt = shm_buffer_get_vc_format(buffer);<br>
-       width = wl_shm_buffer_get_width(buffer);<br>
-       height = wl_shm_buffer_get_height(buffer);<br>
-       stride = wl_shm_buffer_get_stride(buffer);<br>
-       pixels = wl_shm_buffer_get_data(buffer);<br>
+       ifmt = shm_buffer_get_vc_format(buffer->shm_buffer);<br>
+       width = wl_shm_buffer_get_width(buffer->shm_buffer);<br>
+       height = wl_shm_buffer_get_height(buffer->shm_buffer);<br>
+       stride = wl_shm_buffer_get_stride(buffer->shm_buffer);<br>
+       pixels = wl_shm_buffer_get_data(buffer->shm_buffer);<br>
<br>
        ret = rpi_resource_realloc(resource, ifmt & ~PREMULT_ALPHA_FLAG,<br>
                                   width, height, stride, height);<br>
@@ -356,7 +356,7 @@ rpir_surface_destroy(struct rpir_surface *surface)<br>
 }<br>
<br>
 static int<br>
-rpir_surface_damage(struct rpir_surface *surface, struct wl_buffer *buffer,<br>
+rpir_surface_damage(struct rpir_surface *surface, struct weston_buffer *buffer,<br>
                    pixman_region32_t *damage)<br>
 {<br>
        pixman_region32_t upload;<br>
@@ -1113,11 +1113,11 @@ rpi_renderer_flush_damage(struct weston_surface *base)<br>
         * having an shm buffer.<br>
         */<br>
        struct rpir_surface *surface = to_rpir_surface(base);<br>
-       struct wl_buffer *buffer = surface->buffer_ref.buffer;<br>
+       struct weston_buffer *buffer = surface->buffer_ref.buffer;<br>
        int ret;<br>
<br>
        assert(buffer);<br>
-       assert(wl_buffer_is_shm(buffer));<br>
+       assert(wl_shm_buffer_get(buffer->resource));<br>
<br>
        ret = rpir_surface_damage(surface, buffer, &base->damage);<br>
        if (ret)<br>
@@ -1128,7 +1128,7 @@ rpi_renderer_flush_damage(struct weston_surface *base)<br>
 }<br>
<br>
 static void<br>
-rpi_renderer_attach(struct weston_surface *base, struct wl_buffer *buffer)<br>
+rpi_renderer_attach(struct weston_surface *base, struct weston_buffer *buffer)<br>
 {<br>
        /* Called every time a client commits an attach. */<br>
        static int warned;<br>
@@ -1138,12 +1138,18 @@ rpi_renderer_attach(struct weston_surface *base, struct wl_buffer *buffer)<br>
        if (!surface)<br>
                return;<br>
<br>
-       if (buffer && !wl_buffer_is_shm(buffer) && !warned) {<br>
+       if (buffer && !wl_shm_buffer_get(buffer->resource) && !warned) {<br>
                weston_log("Error: non-wl_shm buffers not supported.\n");<br>
                warned = 1;<br>
                return;<br>
        }<br>
<br>
+       if (wl_shm_buffer_get(buffer->resource)) {<br>
+               buffer->shm_buffer = wl_shm_buffer_get(buffer->resource);<br>
+               buffer->width = wl_shm_buffer_get_width(buffer->shm_buffer);<br>
+               buffer->height = wl_shm_buffer_get_height(buffer->shm_buffer);<br>
+       }<br>
+<br>
        weston_buffer_reference(&surface->buffer_ref, buffer);<br>
<br>
        /* XXX: need to check if in middle of update<br>
diff --git a/src/screenshooter.c b/src/screenshooter.c<br>
index 1fdfc9a..be2e34f 100644<br>
--- a/src/screenshooter.c<br>
+++ b/src/screenshooter.c<br>
@@ -46,7 +46,7 @@ struct screenshooter {<br>
<br>
 struct screenshooter_frame_listener {<br>
        struct wl_listener listener;<br>
-       struct wl_buffer *buffer;<br>
+       struct weston_buffer *buffer;<br>
        struct wl_resource *resource;<br>
 };<br>
<br>
@@ -140,9 +140,9 @@ screenshooter_frame_notify(struct wl_listener *listener, void *data)<br>
                             0, 0, output->current->width,<br>
                             output->current->height);<br>
<br>
-       stride = wl_shm_buffer_get_stride(l->buffer);<br>
+       stride = wl_shm_buffer_get_stride(l->buffer->shm_buffer);<br>
<br>
-       d = wl_shm_buffer_get_data(l->buffer);<br>
+       d = wl_shm_buffer_get_data(l->buffer->shm_buffer);<br>
        s = pixels + stride * (l->buffer->height - 1);<br>
<br>
        switch (compositor->read_format) {<br>
@@ -178,10 +178,15 @@ screenshooter_shoot(struct wl_client *client,<br>
        struct weston_output *output =<br>
                wl_resource_get_user_data(output_resource);<br>
        struct screenshooter_frame_listener *l;<br>
-       struct wl_buffer *buffer = buffer_resource->data;<br>
+       struct weston_buffer *buffer =<br>
+               weston_buffer_from_resource(buffer_resource);<br>
<br>
-       if (!wl_buffer_is_shm(buffer))<br>
+       if (!wl_shm_buffer_get(buffer->resource))<br>
                return;<br>
+<br>
+       buffer->shm_buffer = wl_shm_buffer_get(buffer->resource);<br>
+       buffer->width = wl_shm_buffer_get_width(buffer->shm_buffer);<br>
+       buffer->height = wl_shm_buffer_get_height(buffer->shm_buffer);<br>
<br>
        if (buffer->width < output->current->width ||<br>
            buffer->height < output->current->height)<br>
<span class="HOEnZb"><font color="#888888">--<br>
1.8.1.4<br>
<br>
</font></span></blockquote></div><br></div>