Example #1
0
static void
get_color (pixel_checker_t *checker,
	   pixman_image_t *image,
	   int x, int y,
	   color_t *color,
	   uint32_t *pixel)
{
    if (!access (image, x, y, pixel))
    {
	color->a = 0.0;
	color->r = 0.0;
	color->g = 0.0;
	color->b = 0.0;
    }
    else
    {
	pixel_checker_convert_pixel_to_color (
	    checker, *pixel, color);
    }
}
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;
}