summaryrefslogtreecommitdiff
path: root/src/cairo-debug.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2009-08-11 17:01:07 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2009-08-29 08:08:33 +0100
commita2d5f59e2158651ac85dcc8a2b8f49cd2861044e (patch)
tree39175bfd42b989a86b54688eb5c06d69e4faa524 /src/cairo-debug.c
parent4bf96bad9697cbe67907df69d40f46d8d7f24325 (diff)
downloadcairo-a2d5f59e2158651ac85dcc8a2b8f49cd2861044e.tar.gz
[debug] Path printer
Diffstat (limited to 'src/cairo-debug.c')
-rw-r--r--src/cairo-debug.c67
1 files changed, 67 insertions, 0 deletions
diff --git a/src/cairo-debug.c b/src/cairo-debug.c
index 4409e6ebf..9160728e0 100644
--- a/src/cairo-debug.c
+++ b/src/cairo-debug.c
@@ -165,3 +165,70 @@ _cairo_image_surface_write_to_ppm (cairo_image_surface_t *isurf, const char *fn)
fprintf (stderr, "Wrote %s\n", fn);
}
#endif
+
+static cairo_status_t
+_print_move_to (void *closure,
+ const cairo_point_t *point)
+{
+ fprintf (closure,
+ " %f %f m",
+ _cairo_fixed_to_double (point->x),
+ _cairo_fixed_to_double (point->y));
+
+ return CAIRO_STATUS_SUCCESS;
+}
+
+static cairo_status_t
+_print_line_to (void *closure,
+ const cairo_point_t *point)
+{
+ fprintf (closure,
+ " %f %f l",
+ _cairo_fixed_to_double (point->x),
+ _cairo_fixed_to_double (point->y));
+
+ return CAIRO_STATUS_SUCCESS;
+}
+
+static cairo_status_t
+_print_curve_to (void *closure,
+ const cairo_point_t *p1,
+ const cairo_point_t *p2,
+ const cairo_point_t *p3)
+{
+ fprintf (closure,
+ " %f %f %f %f %f %f c",
+ _cairo_fixed_to_double (p1->x),
+ _cairo_fixed_to_double (p1->y),
+ _cairo_fixed_to_double (p2->x),
+ _cairo_fixed_to_double (p2->y),
+ _cairo_fixed_to_double (p3->x),
+ _cairo_fixed_to_double (p3->y));
+
+ return CAIRO_STATUS_SUCCESS;
+}
+
+static cairo_status_t
+_print_close (void *closure)
+{
+ fprintf (closure, " h");
+
+ return CAIRO_STATUS_SUCCESS;
+}
+
+void
+_cairo_debug_print_path (FILE *stream, cairo_path_fixed_t *path)
+{
+ cairo_status_t status;
+
+ status = _cairo_path_fixed_interpret (path,
+ CAIRO_DIRECTION_FORWARD,
+ _print_move_to,
+ _print_line_to,
+ _print_curve_to,
+ _print_close,
+ stream);
+ assert (status == CAIRO_STATUS_SUCCESS);
+
+ printf ("\n");
+}