From 94589497a1d1395e663b64092c96f8e342d3e5ea Mon Sep 17 00:00:00 2001 From: Pekka Paalanen Date: Mon, 13 Jun 2022 11:58:04 +0300 Subject: [PATCH] tests/client-helper: use image_header_from() more These are the last places in weston-test-client-helper.c where using image_header_from() will reduce the code line count and simplify the code a little. No change in behaviour. Signed-off-by: Pekka Paalanen --- tests/weston-test-client-helper.c | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/tests/weston-test-client-helper.c b/tests/weston-test-client-helper.c index 22b3c572..89713e17 100644 --- a/tests/weston-test-client-helper.c +++ b/tests/weston-test-client-helper.c @@ -1464,16 +1464,12 @@ write_image_as_png(pixman_image_t *image, const char *fname) { cairo_surface_t *cairo_surface; cairo_status_t status; - cairo_format_t fmt; + struct image_header ih = image_header_from(image); + cairo_format_t fmt = format_pixman2cairo(ih.pixman_format); - fmt = format_pixman2cairo(pixman_image_get_format(image)); - - cairo_surface = cairo_image_surface_create_for_data( - (void *)pixman_image_get_data(image), - fmt, - pixman_image_get_width(image), - pixman_image_get_height(image), - pixman_image_get_stride(image)); + cairo_surface = cairo_image_surface_create_for_data(ih.data, fmt, + ih.width, ih.height, + ih.stride_bytes); status = cairo_surface_write_to_png(cairo_surface, fname); if (status != CAIRO_STATUS_SUCCESS) { @@ -1492,21 +1488,17 @@ static pixman_image_t * image_convert_to_a8r8g8b8(pixman_image_t *image) { pixman_image_t *ret; - int width; - int height; + struct image_header ih = image_header_from(image); - if (pixman_image_get_format(image) == PIXMAN_a8r8g8b8) + if (ih.pixman_format == PIXMAN_a8r8g8b8) return pixman_image_ref(image); - width = pixman_image_get_width(image); - height = pixman_image_get_height(image); - - ret = pixman_image_create_bits_no_clear(PIXMAN_a8r8g8b8, width, height, - NULL, 0); + ret = pixman_image_create_bits_no_clear(PIXMAN_a8r8g8b8, + ih.width, ih.height, NULL, 0); assert(ret); pixman_image_composite32(PIXMAN_OP_SRC, image, NULL, ret, - 0, 0, 0, 0, 0, 0, width, height); + 0, 0, 0, 0, 0, 0, ih.width, ih.height); return ret; }