summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2010-02-19 11:22:52 +0100
committerAlexander Larsson <alexl@redhat.com>2010-02-19 11:25:41 +0100
commitf32d585069e77f09f84de42eda8ed8f6849aab57 (patch)
tree2cdc7fcf20d8d9c1dd2511c5bc80910fc29975c2
parent48ef4befd88e06e83a583a70f0172f1a08a65cda (diff)
Test pixman_region32_init_from_image in region-test
-rw-r--r--test/Makefile.am4
-rw-r--r--test/region-test.c49
2 files changed, 50 insertions, 3 deletions
diff --git a/test/Makefile.am b/test/Makefile.am
index 5f6ba13a..3229f967 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -13,12 +13,14 @@ TESTPROGRAMS = \
composite
fetch_test_LDADD = $(TEST_LDADD)
-region_test_LDADD = $(TEST_LDADD)
composite_LDADD = $(TEST_LDADD)
trap_crasher_LDADD = $(TEST_LDADD)
oob_test_LDADD = $(TEST_LDADD)
window_test_LDADD = $(TEST_LDADD)
+region_test_LDADD = $(TEST_LDADD)
+region_test_SOURCES = region-test.c utils.c utils.h
+
blitters_test_LDADD = $(TEST_LDADD)
blitters_test_SOURCES = blitters-test.c utils.c utils.h
diff --git a/test/region-test.c b/test/region-test.c
index 3568969f..9d5a41eb 100644
--- a/test/region-test.c
+++ b/test/region-test.c
@@ -1,7 +1,7 @@
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
-#include "pixman.h"
+#include "utils.h"
int
main ()
@@ -22,8 +22,15 @@ main ()
{ 2, 6, 7, 6 },
{ 4, 1, 6, 1 },
};
- int i;
+ int i, j;
pixman_box32_t *b;
+ pixman_image_t *image, *fill;
+ pixman_color_t white = {
+ 0xffff,
+ 0xffff,
+ 0xffff,
+ 0xffff
+ };
/* This used to go into an infinite loop before pixman-region.c
* was fixed to not use explict "short" variables
@@ -74,5 +81,43 @@ main ()
assert (i == 0);
+ fill = pixman_image_create_solid_fill (&white);
+ for (i = 0; i < 100; i++)
+ {
+ int image_size = 128;
+
+ pixman_region32_init (&r1);
+
+ /* Add some random rectangles */
+ for (j = 0; j < 64; j++)
+ pixman_region32_union_rect (&r1, &r1,
+ lcg_rand_n (image_size),
+ lcg_rand_n (image_size),
+ lcg_rand_n (25),
+ lcg_rand_n (25));
+
+ /* Clip to image size */
+ pixman_region32_init_rect (&r2, 0, 0, image_size, image_size);
+ pixman_region32_intersect (&r1, &r1, &r2);
+ pixman_region32_fini (&r2);
+
+ /* render region to a1 mask */
+ image = pixman_image_create_bits (PIXMAN_a1, image_size, image_size, NULL, 0);
+ pixman_image_set_clip_region32 (image, &r1);
+ pixman_image_composite32 (PIXMAN_OP_SRC,
+ fill, NULL, image,
+ 0, 0, 0, 0, 0, 0,
+ image_size, image_size);
+ pixman_region32_init_from_image (&r2, image);
+
+ pixman_image_unref (image);
+
+ assert (pixman_region32_equal (&r1, &r2));
+ pixman_region32_fini (&r1);
+ pixman_region32_fini (&r2);
+
+ }
+ pixman_image_unref (fill);
+
return 0;
}