On Wed, 2017-07-05 at 11:04 +0300, Paul Kocialkowski wrote: > 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. > > Signed-off-by: Paul Kocialkowski <paul.kocialkowski@xxxxxxxxxxxxxxx> > --- > lib/igt_chamelium.c | 40 ++++++++++++++++++++++++++++++++++++++++ > lib/igt_chamelium.h | 3 +++ > 2 files changed, 43 insertions(+) > > diff --git a/lib/igt_chamelium.c b/lib/igt_chamelium.c > index b9d80b6b..ef51ef68 100644 > --- a/lib/igt_chamelium.c > +++ b/lib/igt_chamelium.c > @@ -979,6 +979,46 @@ void chamelium_assert_frame_eq(const struct > chamelium *chamelium, > } > > /** > + * chamelium_write_frame_to_png: > + * @chamelium: The Chamelium instance to use > + * @dump: The chamelium frame dump to save > + * @filename: The file name to dump the frame to > + * > + * Writes a chamelium frame dump into a png image stored at > @filename. > + */ > +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); Use igt_assert_eq() > +} > + > +/** > * chamelium_get_frame_limit: > * @chamelium: The Chamelium instance to use > * @port: The port to check the frame limit on > 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 */ -- Cheers, Lyude _______________________________________________ Intel-gfx mailing list Intel-gfx@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/intel-gfx