Re: [PATCH i-g-t 4/5] lib/igt_fb: Check for stride before creating cairo surface

Chris Wilson
2018-09-06T08:58:57Z

Quoting Deepak Rawat (2018-09-06 01:03:49)
> Cairo surface creation will fail if stride of provided buffer is not
> same as expected by cairo. This fails for vmwgfx odd length framebuffer
> as in vmwgfx stride is always width * bpp.
>
> Signed-off-by: Deepak Rawat <drawat@vmware.com>
> ---
> lib/igt_fb.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/lib/igt_fb.c b/lib/igt_fb.c
> index ba995a1a..2724e323 100644
> --- a/lib/igt_fb.c
> +++ b/lib/igt_fb.c
> @@ -1349,6 +1349,9 @@ static void create_cairo_surface__gtt(int fd, struct igt_fb *fb)
> ptr = gem_mmap__gtt(fd, fb->gem_handle, fb->size,
> PROT_READ | PROT_WRITE);
>
> + igt_require(fb->stride == cairo_format_stride_for_width(
> + drm_format_to_cairo(fb->drm_format), fb->width));
> +
> fb->cairo_surface =
> cairo_image_surface_create_for_data(ptr,
> drm_format_to_cairo(fb->drm_format),

Is there not a
igt_require_f/igt_assert_f(cairo_surface_status(fb->cairo_surface) == CAIRO_STATUS_SUCCESS,
"Unable to create a cairo surface: %s", cairo_status_to_string(cairo_surface_status(fb->cairo_surface)));
here?
-Chris