[cairo-test] Implement cairo_test_log_path() to dump a cairo_path_t to logs

Dumping paths is so hard in C.  Shouldn't be.  At least not when debugging...
This commit is contained in:
Behdad Esfahbod 2008-05-09 17:14:02 +02:00
parent dc33760fcb
commit 1246ff8aec
2 changed files with 34 additions and 0 deletions

View file

@ -151,6 +151,37 @@ cairo_test_log (const char *fmt, ...)
va_end (va);
}
void
cairo_test_log_path (const cairo_path_t *path)
{
int i;
for (i = 0; i < path->num_data; i += path->data[i].header.length) {
cairo_path_data_t *data = &path->data[i];
switch (data->header.type) {
case CAIRO_PATH_MOVE_TO:
cairo_test_log (" cairo_move_to (cr, %g, %g);\n",
data[1].point.x, data[1].point.y);
break;
case CAIRO_PATH_LINE_TO:
cairo_test_log (" cairo_line_to (cr, %g, %g);\n",
data[1].point.x, data[1].point.y);
break;
case CAIRO_PATH_CURVE_TO:
cairo_test_log (" cairo_curve_to (cr, %g, %g, %g, %g, %g, %g);\n",
data[1].point.x, data[1].point.y,
data[2].point.x, data[2].point.y,
data[3].point.x, data[3].point.y);
break;
case CAIRO_PATH_CLOSE_PATH:
cairo_test_log (" cairo_close_path (cr);\n\n");
break;
default:
assert (0);
}
}
}
static void
xunlink (const char *pathname)
{

View file

@ -120,6 +120,9 @@ cairo_test_fini (void);
void
cairo_test_log (const char *fmt, ...) CAIRO_BOILERPLATE_PRINTF_FORMAT(1, 2);
void
cairo_test_log_path (const cairo_path_t *path);
/* Helper functions that take care of finding source images even when
* building in a non-srcdir manner, (ie. the tests will be run in a
* directory that is different from the one where the source image