summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSøren Sandmann Pedersen <ssp@redhat.com>2013-01-21 14:11:08 -0500
committerSøren Sandmann Pedersen <ssp@redhat.com>2013-01-21 14:11:08 -0500
commit4d0078f2d91db0cdb2f5d262ac7c4920c4523abb (patch)
tree06e3251b17a3fe1feb6daa694a5de33b7564ad28
parent1daa2ccb035c64d235e21f1fef3638e9e0188ea1 (diff)
-rw-r--r--test/pixel-test.c149
1 files changed, 109 insertions, 40 deletions
diff --git a/test/pixel-test.c b/test/pixel-test.c
index 888b0f4c..617c597a 100644
--- a/test/pixel-test.c
+++ b/test/pixel-test.c
@@ -31,77 +31,104 @@ typedef struct pixel_combination_t pixel_combination_t;
struct pixel_combination_t
{
pixman_op_t op;
+
pixman_format_code_t src_format;
+ pixman_format_code_t srca_format;
uint32_t src_pixel;
+ uint32_t srca_pixel;
+
pixman_format_code_t dest_format;
+ pixman_format_code_t desta_format;
uint32_t dest_pixel;
+ uint32_t desta_pixel;
};
+#define MASK(n) ((1 << n) - 1)
+
+/* These macros assumue the format is of type PIXMAN_TYPE_ARGB */
+#define B_SHIFT(format) (0)
+#define G_SHIFT(format) (B_SHIFT (format) + PIXMAN_FORMAT_B (format))
+#define R_SHIFT(format) (G_SHIFT (format) + PIXMAN_FORMAT_G (format))
+#define A_SHIFT(format) (R_SHIFT (format) + PIXMAN_FORMAT_R (format))
+
+#define A_MASK(format) (MASK (PIXMAN_FORMAT_A (format)) << A_SHIFT (format))
+#define R_MASK(format) (MASK (PIXMAN_FORMAT_R (format)) << R_SHIFT (format))
+#define G_MASK(format) (MASK (PIXMAN_FORMAT_G (format)) << G_SHIFT (format))
+#define B_MASK(format) (MASK (PIXMAN_FORMAT_B (format)) << B_SHIFT (format))
+
static const pixel_combination_t regressions[] =
{
{ PIXMAN_OP_OVER,
- PIXMAN_a8r8g8b8, 0x2000bf00,
- PIXMAN_r5g6b5, 0x01e0
+ PIXMAN_a8r8g8b8, PIXMAN_a8, 0x0000b500, 0x07,
+ PIXMAN_r5g6b5, PIXMAN_null, 0x01c0, 0x00,
+ },
+ { PIXMAN_OP_OVER,
+ PIXMAN_a8r8g8b8, PIXMAN_null, 0x0700b600, 0x00,
+ PIXMAN_r5g6b5, PIXMAN_null, 0x01c0, 0x00,
},
{ PIXMAN_OP_OVER,
- PIXMAN_a8r8g8b8, 0x0f000400,
- PIXMAN_r5g6b5, 0x0600
+ PIXMAN_a8r8g8b8, PIXMAN_null, 0x2000bf00, 0x00,
+ PIXMAN_r5g6b5, PIXMAN_null, 0x01e0, 0x00,
},
{ PIXMAN_OP_OVER,
- PIXMAN_a8r8g8b8, 0x10005000,
- PIXMAN_r5g6b5, 0x0140
+ PIXMAN_a8r8g8b8, PIXMAN_null, 0x0f000400, 0x00,
+ PIXMAN_r5g6b5, PIXMAN_null, 0x0600, 0x00,
},
{ PIXMAN_OP_OVER,
- PIXMAN_a8r8g8b8, 0x20c6bf00,
- PIXMAN_r5g6b5, 0xb9ff
+ PIXMAN_a8r8g8b8, PIXMAN_null, 0x10005000, 0x00,
+ PIXMAN_r5g6b5, PIXMAN_null, 0x0140, 0x00,
},
{ PIXMAN_OP_OVER,
- PIXMAN_a8r8g8b8, 0x204ac7ff,
- PIXMAN_r5g6b5, 0xc1ff
+ PIXMAN_a8r8g8b8, PIXMAN_null, 0x20c6bf00, 0x00,
+ PIXMAN_r5g6b5, PIXMAN_null, 0xb9ff, 0x00,
+ },
+ { PIXMAN_OP_OVER,
+ PIXMAN_a8r8g8b8, PIXMAN_null, 0x204ac7ff, 0x00,
+ PIXMAN_r5g6b5, PIXMAN_null, 0xc1ff, 0x00,
},
{ PIXMAN_OP_OVER_REVERSE,
- PIXMAN_r5g6b5, 0xffc3,
- PIXMAN_a8r8g8b8, 0x102d00dd
+ PIXMAN_r5g6b5, PIXMAN_null, 0xffc3, 0x00,
+ PIXMAN_a8r8g8b8, PIXMAN_null, 0x102d00dd, 0x00,
},
{ PIXMAN_OP_OVER_REVERSE,
- PIXMAN_r5g6b5, 0x1f00,
- PIXMAN_a8r8g8b8, 0x1bdf0c89
+ PIXMAN_r5g6b5, PIXMAN_null, 0x1f00, 0x00,
+ PIXMAN_a8r8g8b8, PIXMAN_null, 0x1bdf0c89, 0x00,
},
{ PIXMAN_OP_OVER_REVERSE,
- PIXMAN_r5g6b5, 0xf9d2,
- PIXMAN_a8r8g8b8, 0x1076bcf7
+ PIXMAN_r5g6b5, PIXMAN_null, 0xf9d2, 0x00,
+ PIXMAN_a8r8g8b8, PIXMAN_null, 0x1076bcf7, 0x00,
},
{ PIXMAN_OP_OVER_REVERSE,
- PIXMAN_r5g6b5, 0x00c3,
- PIXMAN_a8r8g8b8, 0x1bfe9ae5
+ PIXMAN_r5g6b5, PIXMAN_null, 0x00c3, 0x00,
+ PIXMAN_a8r8g8b8, PIXMAN_null, 0x1bfe9ae5, 0x00,
},
{ PIXMAN_OP_OVER_REVERSE,
- PIXMAN_r5g6b5, 0x09ff,
- PIXMAN_a8r8g8b8, 0x0b00c16c
+ PIXMAN_r5g6b5, PIXMAN_null, 0x09ff, 0x00,
+ PIXMAN_a8r8g8b8, PIXMAN_null, 0x0b00c16c, 0x00,
},
{ PIXMAN_OP_DISJOINT_ATOP,
- PIXMAN_a2r2g2b2, 0xbc,
- PIXMAN_a8r8g8b8, 0x9efff1ff
+ PIXMAN_a2r2g2b2, PIXMAN_null, 0xbc, 0x00,
+ PIXMAN_a8r8g8b8, PIXMAN_null, 0x9efff1ff, 0x00,
},
{ PIXMAN_OP_DISJOINT_ATOP,
- PIXMAN_a4r4g4b4, 0xae5f,
- PIXMAN_a8r8g8b8, 0xf215b675
+ PIXMAN_a4r4g4b4, PIXMAN_null, 0xae5f, 0x00,
+ PIXMAN_a8r8g8b8, PIXMAN_null, 0xf215b675, 0x00,
},
{ PIXMAN_OP_DISJOINT_ATOP_REVERSE,
- PIXMAN_a8r8g8b8, 0xce007980,
- PIXMAN_a8r8g8b8, 0x80ffe4ad
+ PIXMAN_a8r8g8b8, PIXMAN_null, 0xce007980, 0x00,
+ PIXMAN_a8r8g8b8, PIXMAN_null, 0x80ffe4ad, 0x00,
},
{ PIXMAN_OP_DISJOINT_XOR,
- PIXMAN_a8r8g8b8, 0xb8b07bea,
- PIXMAN_a4r4g4b4, 0x939c
+ PIXMAN_a8r8g8b8, PIXMAN_null, 0xb8b07bea, 0x00,
+ PIXMAN_a4r4g4b4, PIXMAN_null, 0x939c, 0x00,
},
{ PIXMAN_OP_CONJOINT_ATOP_REVERSE,
- PIXMAN_r5g6b5, 0x0063,
- PIXMAN_a8r8g8b8, 0x10bb1ed7,
+ PIXMAN_r5g6b5, PIXMAN_null, 0x0063, 0x00,
+ PIXMAN_a8r8g8b8, PIXMAN_null, 0x10bb1ed7, 0x00,
},
{ PIXMAN_OP_OVER,
- PIXMAN_a8r8g8b8, 0x10005000,
- PIXMAN_r5g6b5, 0x0140,
+ PIXMAN_a8r8g8b8, PIXMAN_null, 0x10005000, 0x00,
+ PIXMAN_r5g6b5, PIXMAN_null, 0x0140, 0x00,
}
};
@@ -166,6 +193,46 @@ access (pixman_image_t *image, int x, int y)
return result;
}
+static pixman_image_t *
+create_image (int size, pixman_format_code_t format, pixman_format_code_t aformat,
+ uint32_t pixel, uint32_t apixel)
+{
+ pixman_image_t *image;
+
+ image = pixman_image_create_bits (format, size, size, NULL, -1);
+
+ if (aformat == PIXMAN_null)
+ {
+ fill (image, pixel);
+ }
+ else if (PIXMAN_FORMAT_A (aformat) == PIXMAN_FORMAT_A (format))
+ {
+ uint32_t s;
+
+ s = pixel & ~A_MASK (format);
+ s |= (apixel & A_MASK (aformat)) << (A_SHIFT (format) - A_SHIFT (aformat));
+
+ fill (image, s);
+ }
+ else
+ {
+ pixman_image_t *alpha;
+
+ fill (image, pixel);
+
+ alpha = pixman_image_create_bits (
+ aformat, size, size, NULL, -1);
+
+ fill (alpha, apixel);
+
+ pixman_image_set_alpha_map (image, alpha, 0, 0);
+
+ pixman_image_unref (alpha);
+ }
+
+ return image;
+}
+
static pixman_bool_t
verify (int test_no, const pixel_combination_t *combination, int size)
{
@@ -186,14 +253,13 @@ verify (int test_no, const pixel_combination_t *combination, int size)
&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);
-
+ src = create_image (size,
+ combination->src_format, combination->srca_format,
+ combination->src_pixel, combination->srca_pixel);
+ dest = create_image (size,
+ combination->dest_format, combination->desta_format,
+ combination->dest_pixel, combination->desta_pixel);
+
pixman_image_composite32 (
combination->op, src, NULL, dest, 0, 0, 0, 0, 0, 0, size, size);
@@ -204,7 +270,9 @@ verify (int test_no, const pixel_combination_t *combination, int size)
uint32_t computed = access (dest, i, j);
int32_t a, r, g, b;
+#if 0
if (!pixel_checker_check (&dest_checker, computed, &reference_color))
+#endif
{
printf ("----------- Test %d failed ----------\n", test_no);
@@ -266,6 +334,7 @@ main (int argc, char **argv)
if (!verify (i, combination, j))
{
result = 1;
+ return 1;
goto next;
}
}