summaryrefslogtreecommitdiff
path: root/src/cairo-path.c
diff options
context:
space:
mode:
authorBrian Ewins <Brian.Ewins@gmail.com>2008-01-20 03:21:41 +0000
committerCarl Worth <cworth@cworth.org>2008-01-21 12:06:36 -0800
commit3270ae6a65105787942da8309fa874ee65bc79fe (patch)
tree7567f7007efd0c2a1779992d7b13d7558cc238bf /src/cairo-path.c
parent4177208be63caa3128eaf07428f3d4617fcd18e0 (diff)
[path] Use new interpret_flat infrastructure for path_count.
Refactor to reduce duplication of path flattening code.
Diffstat (limited to 'src/cairo-path.c')
-rw-r--r--src/cairo-path.c62
1 files changed, 18 insertions, 44 deletions
diff --git a/src/cairo-path.c b/src/cairo-path.c
index b9086c4d..605ba058 100644
--- a/src/cairo-path.c
+++ b/src/cairo-path.c
@@ -44,7 +44,6 @@ static const cairo_path_t _cairo_path_nil = { CAIRO_STATUS_NO_MEMORY, NULL, 0 };
/* Closure for path interpretation. */
typedef struct cairo_path_count {
int count;
- double tolerance;
cairo_point_t current_point;
} cpc_t;
@@ -88,39 +87,6 @@ _cpc_curve_to (void *closure,
}
static cairo_status_t
-_cpc_curve_to_flatten (void *closure,
- cairo_point_t *p1,
- cairo_point_t *p2,
- cairo_point_t *p3)
-{
- cpc_t *cpc = closure;
- cairo_status_t status;
- cairo_spline_t spline;
- int i;
-
- cairo_point_t *p0 = &cpc->current_point;
-
- status = _cairo_spline_init (&spline, p0, p1, p2, p3);
- if (status == CAIRO_INT_STATUS_DEGENERATE)
- return CAIRO_STATUS_SUCCESS;
-
- status = _cairo_spline_decompose (&spline, cpc->tolerance);
- if (status)
- goto out;
-
- for (i=1; i < spline.num_points; i++)
- _cpc_line_to (cpc, &spline.points[i]);
-
- cpc->current_point = *p3;
-
- status = CAIRO_STATUS_SUCCESS;
-
- out:
- _cairo_spline_fini (&spline);
- return status;
-}
-
-static cairo_status_t
_cpc_close_path (void *closure)
{
cpc_t *cpc = closure;
@@ -140,19 +106,27 @@ _cairo_path_count (cairo_path_t *path,
cpc_t cpc;
cpc.count = 0;
- cpc.tolerance = tolerance;
cpc.current_point.x = 0;
cpc.current_point.y = 0;
- status = _cairo_path_fixed_interpret (path_fixed,
- CAIRO_DIRECTION_FORWARD,
- _cpc_move_to,
- _cpc_line_to,
- flatten ?
- _cpc_curve_to_flatten :
- _cpc_curve_to,
- _cpc_close_path,
- &cpc);
+ if (flatten) {
+ status = _cairo_path_fixed_interpret_flat (path_fixed,
+ CAIRO_DIRECTION_FORWARD,
+ _cpc_move_to,
+ _cpc_line_to,
+ _cpc_close_path,
+ &cpc,
+ tolerance);
+ } else {
+ status = _cairo_path_fixed_interpret (path_fixed,
+ CAIRO_DIRECTION_FORWARD,
+ _cpc_move_to,
+ _cpc_line_to,
+ _cpc_curve_to,
+ _cpc_close_path,
+ &cpc);
+ }
+
if (status)
return -1;