7
static const pixman_format_code_t formats[] =
19
static const pixman_op_t ops[] =
26
#define TRANSFORM(v00, v01, v10, v11) \
27
{ { { v00, v01, WIDTH * pixman_fixed_1 / 2 }, \
28
{ v10, v11, HEIGHT * pixman_fixed_1 / 2 }, \
29
{ 0, 0, pixman_fixed_1 } } }
31
#define F1 pixman_fixed_1
33
static const pixman_transform_t transforms[] =
35
TRANSFORM (0, -1, 1, 0), /* wrong 90 degree rotation */
36
TRANSFORM (0, 1, -1, 0), /* wrong 270 degree rotation */
37
TRANSFORM (1, 0, 0, 1), /* wrong identity */
38
TRANSFORM (-1, 0, 0, -1), /* wrong 180 degree rotation */
39
TRANSFORM (0, -F1, F1, 0), /* correct 90 degree rotation */
40
TRANSFORM (0, F1, -F1, 0), /* correct 270 degree rotation */
41
TRANSFORM (F1, 0, 0, F1), /* correct identity */
42
TRANSFORM (-F1, 0, 0, -F1), /* correct 180 degree rotation */
45
#define RANDOM_FORMAT() \
46
(formats[prng_rand_n (ARRAY_LENGTH (formats))])
49
(ops[prng_rand_n (ARRAY_LENGTH (ops))])
51
#define RANDOM_TRANSFORM() \
52
(&(transforms[prng_rand_n (ARRAY_LENGTH (transforms))]))
55
on_destroy (pixman_image_t *image, void *data)
60
static pixman_image_t *
63
pixman_format_code_t format = RANDOM_FORMAT();
64
uint32_t *bytes = malloc (WIDTH * HEIGHT * 4);
65
pixman_image_t *image;
67
prng_randmemset (bytes, WIDTH * HEIGHT * 4, 0);
69
image = pixman_image_create_bits (
70
format, WIDTH, HEIGHT, bytes, WIDTH * 4);
72
pixman_image_set_transform (image, RANDOM_TRANSFORM());
73
pixman_image_set_destroy_function (image, on_destroy, bytes);
74
pixman_image_set_repeat (image, PIXMAN_REPEAT_NORMAL);
76
image_endian_swap (image);
82
test_transform (int testnum, int verbose)
84
pixman_image_t *src, *dest;
92
pixman_image_composite (RANDOM_OP(),
94
0, 0, 0, 0, WIDTH / 2, HEIGHT / 2,
97
crc = compute_crc32_for_image (0, dest);
99
pixman_image_unref (src);
100
pixman_image_unref (dest);
106
main (int argc, const char *argv[])
108
return fuzzer_test_main ("rotate", 15000,
110
test_transform, argc, argv);