[path] Add path watch debugging

Simple debug macro to print the path to stderr during construction.
This commit is contained in:
Chris Wilson 2009-07-05 09:21:47 +01:00
parent 1645352bfb
commit a04e372664
2 changed files with 35 additions and 0 deletions

View file

@ -39,6 +39,11 @@
#include "cairo-types-private.h"
#include "cairo-compiler-private.h"
#define WATCH_PATH 0
#if WATCH_PATH
#include <stdio.h>
#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;
}

View file

@ -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);