|
|
@ -121,6 +121,19 @@ static void buffer_handle_resource_destroy(struct wl_resource *buffer_resource)
|
|
|
|
linux_dmabuf_buffer_destroy(buffer);
|
|
|
|
linux_dmabuf_buffer_destroy(buffer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static bool check_import_dmabuf(struct wlr_dmabuf_buffer *buffer) {
|
|
|
|
|
|
|
|
struct wlr_texture *texture =
|
|
|
|
|
|
|
|
wlr_texture_from_dmabuf(buffer->renderer, &buffer->attributes);
|
|
|
|
|
|
|
|
if (texture == NULL) {
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// We can import the image, good. No need to keep it since wlr_surface will
|
|
|
|
|
|
|
|
// import it again on commit.
|
|
|
|
|
|
|
|
wlr_texture_destroy(texture);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void params_create_common(struct wl_client *client,
|
|
|
|
static void params_create_common(struct wl_client *client,
|
|
|
|
struct wl_resource *params_resource, uint32_t buffer_id, int32_t width,
|
|
|
|
struct wl_resource *params_resource, uint32_t buffer_id, int32_t width,
|
|
|
|
int32_t height, uint32_t format, uint32_t flags) {
|
|
|
|
int32_t height, uint32_t format, uint32_t flags) {
|
|
|
@ -194,7 +207,7 @@ static void params_create_common(struct wl_client *client,
|
|
|
|
// Skip checks if kernel does no support seek on buffer
|
|
|
|
// Skip checks if kernel does no support seek on buffer
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (buffer->attributes.offset[i] >= size) {
|
|
|
|
if (buffer->attributes.offset[i] > size) {
|
|
|
|
wl_resource_post_error(params_resource,
|
|
|
|
wl_resource_post_error(params_resource,
|
|
|
|
ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_OUT_OF_BOUNDS,
|
|
|
|
ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_OUT_OF_BOUNDS,
|
|
|
|
"invalid offset %i for plane %d",
|
|
|
|
"invalid offset %i for plane %d",
|
|
|
@ -202,7 +215,8 @@ static void params_create_common(struct wl_client *client,
|
|
|
|
goto err_out;
|
|
|
|
goto err_out;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (buffer->attributes.offset[i] + buffer->attributes.stride[i] > size) {
|
|
|
|
if (buffer->attributes.offset[i] + buffer->attributes.stride[i] > size ||
|
|
|
|
|
|
|
|
buffer->attributes.stride[i] == 0) {
|
|
|
|
wl_resource_post_error(params_resource,
|
|
|
|
wl_resource_post_error(params_resource,
|
|
|
|
ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_OUT_OF_BOUNDS,
|
|
|
|
ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_OUT_OF_BOUNDS,
|
|
|
|
"invalid stride %i for plane %d",
|
|
|
|
"invalid stride %i for plane %d",
|
|
|
@ -212,7 +226,7 @@ static void params_create_common(struct wl_client *client,
|
|
|
|
|
|
|
|
|
|
|
|
// planes > 0 might be subsampled according to fourcc format
|
|
|
|
// planes > 0 might be subsampled according to fourcc format
|
|
|
|
if (i == 0 && buffer->attributes.offset[i] +
|
|
|
|
if (i == 0 && buffer->attributes.offset[i] +
|
|
|
|
buffer->attributes.stride[i] * height >= size) {
|
|
|
|
buffer->attributes.stride[i] * height > size) {
|
|
|
|
wl_resource_post_error(params_resource,
|
|
|
|
wl_resource_post_error(params_resource,
|
|
|
|
ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_OUT_OF_BOUNDS,
|
|
|
|
ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_OUT_OF_BOUNDS,
|
|
|
|
"invalid buffer stride or height for plane %d", i);
|
|
|
|
"invalid buffer stride or height for plane %d", i);
|
|
|
@ -229,8 +243,7 @@ static void params_create_common(struct wl_client *client,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Check if dmabuf is usable */
|
|
|
|
/* Check if dmabuf is usable */
|
|
|
|
if (!wlr_renderer_check_import_dmabuf(buffer->renderer,
|
|
|
|
if (!check_import_dmabuf(buffer)) {
|
|
|
|
&buffer->attributes)) {
|
|
|
|
|
|
|
|
goto err_failed;
|
|
|
|
goto err_failed;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|