summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSøren Sandmann Pedersen <ssp@l3000.localdomain>2010-06-29 13:28:33 -0400
committerSøren Sandmann Pedersen <ssp@l3000.localdomain>2010-06-29 13:28:33 -0400
commit8aaf1c4942f7744ec3638e1ecfc5e9f0449eefe5 (patch)
tree9238041a6b1d342bbf80c1c3bfaf5a45cf17c1b7
parent4f95e9e7bed774a65ec9e34e1a5ada8157091553 (diff)
Fixes and tests
-rw-r--r--region-iter.c57
1 files changed, 49 insertions, 8 deletions
diff --git a/region-iter.c b/region-iter.c
index e45d3a0..aefeca7 100644
--- a/region-iter.c
+++ b/region-iter.c
@@ -135,6 +135,8 @@ region_iter_get_row (region_iter_t *iter,
static pixman_region32_data_t *
add_box (pixman_region32_data_t *data, int b1, int b2, int x1, int x2, int y1, int y2)
{
+ printf ("box: %d %d (%d %d %d %d)\n", b1, b2, x1, y1, x2, y2);
+
#if 0
switch (op)
{
@@ -160,6 +162,7 @@ add_box (pixman_region32_data_t *data, int b1, int b2, int x1, int x2, int y1, i
return data;
#endif
+ return NULL;
}
static void
@@ -179,7 +182,19 @@ process (const pixman_box32_t *row1_begin, const pixman_box32_t *row1_end,
while (p1 != row1_end || p2 != row2_end)
{
- if (p1->x2 < x2)
+ if (p1 == row1_end)
+ {
+ data = add_box (data, 0, 1, x2, p2->x2, y1, y2);
+
+ x2 = p2->x2;
+ }
+ else if (p2 == row2_end)
+ {
+ data = add_box (data, 1, 0, x1, p1->x2, y1, y2);
+
+ x1 = p1->x2;
+ }
+ else if (p1->x2 < x2)
{
data = add_box (data, 1, 0, x1, p1->x2, y1, y2);
@@ -216,11 +231,21 @@ process (const pixman_box32_t *row1_begin, const pixman_box32_t *row1_end,
x1 = x2 = p2->x2;
}
- if (x1 == p1->x2)
- x1 = p1++->x1;
+ if (x1 == p1->x2 && p1 != row1_end)
+ {
+ p1++;
+
+ if (p1 != row1_end)
+ x1 = p1->x1;
+ }
+
+ if (x2 == p2->x2 && p2 != row2_end)
+ {
+ p2++;
- if (x2 == p2->x2)
- x2 = p2++->x1;
+ if (p2 != row2_end)
+ x2 = p2->x1;
+ }
}
}
@@ -235,13 +260,12 @@ region_op (pixman_region32_t *dst,
int row1_y1, row1_y2;
const pixman_box32_t *row2_first, *row2_last;
int row2_y1, row2_y2;
- int y;
region_iter_init (&iter1, src1);
region_iter_init (&iter2, src2);
region_iter_get_row (&iter1, &row1_first, &row1_last, &row1_y1, &row1_y2);
- region_iter_get_row (&iter2, &row2_first, &row1_last, &row2_y1, &row2_y2);
+ region_iter_get_row (&iter2, &row2_first, &row2_last, &row2_y1, &row2_y2);
do
{
@@ -283,7 +307,7 @@ region_op (pixman_region32_t *dst,
if (row1_y1 == row1_y2)
region_iter_get_row (&iter1, &row1_first, &row1_last, &row1_y1, &row1_y2);
- if (row2_y2 == row2_y2)
+ if (row2_y1 == row2_y2)
region_iter_get_row (&iter2, &row2_first, &row2_last, &row2_y1, &row2_y2);
} while (row1_y1 != INT_MAX || row2_y1 != INT_MAX);
@@ -318,6 +342,7 @@ int
main ()
{
pixman_region32_t region;
+ pixman_region32_t region1, region2;
/* empty region */
pixman_region32_init (&region);
@@ -371,5 +396,21 @@ main ()
100, 200, 200, 50);
dump_region ("two rows", &region);
+ /* op */
+ printf ("-=- op\n");
+ pixman_region32_init_rect (&region1, 100, 100, 200, 200);
+ pixman_region32_init_rect (&region2, 200, 200, 200, 200);
+
+ region_op (NULL, &region1, &region2);
+
+ printf ("-=- op2\n");
+ pixman_region32_init_rect (&region1, 100, 100, 200, 200);
+ pixman_region32_union_rect (&region1, &region1, 100, 400, 200, 50);
+
+ pixman_region32_init_rect (&region2, 150, 50, 10, 520);
+
+
+ region_op (NULL, &region1, &region2);
+
return 0;
}