From: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
To: Intel-gfx@lists.freedesktop.org
Cc: Thomas Wood <thomas.wood@intel.com>
Subject: [PATCH i-g-t 4/4] kms_plane_scaling: Find the image regardless how the test is run
Date: Tue, 5 May 2015 10:53:23 +0100 [thread overview]
Message-ID: <1430819603-492-4-git-send-email-tvrtko.ursulin@linux.intel.com> (raw)
In-Reply-To: <1430819603-492-1-git-send-email-tvrtko.ursulin@linux.intel.com>
From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
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.
v2: Export Cairo read callback instead of duplicating it. (Thomas Wood)
Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Cc: chandra konduru <chandra.konduru@intel.com>
Cc: Thomas Wood <thomas.wood@intel.com>
---
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);
d->fb_id2 = igt_create_fb(d->drm_fd,
d->image_w, d->image_h,
--
2.3.5
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2015-05-05 9:53 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-05 9:53 [PATCH v2 i-g-t 1/4] igt_kms: Avoid NULL ptr deref when commiting disabled planes Tvrtko Ursulin
2015-05-05 9:53 ` [PATCH i-g-t 2/4] igt_kms: Merge condition in igt_plane_set_fb Tvrtko Ursulin
2015-05-06 20:56 ` Konduru, Chandra
2015-05-07 9:06 ` Tvrtko Ursulin
2015-05-05 9:53 ` [PATCH i-g-t 3/4] igt_kms: Do not reset plane position on assigning a fb Tvrtko Ursulin
2015-05-06 19:02 ` Konduru, Chandra
2015-05-07 9:15 ` Tvrtko Ursulin
2015-05-08 0:03 ` Konduru, Chandra
2015-05-08 8:36 ` Tvrtko Ursulin
2015-05-08 17:57 ` Konduru, Chandra
2015-05-05 9:53 ` Tvrtko Ursulin [this message]
2015-05-05 17:22 ` [PATCH i-g-t 4/4] kms_plane_scaling: Find the image regardless how the test is run Konduru, Chandra
2015-05-06 9:29 ` Tvrtko Ursulin
2015-05-06 18:17 ` Konduru, Chandra
2015-05-07 8:54 ` Tvrtko Ursulin
2015-05-06 20:47 ` [PATCH v2 i-g-t 1/4] igt_kms: Avoid NULL ptr deref when commiting disabled planes Konduru, Chandra
2015-05-07 9:00 ` Tvrtko Ursulin
2015-05-07 23:45 ` Konduru, Chandra
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1430819603-492-4-git-send-email-tvrtko.ursulin@linux.intel.com \
--to=tvrtko.ursulin@linux.intel.com \
--cc=Intel-gfx@lists.freedesktop.org \
--cc=thomas.wood@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox