[cairo] [PATCH] Performance patch for bo intersections

Baz brian.ewins at gmail.com
Mon Dec 11 18:29:14 PST 2006


On 12/12/06, Carl Worth <cworth at cworth.org> wrote:
> cg-diff should be just fine, but this on the other hand:
>
> > ------=_Part_140159_28422894.1165887995811
> > Content-Type: application/octet-stream; name=perf.patch
> > Content-Transfer-Encoding: base64
> > X-Attachment-Id: f_evln7qw5
> > Content-Disposition: attachment; filename="perf.patch"
>
> is not fine.
>
> We need plain-text patches so we can reply and comment on them.

Aagh, sorry - gmail strikes again. Here's an inline copy for review,
I'll sort it out properly next time around.

diff --git a/src/cairo-bentley-ottmann.c b/src/cairo-bentley-ottmann.c
index 4a72a8d..085f09b 100644
--- a/src/cairo-bentley-ottmann.c
+++ b/src/cairo-bentley-ottmann.c
@@ -804,9 +804,54 @@ _cairo_bo_event_queue_insert_if_intersec
     cairo_bo_status_t status;
     cairo_bo_point32_t intersection;
     cairo_bo_event_t event;
+    cairo_bo_point32_t* l1;
+    cairo_bo_point32_t* r1;
+    cairo_bo_point32_t* l2;
+    cairo_bo_point32_t* r2;
+

     if (left == NULL || right == NULL)
        return;
+
+    /* Edges whose bounding boxes don't overlap can't intersect.
+     */
+    //if (left->bottom.y < right->top.y || right->bottom.y < left->top.y)
+    //  return;
+
+    if (left->top.x < left->bottom.x) {
+      l1 = &(left->top);
+      r1 = &(left->bottom);
+    } else {
+      l1 = &(left->bottom);
+      r1 = &(left->top);
+    }
+
+    if (right->top.x < right->bottom.x) {
+      l2 = &(right->top);
+      r2 = &(right->bottom);
+    } else {
+      l2 = &(right->bottom);
+      r2 = &(right->top);
+    }
+
+    if (r1->x < l2->x || r2->x < l1->x) {
+      return;
+    }
+
+    /* coincident points are never intersections (because they
+     * are already at start/end events(?). They're quite common.
+     */
+    if (r1->x == l2->x) {
+      return;
+    }
+
+    /* coincident points are never intersections (because they
+     * are already at start/end events(?). They're quite common.
+     */
+    if (r1->x == l2->x) {
+      if (r1->y == l2->y) {
+       return;
+      } else if (l1->x == l2->x && l1->y == l2->y) {
+       return;
+      } else if (r1->x == r2->x && r1->y == r2->y) {
+       return;
+      } else if (l1->x == r2->x &&  l1->y == r2->y) {
+       return;
+      }
+    }

     /* The names "left" and "right" here are correct descriptions of
      * the order of the two edges within the active edge list. So if a


More information about the cairo mailing list