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 <pekka.paalanen@collabora.com>
dev
Pekka Paalanen 2 years ago committed by Pekka Paalanen
parent 791a6be216
commit 94589497a1
  1. 28
      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_surface_t *cairo_surface;
cairo_status_t status; 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(ih.data, fmt,
ih.width, ih.height,
cairo_surface = cairo_image_surface_create_for_data( ih.stride_bytes);
(void *)pixman_image_get_data(image),
fmt,
pixman_image_get_width(image),
pixman_image_get_height(image),
pixman_image_get_stride(image));
status = cairo_surface_write_to_png(cairo_surface, fname); status = cairo_surface_write_to_png(cairo_surface, fname);
if (status != CAIRO_STATUS_SUCCESS) { if (status != CAIRO_STATUS_SUCCESS) {
@ -1492,21 +1488,17 @@ static pixman_image_t *
image_convert_to_a8r8g8b8(pixman_image_t *image) image_convert_to_a8r8g8b8(pixman_image_t *image)
{ {
pixman_image_t *ret; pixman_image_t *ret;
int width; struct image_header ih = image_header_from(image);
int height;
if (pixman_image_get_format(image) == PIXMAN_a8r8g8b8) if (ih.pixman_format == PIXMAN_a8r8g8b8)
return pixman_image_ref(image); return pixman_image_ref(image);
width = pixman_image_get_width(image); ret = pixman_image_create_bits_no_clear(PIXMAN_a8r8g8b8,
height = pixman_image_get_height(image); ih.width, ih.height, NULL, 0);
ret = pixman_image_create_bits_no_clear(PIXMAN_a8r8g8b8, width, height,
NULL, 0);
assert(ret); assert(ret);
pixman_image_composite32(PIXMAN_OP_SRC, image, NULL, 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; return ret;
} }

Loading…
Cancel
Save