From 79f4cfedbf8f4249291c0915d040d79af97d1389 Mon Sep 17 00:00:00 2001 From: Damien Lespiau Date: Fri, 6 Sep 2013 18:22:53 +0100 Subject: [PATCH] lib: Add a helper to write a png from a struct kmstest_fb Signed-off-by: Damien Lespiau --- lib/drmtest.c | 11 +++++++++++ lib/drmtest.h | 1 + 2 files changed, 12 insertions(+) diff --git a/lib/drmtest.c b/lib/drmtest.c index cf442a00..5ff9b5f5 100644 --- a/lib/drmtest.c +++ b/lib/drmtest.c @@ -1648,6 +1648,17 @@ static cairo_t *create_cairo_ctx(int fd, struct kmstest_fb *fb) return cr; } +void kmstest_write_fb(int fd, struct kmstest_fb *fb, const char *filename) +{ + cairo_surface_t *surface; + cairo_status_t status; + + surface = create_image_surface(fd, fb); + status = cairo_surface_write_to_png(surface, filename); + assert(status == CAIRO_STATUS_SUCCESS); + cairo_surface_destroy(surface); +} + cairo_t *kmstest_get_cairo_ctx(int fd, struct kmstest_fb *fb) { diff --git a/lib/drmtest.h b/lib/drmtest.h index b0b353f0..296c5008 100644 --- a/lib/drmtest.h +++ b/lib/drmtest.h @@ -357,6 +357,7 @@ void kmstest_paint_color_gradient(cairo_t *cr, int x, int y, int w, int h, void kmstest_paint_test_pattern(cairo_t *cr, int width, int height); void kmstest_paint_image(cairo_t *cr, const char *filename, int dst_x, int dst_y, int dst_width, int dst_height); +void kmstest_write_fb(int fd, struct kmstest_fb *fb, const char *filename); void kmstest_dump_mode(drmModeModeInfo *mode); int kmstest_get_pipe_from_crtc_id(int fd, int crtc_id); const char *kmstest_format_str(uint32_t drm_format);