summaryrefslogtreecommitdiff
path: root/src/cairo-path.c
diff options
context:
space:
mode:
authorBrian Ewins <Brian.Ewins@gmail.com>2008-01-20 03:22:12 +0000
committerCarl Worth <cworth@cworth.org>2008-01-21 12:07:11 -0800
commiteba04b7fbcc7fdbf075ad1372208908634459178 (patch)
tree05adc703636f4eef62ba8f98df706330b1de8e04 /src/cairo-path.c
parent3270ae6a65105787942da8309fa874ee65bc79fe (diff)
downloadcairo-eba04b7fbcc7fdbf075ad1372208908634459178.tar.gz
[path] use new interpret_flat infrastructure for path_populate
refactor to reduce duplication of flattening code.
Diffstat (limited to 'src/cairo-path.c')
-rw-r--r--src/cairo-path.c50
1 files changed, 13 insertions, 37 deletions
diff --git a/src/cairo-path.c b/src/cairo-path.c
index 605ba0583..96ecbb355 100644
--- a/src/cairo-path.c
+++ b/src/cairo-path.c
@@ -237,40 +237,6 @@ _cpp_curve_to (void *closure,
}
static cairo_status_t
-_cpp_curve_to_flatten (void *closure,
- cairo_point_t *p1,
- cairo_point_t *p2,
- cairo_point_t *p3)
-{
- cpp_t *cpp = closure;
- cairo_status_t status;
- cairo_spline_t spline;
- int i;
-
- cairo_point_t *p0 = &cpp->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,
- _cairo_gstate_get_tolerance (cpp->gstate));
- if (status)
- goto out;
-
- for (i=1; i < spline.num_points; i++)
- _cpp_line_to (cpp, &spline.points[i]);
-
- cpp->current_point = *p3;
-
- status = CAIRO_STATUS_SUCCESS;
-
- out:
- _cairo_spline_fini (&spline);
- return status;
-}
-
-static cairo_status_t
_cpp_close_path (void *closure)
{
cpp_t *cpp = closure;
@@ -298,15 +264,25 @@ _cairo_path_populate (cairo_path_t *path,
cpp.current_point.x = 0;
cpp.current_point.y = 0;
- status = _cairo_path_fixed_interpret (path_fixed,
+ if (flatten) {
+ double tolerance = _cairo_gstate_get_tolerance (gstate);
+ status = _cairo_path_fixed_interpret_flat (path_fixed,
+ CAIRO_DIRECTION_FORWARD,
+ _cpp_move_to,
+ _cpp_line_to,
+ _cpp_close_path,
+ &cpp,
+ tolerance);
+ } else {
+ status = _cairo_path_fixed_interpret (path_fixed,
CAIRO_DIRECTION_FORWARD,
_cpp_move_to,
_cpp_line_to,
- flatten ?
- _cpp_curve_to_flatten :
_cpp_curve_to,
_cpp_close_path,
&cpp);
+ }
+
if (status)
return status;