From a04e3726648c62a1385b67cfc16a785a468e1d13 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Sun, 5 Jul 2009 09:21:47 +0100 Subject: [PATCH] [path] Add path watch debugging Simple debug macro to print the path to stderr during construction. --- src/cairo-path-fixed-private.h | 9 +++++++++ src/cairo-path-fixed.c | 26 ++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/src/cairo-path-fixed-private.h b/src/cairo-path-fixed-private.h index 5df184938..c7101e9f8 100644 --- a/src/cairo-path-fixed-private.h +++ b/src/cairo-path-fixed-private.h @@ -39,6 +39,11 @@ #include "cairo-types-private.h" #include "cairo-compiler-private.h" +#define WATCH_PATH 0 +#if WATCH_PATH +#include +#endif + enum cairo_path_op { CAIRO_PATH_OP_MOVE_TO = 0, CAIRO_PATH_OP_LINE_TO = 1, @@ -110,6 +115,10 @@ _cairo_path_fixed_iter_at_end (const cairo_path_fixed_iter_t *iter); static inline cairo_bool_t _cairo_path_fixed_is_region (cairo_path_fixed_t *path) { +#if WATCH_PATH + fprintf (stderr, "_cairo_path_fixed_is_region () = %s\n", + path->is_region ? "true" : "false"); +#endif return path->is_region; } diff --git a/src/cairo-path-fixed.c b/src/cairo-path-fixed.c index 5574e2d1e..1cc86c53b 100644 --- a/src/cairo-path-fixed.c +++ b/src/cairo-path-fixed.c @@ -574,6 +574,32 @@ _cairo_path_fixed_add (cairo_path_fixed_t *path, _cairo_path_fixed_add_buf (path, buf); } + if (WATCH_PATH) { + const char *op_str[] = { + "move-to", + "line-to", + "curve-to", + "close-path", + }; + char buf[1024]; + int len = 0; + int i; + + len += snprintf (buf + len, sizeof (buf), "["); + for (i = 0; i < num_points; i++) { + if (i != 0) + len += snprintf (buf + len, sizeof (buf), " "); + len += snprintf (buf + len, sizeof (buf), "(%f, %f)", + _cairo_fixed_to_double (points[i].x), + _cairo_fixed_to_double (points[i].y)); + } + len += snprintf (buf + len, sizeof (buf), "]"); + + fprintf (stderr, + "_cairo_path_fixed_add (%s, %s)\n", + op_str[(int) op], buf); + } + _cairo_path_buf_add_op (buf, op); _cairo_path_buf_add_points (buf, points, num_points);