[Intel-gfx] [PATCH i-g-t 3/4] lib/igt_chamelium: Add support for dumping chamelium frames to a png
Paul Kocialkowski
paul.kocialkowski at linux.intel.com
Mon Jul 3 12:02:11 UTC 2017
This introduces a chamelium_write_frame_to_png function that saves a
Chamelium frame dump to a png file. This should be useful when a frame
comparison with a reference fails.
---
lib/igt_chamelium.c | 32 ++++++++++++++++++++++++++++++++
lib/igt_chamelium.h | 3 +++
2 files changed, 35 insertions(+)
diff --git a/lib/igt_chamelium.c b/lib/igt_chamelium.c
index b9d80b6b..c8719f4d 100644
--- a/lib/igt_chamelium.c
+++ b/lib/igt_chamelium.c
@@ -978,6 +978,38 @@ void chamelium_assert_frame_eq(const struct chamelium *chamelium,
"Chamelium frame dump didn't match reference image\n");
}
+void chamelium_write_frame_to_png(const struct chamelium *chamelium,
+ const struct chamelium_frame_dump *dump,
+ const char *filename)
+{
+ cairo_surface_t *dump_surface;
+ pixman_image_t *image_bgr;
+ pixman_image_t *image_argb;
+ int w = dump->width, h = dump->height;
+ uint32_t *bits_bgr = (uint32_t *) dump->bgr;
+ unsigned char *bits_argb;
+ cairo_status_t status;
+
+ image_bgr = pixman_image_create_bits(
+ PIXMAN_b8g8r8, w, h, bits_bgr,
+ PIXMAN_FORMAT_BPP(PIXMAN_b8g8r8) / 8 * w);
+ image_argb = convert_frame_format(image_bgr, PIXMAN_x8r8g8b8);
+ pixman_image_unref(image_bgr);
+
+ bits_argb = (unsigned char *) pixman_image_get_data(image_argb);
+
+ dump_surface = cairo_image_surface_create_for_data(
+ bits_argb, CAIRO_FORMAT_ARGB32, w, h,
+ PIXMAN_FORMAT_BPP(PIXMAN_x8r8g8b8) / 8 * w);
+
+ status = cairo_surface_write_to_png(dump_surface, filename);
+ cairo_surface_destroy(dump_surface);
+
+ pixman_image_unref(image_argb);
+
+ igt_assert(status == CAIRO_STATUS_SUCCESS);
+}
+
/**
* chamelium_get_frame_limit:
* @chamelium: The Chamelium instance to use
diff --git a/lib/igt_chamelium.h b/lib/igt_chamelium.h
index e51cf4f9..908e03d1 100644
--- a/lib/igt_chamelium.h
+++ b/lib/igt_chamelium.h
@@ -105,6 +105,9 @@ int chamelium_get_frame_limit(struct chamelium *chamelium,
void chamelium_assert_frame_eq(const struct chamelium *chamelium,
const struct chamelium_frame_dump *dump,
struct igt_fb *fb);
+void chamelium_write_frame_to_png(const struct chamelium *chamelium,
+ const struct chamelium_frame_dump *dump,
+ const char *filename);
void chamelium_destroy_frame_dump(struct chamelium_frame_dump *dump);
#endif /* IGT_CHAMELIUM_H */
--
2.13.2
More information about the Intel-gfx
mailing list