summaryrefslogtreecommitdiff
path: root/src/cairo-bentley-ottmann.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2008-12-17 20:47:09 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2009-01-29 16:47:53 +0000
commit5e6d25e204b681c5d5fba90abfe4d7401f23460f (patch)
treef74bc77c0912a570622cadc686bb6064ed19bf1d /src/cairo-bentley-ottmann.c
parentdd4276c6618aa250637e4499bc7cb0a35b24448c (diff)
downloadcairo-5e6d25e204b681c5d5fba90abfe4d7401f23460f.tar.gz
[skiplist] Provide an initial stack allocated pool.
Since we only need to allocate elts for intersection events and edges, the number of elts in flight at any one time is actually quite small and can usually be accommodated from an embedded pool.
Diffstat (limited to 'src/cairo-bentley-ottmann.c')
-rw-r--r--src/cairo-bentley-ottmann.c33
1 files changed, 10 insertions, 23 deletions
diff --git a/src/cairo-bentley-ottmann.c b/src/cairo-bentley-ottmann.c
index 4096b9ad6..f1f2f8384 100644
--- a/src/cairo-bentley-ottmann.c
+++ b/src/cairo-bentley-ottmann.c
@@ -968,12 +968,6 @@ _cairo_bo_event_queue_init (cairo_bo_event_queue_t *event_queue,
unsigned num_events = 2*num_edges;
cairo_status_t status;
- status = _cairo_skip_list_init (&event_queue->intersection_queue,
- cairo_bo_event_compare_abstract,
- sizeof (cairo_bo_event_t));
- if (unlikely (status))
- return status;
-
/* The skip_elt_t field of a cairo_bo_event_t isn't used for start
* or stop events, so this allocation is safe. XXX: make the
* event type a union so it doesn't always contain the skip
@@ -982,10 +976,8 @@ _cairo_bo_event_queue_init (cairo_bo_event_queue_t *event_queue,
sizeof (cairo_bo_event_t) +
sizeof (cairo_bo_event_t *),
sizeof (cairo_bo_event_t *));
- if (unlikely (events == NULL)) {
- _cairo_skip_list_fini (&event_queue->intersection_queue);
+ if (unlikely (events == NULL))
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
- }
sorted_event_ptrs = (cairo_bo_event_t **) (events + num_events);
event_queue->startstop_events = events;
@@ -1012,6 +1004,10 @@ _cairo_bo_event_queue_init (cairo_bo_event_queue_t *event_queue,
_cairo_bo_event_queue_sort (sorted_event_ptrs, num_events);
event_queue->sorted_startstop_event_ptrs[num_events] = NULL;
+ _cairo_skip_list_init (&event_queue->intersection_queue,
+ cairo_bo_event_compare_abstract,
+ sizeof (cairo_bo_event_t));
+
return CAIRO_STATUS_SUCCESS;
}
@@ -1058,22 +1054,16 @@ _cairo_bo_event_queue_insert_if_intersect_below_current_y (cairo_bo_event_queue_
return _cairo_bo_event_queue_insert (event_queue, &event);
}
-static cairo_status_t
+static void
_cairo_bo_sweep_line_init (cairo_bo_sweep_line_t *sweep_line)
{
- cairo_status_t status;
-
- status = _cairo_skip_list_init (&sweep_line->active_edges,
- _sweep_line_elt_compare,
- sizeof (sweep_line_elt_t));
- if (unlikely (status))
- return status;
+ _cairo_skip_list_init (&sweep_line->active_edges,
+ _sweep_line_elt_compare,
+ sizeof (sweep_line_elt_t));
sweep_line->head = NULL;
sweep_line->tail = NULL;
sweep_line->current_y = 0;
-
- return CAIRO_STATUS_SUCCESS;
}
static void
@@ -1508,9 +1498,7 @@ _cairo_bentley_ottmann_tessellate_bo_edges (cairo_bo_edge_t *edges,
if (status)
return status;
- status = _cairo_bo_sweep_line_init (&sweep_line);
- if (unlikely (status))
- goto CLEANUP_EVENT_QUEUE;
+ _cairo_bo_sweep_line_init (&sweep_line);
_cairo_bo_traps_init (&bo_traps, traps, xmin, ymin, xmax, ymax);
@@ -1637,7 +1625,6 @@ _cairo_bentley_ottmann_tessellate_bo_edges (cairo_bo_edge_t *edges,
}
_cairo_bo_traps_fini (&bo_traps);
_cairo_bo_sweep_line_fini (&sweep_line);
- CLEANUP_EVENT_QUEUE:
_cairo_bo_event_queue_fini (&event_queue);
return status;
}