Re: [PATCH i-g-t 4/4] kms_plane_scaling: Find the image regardless how the test is run

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




> -----Original Message-----
> From: Tvrtko Ursulin [mailto:tvrtko.ursulin@xxxxxxxxxxxxxxx]
> Sent: Tuesday, May 05, 2015 2:53 AM
> To: Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
> Cc: Ursulin, Tvrtko; Konduru, Chandra; Wood, Thomas
> Subject: [PATCH i-g-t 4/4] kms_plane_scaling: Find the image regardless how the
> test is run
> 
> From: Tvrtko Ursulin <tvrtko.ursulin@xxxxxxxxx>
> 
> As it stands running the test like "sudo tests/kms_plane_scaling"
> does not work.
> 
> Fix it by using the same method igt_paint_image uses.
As image size is required in other tests too, in recent patch
I added igt_get_image_size() which can be used here
instead duplication.

> 
> v2: Export Cairo read callback instead of duplicating it. (Thomas Wood)
> 
> Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@xxxxxxxxx>
> Cc: chandra konduru <chandra.konduru@xxxxxxxxx>
> Cc: Thomas Wood <thomas.wood@xxxxxxxxx>
> ---
>  lib/igt_fb.c              | 17 ++++++++++++++---
>  lib/igt_fb.h              |  2 ++
>  tests/kms_plane_scaling.c |  7 ++++++-
>  3 files changed, 22 insertions(+), 4 deletions(-)
> 
> diff --git a/lib/igt_fb.c b/lib/igt_fb.c index cc4b8ee..2416e76 100644
> --- a/lib/igt_fb.c
> +++ b/lib/igt_fb.c
> @@ -338,8 +338,18 @@ void igt_paint_test_pattern(cairo_t *cr, int width, int
> height)
>  	igt_assert(!cairo_status(cr));
>  }
> 
> -static cairo_status_t
> -stdio_read_func(void *closure, unsigned char* data, unsigned int size)
> +/**
> + * igt_cairo_read_func:
> + * @closure: callback closure parameter
> + * @data: callback data parameter
> + * @size: callback size parameter
> + *
> + * Read callback for cairo_image_surface_create_from_png_stream to be
> +used
> + * in conjuction with igt_fopen_data in order to open data files from
> +IGT
> + * standard locations.
> + */
> +cairo_status_t
> +igt_cairo_read_func(void *closure, unsigned char* data, unsigned int
> +size)
>  {
>  	if (fread(data, 1, size, (FILE*)closure) != size)
>  		return CAIRO_STATUS_READ_ERROR;
> @@ -369,7 +379,8 @@ void igt_paint_image(cairo_t *cr, const char *filename,
> 
>  	f = igt_fopen_data(filename);
> 
> -	image =
> cairo_image_surface_create_from_png_stream(&stdio_read_func, f);
> +	image =
> cairo_image_surface_create_from_png_stream(&igt_cairo_read_func,
> +							   f);
>  	igt_assert(cairo_surface_status(image) == CAIRO_STATUS_SUCCESS);
> 
>  	img_width = cairo_image_surface_get_width(image);
> diff --git a/lib/igt_fb.h b/lib/igt_fb.h index a07acd2..2da5f0c 100644
> --- a/lib/igt_fb.h
> +++ b/lib/igt_fb.h
> @@ -98,6 +98,8 @@ void igt_write_fb_to_png(int fd, struct igt_fb *fb, const
> char *filename);  int igt_cairo_printf_line(cairo_t *cr, enum igt_text_align align,
>  			       double yspacing, const char *fmt, ...)
>  			       __attribute__((format (printf, 4, 5)));
> +cairo_status_t
> +igt_cairo_read_func(void *closure, unsigned char* data, unsigned int
> +size);
> 
>  /* helpers to handle drm fourcc codes */  uint32_t
> igt_bpp_depth_to_drm_format(int bpp, int depth); diff --git
> a/tests/kms_plane_scaling.c b/tests/kms_plane_scaling.c index
> 00db5cb..272f759 100644
> --- a/tests/kms_plane_scaling.c
> +++ b/tests/kms_plane_scaling.c
> @@ -210,6 +210,7 @@ static void test_plane_scaling(data_t *d)
>  	enum pipe pipe;
>  	int valid_tests = 0;
>  	int primary_plane_scaling = 0; /* For now */
> +	FILE* f;
> 
>  	igt_require(d->display.has_universal_planes);
>  	igt_require(d->num_scalers);
> @@ -223,11 +224,15 @@ static void test_plane_scaling(data_t *d)
>  		mode = igt_output_get_mode(output);
> 
>  		/* allocate fb2 with image size */
> -		image = cairo_image_surface_create_from_png(FILE_NAME);
> +
> +		f = igt_fopen_data(FILE_NAME);
> +		image = cairo_image_surface_create_from_png_stream(
> +						&igt_cairo_read_func, f);
>  		igt_assert(cairo_surface_status(image) ==
> CAIRO_STATUS_SUCCESS);
>  		d->image_w = cairo_image_surface_get_width(image);
>  		d->image_h = cairo_image_surface_get_height(image);
>  		cairo_surface_destroy(image);
> +		fclose(f);

Above can be replaced with
	igt_get_image_size(FILE_NAME, &d->image_w, &d->image_h);

> 
>  		d->fb_id2 = igt_create_fb(d->drm_fd,
>  				d->image_w, d->image_h,
> --
> 2.3.5

_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/intel-gfx





[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux