mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2025-12-26 12:20:12 +01:00
[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:
parent
dc33760fcb
commit
1246ff8aec
2 changed files with 34 additions and 0 deletions
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue