summaryrefslogtreecommitdiff
path: root/src/noop-renderer.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/noop-renderer.c')
-rw-r--r--src/noop-renderer.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/noop-renderer.c b/src/noop-renderer.c
index ad750b5a..72332eb7 100644
--- a/src/noop-renderer.c
+++ b/src/noop-renderer.c
@@ -49,6 +49,39 @@ noop_renderer_flush_damage(struct weston_surface *surface)
static void
noop_renderer_attach(struct weston_surface *es, struct weston_buffer *buffer)
{
+ struct wl_shm_buffer *shm_buffer;
+ uint8_t *data;
+ uint32_t size, i, width, height, stride;
+ volatile unsigned char unused = 0; /* volatile so it's not optimized out */
+
+ if (!buffer)
+ return;
+
+ shm_buffer = wl_shm_buffer_get(buffer->resource);
+
+ if (!shm_buffer) {
+ weston_log("No-op renderer supports only SHM buffers\n");
+ return;
+ }
+
+ data = wl_shm_buffer_get_data(shm_buffer);
+ stride = wl_shm_buffer_get_stride(shm_buffer);
+ width = wl_shm_buffer_get_width(shm_buffer);
+ height = wl_shm_buffer_get_height(shm_buffer);
+ size = stride * height;
+
+ /* Access the buffer data to make sure the buffer's client gets killed
+ * if the buffer size is invalid. This makes the bad_buffer test pass.
+ * This can be removed if we start reading the buffer contents
+ * somewhere else, e.g. in repaint_output(). */
+ wl_shm_buffer_begin_access(shm_buffer);
+ for (i = 0; i < size; i++)
+ unused ^= data[i];
+ wl_shm_buffer_end_access(shm_buffer);
+
+ buffer->shm_buffer = shm_buffer;
+ buffer->width = width;
+ buffer->height = height;
}
static void