12 pixman_box32_t boxes[] = {
17 pixman_box32_t boxes2[] = {
21 pixman_box32_t boxes3[] = {
27 pixman_image_t *image, *fill;
28 pixman_color_t white = {
37 /* This used to go into an infinite loop before pixman-region.c
38 * was fixed to not use explict "short" variables
40 pixman_region32_init_rect (&r1, 0, 0, 20, 64000);
41 pixman_region32_init_rect (&r2, 0, 0, 20, 64000);
42 pixman_region32_init_rect (&r3, 0, 0, 20, 64000);
44 pixman_region32_subtract (&r1, &r2, &r3);
47 /* This would produce a region containing an empty
48 * rectangle in it. Such regions are considered malformed,
49 * but using an empty rectangle for initialization should
52 pixman_region32_init_rects (&r1, boxes, 3);
54 b = pixman_region32_rectangles (&r1, &i);
60 assert (b[i].x1 < b[i].x2);
61 assert (b[i].y1 < b[i].y2);
64 /* This would produce a rectangle containing the bounding box
65 * of the two rectangles. The correct result is to eliminate
66 * the broken rectangle.
68 pixman_region32_init_rects (&r1, boxes2, 2);
70 b = pixman_region32_rectangles (&r1, &i);
74 assert (b[0].x1 == 4);
75 assert (b[0].y1 == 1);
76 assert (b[0].x2 == 6);
77 assert (b[0].y2 == 7);
79 /* This should produce an empty region */
80 pixman_region32_init_rects (&r1, boxes3, 2);
82 b = pixman_region32_rectangles (&r1, &i);
86 fill = pixman_image_create_solid_fill (&white);
87 for (i = 0; i < 100; i++)
91 pixman_region32_init (&r1);
93 /* Add some random rectangles */
94 for (j = 0; j < 64; j++)
95 pixman_region32_union_rect (&r1, &r1,
96 prng_rand_n (image_size),
97 prng_rand_n (image_size),
101 /* Clip to image size */
102 pixman_region32_init_rect (&r2, 0, 0, image_size, image_size);
103 pixman_region32_intersect (&r1, &r1, &r2);
104 pixman_region32_fini (&r2);
106 /* render region to a1 mask */
107 image = pixman_image_create_bits (PIXMAN_a1, image_size, image_size, NULL, 0);
108 pixman_image_set_clip_region32 (image, &r1);
109 pixman_image_composite32 (PIXMAN_OP_SRC,
112 image_size, image_size);
113 pixman_region32_init_from_image (&r2, image);
115 pixman_image_unref (image);
117 assert (pixman_region32_equal (&r1, &r2));
118 pixman_region32_fini (&r1);
119 pixman_region32_fini (&r2);
122 pixman_image_unref (fill);