+ sys_buf_t *buf = new0(sys_buf_t);
+ buf->pool = wl_resource_get_user_data(pool);
+ buf->mem = buf->pool->mem + offset;
+
+ printf("pool_create_buffer - %dx%d %p+%d : %d,%d,%d\n",
+ width, height, buf->pool->mem, offset, id, stride, format);
+
+ if (offset > buf->pool->size || offset < 0)
+ {
+ printf("\n\nerror\n\n");
+ wl_resource_post_error(pool, WL_SHM_ERROR_INVALID_STRIDE,
+ "offset is too big or negative");
+ return;
+ }
+
+ cairo_format_t cf =
+ format == WL_SHM_FORMAT_ARGB8888 ? CAIRO_FORMAT_ARGB32 :
+ format == WL_SHM_FORMAT_XRGB8888 ? CAIRO_FORMAT_RGB24 : CAIRO_FORMAT_INVALID;
+
+ buf->surface = cairo_image_surface_create_for_data(buf->mem, cf, width, height, stride);
+
+ struct wl_resource *res = wl_resource_create(cli, &wl_buffer_interface,
+ wl_resource_get_version(pool), id);
+ wl_resource_set_implementation(res, &buffer_iface, buf, NULL);