Merge pull request #1020 from emersion/remove-check-dmabuf

render: remove wlr_renderer_check_import_dmabuf
This commit is contained in:
emersion 2018-05-31 21:49:57 +01:00 committed by GitHub
commit 6b7a55aa3d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 36 additions and 66 deletions

View file

@ -121,6 +121,19 @@ static void buffer_handle_resource_destroy(struct wl_resource *buffer_resource)
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,
struct wl_resource *params_resource, uint32_t buffer_id, int32_t width,
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
continue;
}
if (buffer->attributes.offset[i] >= size) {
if (buffer->attributes.offset[i] > size) {
wl_resource_post_error(params_resource,
ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_OUT_OF_BOUNDS,
"invalid offset %i for plane %d",
@ -202,7 +215,8 @@ static void params_create_common(struct wl_client *client,
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,
ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_OUT_OF_BOUNDS,
"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
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,
ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_OUT_OF_BOUNDS,
"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 */
if (!wlr_renderer_check_import_dmabuf(buffer->renderer,
&buffer->attributes)) {
if (!check_import_dmabuf(buffer)) {
goto err_failed;
}