summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSøren Sandmann Pedersen <ssp@redhat.com>2010-11-08 01:46:02 -0500
committerSøren Sandmann Pedersen <ssp@redhat.com>2010-11-08 01:46:02 -0500
commit595f5962e210b7f0970e2563a8c2f8cf97b082cd (patch)
treeb89cc133efa53a36e398755775a485bcc4e888b1
parentf043b03399ff1f323dd16bc82a5b5a1126828291 (diff)
asdf
-rw-r--r--region-iter.c104
1 files changed, 104 insertions, 0 deletions
diff --git a/region-iter.c b/region-iter.c
index b7337c4..f42c655 100644
--- a/region-iter.c
+++ b/region-iter.c
@@ -55,6 +55,15 @@ struct row_t
/* region_data manipulation */
+#define BROKEN_DATA ((pixman_region32_data_t *)0x01)
+
+typedef struct region_builder_t region_builder_t;
+
+struct region_builder_t
+{
+ pixman_region32_data_t * data;
+};
+
static size_t
next_power (size_t n)
{
@@ -91,6 +100,52 @@ region_data_append (pixman_region32_data_t *data, int n, pixman_box32_t *boxes)
return data;
}
+static void
+region_builder_init (region_builder_t *builder)
+{
+ builder->data = NULL;
+}
+
+static pixman_bool_t
+region_builder_add_boxes (region_builder_t *builder, int n, pixman_box32_t *boxes)
+{
+ pixman_region32_data_t *data;
+
+ if (builder->data == BROKEN_DATA)
+ return FALSE;
+
+ data = region_data_append (builder->data, n, boxes);
+
+ if (!data)
+ {
+ free (builder->data);
+ builder->data = BROKEN_DATA;
+ return FALSE;
+ }
+
+ builder->data = data;
+ return TRUE;
+}
+
+static void
+region_builder_finish (region_builder_t *builder, pixman_region32_t *region)
+{
+ pixman_region32_fini (region);
+
+ if (!builder->data)
+ {
+ /* Empty */
+ }
+ else if (builder->data == BROKEN_DATA)
+ {
+
+ }
+ else
+ {
+ /* Coalesce and set extents */
+ }
+}
+
/* Region iterator */
static void
@@ -407,6 +462,55 @@ region_op (ops_t op,
}
}
+static int
+compare_boxes (void *box1v, void *box2v)
+{
+ pixman_box32_t *box1 = box1v;
+ pixman_box32_t *box2 = box2v;
+ int c;
+
+ if ((c = box1->y1 - box2->y1) == 0)
+ c = box1->x1 - box2->x1;
+
+ return c;
+}
+
+pixman_bool_t
+region_from_boxes (pixman_region32_t *region, const pixman_box32_t *boxes, int n_boxes)
+{
+ if (n_boxes == 0)
+ {
+ pixman_region32_init (region);
+ return TRUE;
+ }
+ else
+ {
+ pixman_box32_t *copy = malloc (sizeof (pixman_box32_t) * n_boxes);
+ int displacement, i;
+
+ displacement = 0;
+ for (i = 0; i < n_boxes; ++i)
+ {
+ pixman_box32_t *box = boxes + i;
+
+ if (box->x1 >= box->x2 || box->y1 >= box->y2)
+ displacement++;
+ else
+ copy[i - displacement] = boxes[i];
+ }
+
+ qsort (copy, i - displacement, sizeof (pixman_box32_t), compare_boxes);
+
+ make_region_from_boxes (region, copy, i - displacement);
+ }
+
+ else if (n_boxes == 1)
+
+ pixman_region32_t tmp;
+
+ qsort
+}
+
typedef struct corner_t corner_t;
struct corner_t