diff --git a/src/cairo-surface-fallback.c b/src/cairo-surface-fallback.c index 090da70..06e53d5 100644 --- a/src/cairo-surface-fallback.c +++ b/src/cairo-surface-fallback.c @@ -768,6 +768,211 @@ _cairo_surface_fallback_mask (cairo_surf return status; } +static int _dump_debug_level = 0; +static int _dump_debug_done_indent = 0; + +void +open_dump_debug (char const *name) +{ + int i; + if (_dump_debug_done_indent) { + printf("\n"); + } + for (i=0; i<_dump_debug_level; i++) { + printf (" "); + } + if (name) printf ("%s=", name); + _dump_debug_level++; + _dump_debug_done_indent = 1; +} + +void +close_dump_debug (void) +{ + --_dump_debug_level; + if (_dump_debug_done_indent) + printf ("\n"); + _dump_debug_done_indent = 0; +} + +void +dump_debug_bytes (void const *buf, size_t size) +{ + size_t i; + uint8_t const *bytes= buf; + for (i=0; ixx); + dump_debug_double ("yx", &m->yx); + dump_debug_double ("xy", &m->xy); + dump_debug_double ("yy", &m->yy); + dump_debug_double ("x0", &m->x0); + dump_debug_double ("y0", &m->y0); + close_dump_debug (); +} + +void +dump_debug_int (char const *name, int x) +{ + open_dump_debug (name); + printf ("%d", x); + close_dump_debug (); +} + +void +dump_debug_pattern (char const *name, cairo_pattern_t const *pat) +{ + open_dump_debug (name); + dump_debug_int ("type", pat->type); + dump_debug_int ("ref_count", pat->ref_count); + dump_debug_int ("status", pat->status); + dump_debug_matrix ("matrix", &pat->matrix); + dump_debug_int ("filter", pat->filter); + dump_debug_int ("extend", pat->extend); + close_dump_debug (); +} + +void +dump_debug_double_ary (char const *name, double const *ary, unsigned n) +{ + unsigned i; + open_dump_debug (name); + printf ("[%u]", n); + for (i=0; ary && iline_width); + dump_debug_int ("line_cap", style->line_cap); + dump_debug_int ("line_join", style->line_join); + dump_debug_double ("miter_limit", &style->miter_limit); + dump_debug_double_ary ("dash", style->dash, style->num_dashes); + dump_debug_double ("dash_offset", &style->dash_offset); + close_dump_debug (); +} + +void +dump_debug_fixed (char const *name, cairo_fixed_t x) +{ + open_dump_debug (name); + printf ("%g (0x%x)", x/65536.0, x); + close_dump_debug (); +} + +void +dump_debug_point (char const *name, cairo_point_t pt) +{ + open_dump_debug (name); + dump_debug_fixed ("x", pt.x); + dump_debug_fixed ("y", pt.x); + close_dump_debug (); +} +cairo_status_t +dump_debug_move_to (void *unused_closure, cairo_point_t *p) +{ + (void)unused_closure; + dump_debug_point ("moveto", *p); + return CAIRO_STATUS_SUCCESS; +} + +cairo_status_t +dump_debug_line_to (void *unused_closure, cairo_point_t *p) +{ + (void)unused_closure; + dump_debug_point ("lineto", *p); + return CAIRO_STATUS_SUCCESS; +} + +cairo_status_t +dump_debug_curve_to (void *unused_closure, + cairo_point_t *ctrl1, + cairo_point_t *ctrl2, + cairo_point_t *stop) +{ + (void)unused_closure; + dump_debug_point ("curveto_ctrl1", *ctrl1); + dump_debug_point ("curveto_ctrl2", *ctrl2); + dump_debug_point ("curveto_stop", *stop); + return CAIRO_STATUS_SUCCESS; +} + +cairo_status_t +dump_debug_close_path (void *unused_closure) +{ + (void)unused_closure; + open_dump_debug ("closepath"); + close_dump_debug (); + return CAIRO_STATUS_SUCCESS; +} + +void +dump_debug_path_fixed (char const *name, cairo_path_fixed_t *path) +{ + open_dump_debug (name); + dump_debug_int ("has_current_point", path->has_current_point); + dump_debug_point ("last_move_point", path->last_move_point); + dump_debug_point ("current_point", path->current_point); + + open_dump_debug ("ops"); + _cairo_path_fixed_interpret (path, CAIRO_DIRECTION_FORWARD, + dump_debug_move_to, + dump_debug_line_to, + dump_debug_curve_to, + dump_debug_close_path, + NULL); + close_dump_debug (); + close_dump_debug (); +} + +void +dump_debug_stroke ( + char const *name, + cairo_surface_t *surface, + cairo_operator_t op, + cairo_pattern_t *source, + cairo_path_fixed_t *path, + cairo_stroke_style_t *stroke_style, + cairo_matrix_t *ctm, + cairo_matrix_t *ctm_inverse, + double tolerance, + cairo_antialias_t antialias) +{ + open_dump_debug (name); + (void)surface; + dump_debug_int ("op", op); + dump_debug_pattern ("source", source); + dump_debug_stroke_style ("stroke_style", stroke_style); + dump_debug_matrix ("ctm", ctm); + dump_debug_matrix ("ctm_inverse", ctm_inverse); + dump_debug_double ("tolerance", &tolerance); + dump_debug_int ("antialias", antialias); + dump_debug_path_fixed ("path", path); + close_dump_debug (); +} + cairo_status_t _cairo_surface_fallback_stroke (cairo_surface_t *surface, cairo_operator_t op, @@ -784,6 +989,11 @@ _cairo_surface_fallback_stroke (cairo_su _cairo_traps_init (&traps); + if (0) { + dump_debug_stroke ("stroke", surface, op, source, path, stroke_style, + ctm, ctm_inverse, tolerance, antialias); + } + status = _cairo_path_fixed_stroke_to_traps (path, stroke_style, ctm, ctm_inverse,