static pixman_bool_t verify (int test_no, pixman_op_t op, pixman_image_t *source, pixman_image_t *mask, pixman_image_t *dest, pixman_image_t *orig_dest, int x, int y, int width, int height, pixman_bool_t component_alpha) { pixel_checker_t dest_checker, src_checker, mask_checker; int i, j; pixel_checker_init (&src_checker, source->bits.format); pixel_checker_init (&dest_checker, dest->bits.format); pixel_checker_init (&mask_checker, mask->bits.format); assert (dest->bits.format == orig_dest->bits.format); for (j = y; j < y + height; ++j) { for (i = x; i < x + width; ++i) { color_t src_color, mask_color, orig_dest_color, result; uint32_t dest_pixel, orig_dest_pixel, src_pixel, mask_pixel; access (dest, i, j, &dest_pixel); get_color (&src_checker, source, i - x, j - y, &src_color, &src_pixel); get_color (&mask_checker, mask, i - x, j - y, &mask_color, &mask_pixel); get_color (&dest_checker, orig_dest, i, j, &orig_dest_color, &orig_dest_pixel); do_composite (op, &src_color, &mask_color, &orig_dest_color, &result, component_alpha); if (!pixel_checker_check (&dest_checker, dest_pixel, &result)) { int a, r, g, b; printf ("--------- Test 0x%x failed ---------\n", test_no); printf (" operator: %s (%s alpha)\n", operator_name (op), component_alpha? "component" : "unified"); printf (" dest_x, dest_y: %d %d\n", x, y); printf (" width, height: %d %d\n", width, height); printf (" source: format: %-14s size: %2d x %2d\n", format_name (source->bits.format), source->bits.width, source->bits.height); printf (" mask: format: %-14s size: %2d x %2d\n", format_name (mask->bits.format), mask->bits.width, mask->bits.height); printf (" dest: format: %-14s size: %2d x %2d\n", format_name (dest->bits.format), dest->bits.width, dest->bits.height); printf (" -- Failed pixel: (%d, %d) --\n", i, j); printf (" source ARGB: %f %f %f %f (pixel: %x)\n", src_color.a, src_color.r, src_color.g, src_color.b, src_pixel); printf (" mask ARGB: %f %f %f %f (pixel: %x)\n", mask_color.a, mask_color.r, mask_color.g, mask_color.b, mask_pixel); printf (" dest ARGB: %f %f %f %f (pixel: %x)\n", orig_dest_color.a, orig_dest_color.r, orig_dest_color.g, orig_dest_color.b, orig_dest_pixel); printf (" expected ARGB: %f %f %f %f\n", result.a, result.r, result.g, result.b); pixel_checker_get_min (&dest_checker, &result, &a, &r, &g, &b); printf (" min acceptable: %8d %8d %8d %8d\n", a, r, g, b); pixel_checker_split_pixel (&dest_checker, dest_pixel, &a, &r, &g, &b); printf (" got: %8d %8d %8d %8d (pixel: %x)\n", a, r, g, b, dest_pixel); pixel_checker_get_max (&dest_checker, &result, &a, &r, &g, &b); printf (" max acceptable: %8d %8d %8d %8d\n", a, r, g, b); printf ("\n"); printf (" { %s,\n", operator_name (op)); printf (" PIXMAN_%s,\t0x%x,\n", format_name (source->bits.format), src_pixel); printf (" PIXMAN_%s,\t0x%x,\n", format_name (mask->bits.format), mask_pixel); printf (" PIXMAN_%s,\t0x%x\n", format_name (dest->bits.format), orig_dest_pixel); printf (" },\n"); return FALSE; } } } return TRUE; }
static pixman_bool_t verify (int test_no, const pixel_combination_t *combination, int size) { pixman_image_t *src, *dest; pixel_checker_t src_checker, dest_checker; color_t source_color, dest_color, reference_color; pixman_bool_t result = TRUE; int i, j; /* Compute reference color */ pixel_checker_init (&src_checker, combination->src_format); pixel_checker_init (&dest_checker, combination->dest_format); pixel_checker_convert_pixel_to_color ( &src_checker, combination->src_pixel, &source_color); pixel_checker_convert_pixel_to_color ( &dest_checker, combination->dest_pixel, &dest_color); do_composite (combination->op, &source_color, NULL, &dest_color, &reference_color, FALSE); src = pixman_image_create_bits ( combination->src_format, size, size, NULL, -1); dest = pixman_image_create_bits ( combination->dest_format, size, size, NULL, -1); fill (src, combination->src_pixel); fill (dest, combination->dest_pixel); pixman_image_composite32 ( combination->op, src, NULL, dest, 0, 0, 0, 0, 0, 0, size, size); for (j = 0; j < size; ++j) { for (i = 0; i < size; ++i) { uint32_t computed = access (dest, i, j); int32_t a, r, g, b; if (!pixel_checker_check (&dest_checker, computed, &reference_color)) { printf ("----------- Test %d failed ----------\n", test_no); printf (" operator: %s\n", operator_name (combination->op)); printf (" src format: %s\n", format_name (combination->src_format)); printf (" dest format: %s\n", format_name (combination->dest_format)); printf (" - source ARGB: %f %f %f %f (pixel: %8x)\n", source_color.a, source_color.r, source_color.g, source_color.b, combination->src_pixel); pixel_checker_split_pixel (&src_checker, combination->src_pixel, &a, &r, &g, &b); printf (" %8d %8d %8d %8d\n", a, r, g, b); printf (" - dest ARGB: %f %f %f %f (pixel: %8x)\n", dest_color.a, dest_color.r, dest_color.g, dest_color.b, combination->dest_pixel); pixel_checker_split_pixel (&dest_checker, combination->dest_pixel, &a, &r, &g, &b); printf (" %8d %8d %8d %8d\n", a, r, g, b); pixel_checker_split_pixel (&dest_checker, computed, &a, &r, &g, &b); printf (" - expected ARGB: %f %f %f %f\n", reference_color.a, reference_color.r, reference_color.g, reference_color.b); pixel_checker_get_min (&dest_checker, &reference_color, &a, &r, &g, &b); printf (" min acceptable: %8d %8d %8d %8d\n", a, r, g, b); pixel_checker_split_pixel (&dest_checker, computed, &a, &r, &g, &b); printf (" got: %8d %8d %8d %8d (pixel: %8x)\n", a, r, g, b, computed); pixel_checker_get_max (&dest_checker, &reference_color, &a, &r, &g, &b); printf (" max acceptable: %8d %8d %8d %8d\n", a, r, g, b); result = FALSE; goto done; } } } done: pixman_image_unref (src); pixman_image_unref (dest); return result; }