diff options
Diffstat (limited to 'src/cairo.c')
-rw-r--r-- | src/cairo.c | 272 |
1 files changed, 229 insertions, 43 deletions
diff --git a/src/cairo.c b/src/cairo.c index 983f02cea..d3396400f 100644 --- a/src/cairo.c +++ b/src/cairo.c @@ -49,6 +49,7 @@ #include "cairo-surface-backend-private.h" #include <assert.h> +#include "cairo-ttrace.h" /** * SECTION:cairo @@ -226,17 +227,28 @@ _cairo_create_in_error (cairo_status_t status) cairo_t * cairo_create (cairo_surface_t *target) { - if (unlikely (target == NULL)) + CAIRO_TRACE_BEGIN (__func__); + if (unlikely (target == NULL)) { + CAIRO_TRACE_END (__func__); return _cairo_create_in_error (_cairo_error (CAIRO_STATUS_NULL_POINTER)); - if (unlikely (target->status)) + } + if (unlikely (target->status)) { + CAIRO_TRACE_END (__func__); return _cairo_create_in_error (target->status); - if (unlikely (target->finished)) + } + if (unlikely (target->finished)) { + CAIRO_TRACE_END (__func__); return _cairo_create_in_error (_cairo_error (CAIRO_STATUS_SURFACE_FINISHED)); + } - if (target->backend->create_context == NULL) + if (target->backend->create_context == NULL) { + CAIRO_TRACE_END (__func__); return _cairo_create_in_error (_cairo_error (CAIRO_STATUS_WRITE_ERROR)); + } - return target->backend->create_context (target); + cairo_t *cr = target->backend->create_context (target); + CAIRO_TRACE_END (__func__); + return cr; } slim_hidden_def (cairo_create); @@ -299,15 +311,21 @@ _cairo_fini (cairo_t *cr) void cairo_destroy (cairo_t *cr) { - if (cr == NULL || CAIRO_REFERENCE_COUNT_IS_INVALID (&cr->ref_count)) + CAIRO_TRACE_BEGIN (__func__); + if (cr == NULL || CAIRO_REFERENCE_COUNT_IS_INVALID (&cr->ref_count)) { + CAIRO_TRACE_END (__func__); return; + } assert (CAIRO_REFERENCE_COUNT_HAS_REFERENCE (&cr->ref_count)); - if (! _cairo_reference_count_dec_and_test (&cr->ref_count)) + if (! _cairo_reference_count_dec_and_test (&cr->ref_count)) { + CAIRO_TRACE_END (__func__); return; + } cr->backend->destroy (cr); + CAIRO_TRACE_END (__func__); } slim_hidden_def (cairo_destroy); @@ -404,14 +422,19 @@ cairo_get_reference_count (cairo_t *cr) void cairo_save (cairo_t *cr) { + CAIRO_TRACE_BEGIN (__func__); cairo_status_t status; - if (unlikely (cr->status)) + if (unlikely (cr->status)) { + CAIRO_TRACE_END (__func__); return; + } status = cr->backend->save (cr); if (unlikely (status)) _cairo_set_error (cr, status); + + CAIRO_TRACE_END (__func__); } slim_hidden_def(cairo_save); @@ -428,14 +451,19 @@ slim_hidden_def(cairo_save); void cairo_restore (cairo_t *cr) { + CAIRO_TRACE_BEGIN (__func__); cairo_status_t status; - if (unlikely (cr->status)) + if (unlikely (cr->status)) { + CAIRO_TRACE_END (__func__); return; + } status = cr->backend->restore (cr); if (unlikely (status)) _cairo_set_error (cr, status); + + CAIRO_TRACE_END (__func__); } slim_hidden_def(cairo_restore); @@ -675,14 +703,19 @@ cairo_set_opacity (cairo_t *cr, double opacity) void cairo_set_source_rgb (cairo_t *cr, double red, double green, double blue) { + CAIRO_TRACE_BEGIN (__func__); cairo_status_t status; - if (unlikely (cr->status)) + if (unlikely (cr->status)) { + CAIRO_TRACE_END (__func__); return; + } status = cr->backend->set_source_rgba (cr, red, green, blue, 1.); if (unlikely (status)) _cairo_set_error (cr, status); + + CAIRO_TRACE_END (__func__); } slim_hidden_def (cairo_set_source_rgb); @@ -753,19 +786,25 @@ cairo_set_source_surface (cairo_t *cr, double x, double y) { + CAIRO_TRACE_BEGIN (__func__); cairo_status_t status; - if (unlikely (cr->status)) + if (unlikely (cr->status)) { + CAIRO_TRACE_END (__func__); return; + } if (unlikely (surface == NULL)) { _cairo_set_error (cr, CAIRO_STATUS_NULL_POINTER); + CAIRO_TRACE_END (__func__); return; } status = cr->backend->set_source_surface (cr, surface, x, y); if (unlikely (status)) _cairo_set_error (cr, status); + + CAIRO_TRACE_END (__func__); } slim_hidden_def (cairo_set_source_surface); @@ -1191,14 +1230,19 @@ cairo_set_miter_limit (cairo_t *cr, double limit) void cairo_translate (cairo_t *cr, double tx, double ty) { + CAIRO_TRACE_BEGIN (__func__); cairo_status_t status; - if (unlikely (cr->status)) + if (unlikely (cr->status)) { + CAIRO_TRACE_END (__func__); return; + } status = cr->backend->translate (cr, tx, ty); if (unlikely (status)) _cairo_set_error (cr, status); + + CAIRO_TRACE_END (__func__); } slim_hidden_def (cairo_translate); @@ -1218,14 +1262,19 @@ slim_hidden_def (cairo_translate); void cairo_scale (cairo_t *cr, double sx, double sy) { + CAIRO_TRACE_BEGIN (__func__); cairo_status_t status; - if (unlikely (cr->status)) + if (unlikely (cr->status)) { + CAIRO_TRACE_END (__func__); return; + } status = cr->backend->scale (cr, sx, sy); if (unlikely (status)) _cairo_set_error (cr, status); + + CAIRO_TRACE_END (__func__); } slim_hidden_def (cairo_scale); @@ -1246,14 +1295,19 @@ slim_hidden_def (cairo_scale); void cairo_rotate (cairo_t *cr, double angle) { + CAIRO_TRACE_BEGIN (__func__); cairo_status_t status; - if (unlikely (cr->status)) + if (unlikely (cr->status)) { + CAIRO_TRACE_END (__func__); return; + } status = cr->backend->rotate (cr, angle); if (unlikely (status)) _cairo_set_error (cr, status); + + CAIRO_TRACE_END (__func__); } /** @@ -1346,10 +1400,14 @@ cairo_identity_matrix (cairo_t *cr) void cairo_user_to_device (cairo_t *cr, double *x, double *y) { - if (unlikely (cr->status)) + CAIRO_TRACE_BEGIN (__func__); + if (unlikely (cr->status)) { + CAIRO_TRACE_END (__func__); return; + } cr->backend->user_to_device (cr, x, y); + CAIRO_TRACE_END (__func__); } slim_hidden_def (cairo_user_to_device); @@ -1369,10 +1427,14 @@ slim_hidden_def (cairo_user_to_device); void cairo_user_to_device_distance (cairo_t *cr, double *dx, double *dy) { - if (unlikely (cr->status)) + CAIRO_TRACE_BEGIN (__func__); + if (unlikely (cr->status)) { + CAIRO_TRACE_END (__func__); return; + } cr->backend->user_to_device_distance (cr, dx, dy); + CAIRO_TRACE_END (__func__); } slim_hidden_def (cairo_user_to_device_distance); @@ -1391,10 +1453,14 @@ slim_hidden_def (cairo_user_to_device_distance); void cairo_device_to_user (cairo_t *cr, double *x, double *y) { - if (unlikely (cr->status)) + CAIRO_TRACE_BEGIN (__func__); + if (unlikely (cr->status)) { + CAIRO_TRACE_END (__func__); return; + } cr->backend->device_to_user (cr, x, y); + CAIRO_TRACE_END (__func__); } slim_hidden_def (cairo_device_to_user); @@ -1626,10 +1692,13 @@ cairo_arc (cairo_t *cr, double radius, double angle1, double angle2) { + CAIRO_TRACE_BEGIN (__func__); cairo_status_t status; - if (unlikely (cr->status)) + if (unlikely (cr->status)) { + CAIRO_TRACE_END (__func__); return; + } if (angle2 < angle1) { /* increase angle2 by multiples of full circle until it @@ -1642,6 +1711,8 @@ cairo_arc (cairo_t *cr, status = cr->backend->arc (cr, xc, yc, radius, angle1, angle2, TRUE); if (unlikely (status)) _cairo_set_error (cr, status); + + CAIRO_TRACE_END (__func__); } /** @@ -1670,10 +1741,13 @@ cairo_arc_negative (cairo_t *cr, double radius, double angle1, double angle2) { + CAIRO_TRACE_BEGIN (__func__); cairo_status_t status; - if (unlikely (cr->status)) + if (unlikely (cr->status)) { + CAIRO_TRACE_END (__func__); return; + } if (angle2 > angle1) { /* decrease angle2 by multiples of full circle until it @@ -1687,6 +1761,7 @@ cairo_arc_negative (cairo_t *cr, status = cr->backend->arc (cr, xc, yc, radius, angle1, angle2, FALSE); if (unlikely (status)) _cairo_set_error (cr, status); + CAIRO_TRACE_END (__func__); } /* XXX: NYI @@ -1861,14 +1936,19 @@ cairo_rectangle (cairo_t *cr, double x, double y, double width, double height) { + CAIRO_TRACE_BEGIN (__func__); cairo_status_t status; - if (unlikely (cr->status)) + if (unlikely (cr->status)) { + CAIRO_TRACE_END (__func__); return; + } status = cr->backend->rectangle (cr, x, y, width, height); if (unlikely (status)) _cairo_set_error (cr, status); + + CAIRO_TRACE_END (__func__); } /** @@ -1906,16 +1986,21 @@ cairo_rounded_rectangle (cairo_t *cr, double r_top_left, double r_top_right, double r_bottom_left, double r_bottom_right) { - cairo_status_t status; + CAIRO_TRACE_BEGIN (__func__); + cairo_status_t status; - if (unlikely (cr->status)) + if (unlikely (cr->status)) { + CAIRO_TRACE_END (__func__); return; + } status = cr->backend->rounded_rectangle (cr, x, y, width, height, r_top_left, r_top_right, r_bottom_left, r_bottom_right); if (unlikely (status)) _cairo_set_error (cr, status); + + CAIRO_TRACE_END (__func__); } #if 0 @@ -2041,14 +2126,19 @@ cairo_path_extents (cairo_t *cr, void cairo_paint (cairo_t *cr) { + CAIRO_TRACE_BEGIN (__func__); cairo_status_t status; - if (unlikely (cr->status)) + if (unlikely (cr->status)) { + CAIRO_TRACE_END (__func__); return; + } status = cr->backend->paint (cr); if (unlikely (status)) _cairo_set_error (cr, status); + + CAIRO_TRACE_END (__func__); } slim_hidden_def (cairo_paint); @@ -2068,14 +2158,19 @@ void cairo_paint_with_alpha (cairo_t *cr, double alpha) { + CAIRO_TRACE_BEGIN (__func__); cairo_status_t status; - if (unlikely (cr->status)) + if (unlikely (cr->status)) { + CAIRO_TRACE_END (__func__); return; + } status = cr->backend->paint_with_alpha (cr, alpha); if (unlikely (status)) _cairo_set_error (cr, status); + + CAIRO_TRACE_END (__func__); } /** @@ -2094,24 +2189,31 @@ void cairo_mask (cairo_t *cr, cairo_pattern_t *pattern) { + CAIRO_TRACE_BEGIN (__func__); cairo_status_t status; - if (unlikely (cr->status)) + if (unlikely (cr->status)) { + CAIRO_TRACE_END (__func__); return; + } if (unlikely (pattern == NULL)) { _cairo_set_error (cr, CAIRO_STATUS_NULL_POINTER); + CAIRO_TRACE_END (__func__); return; } if (unlikely (pattern->status)) { _cairo_set_error (cr, pattern->status); + CAIRO_TRACE_END (__func__); return; } status = cr->backend->mask (cr, pattern); if (unlikely (status)) _cairo_set_error (cr, status); + + CAIRO_TRACE_END (__func__); } slim_hidden_def (cairo_mask); @@ -2135,11 +2237,14 @@ cairo_mask_surface (cairo_t *cr, double surface_x, double surface_y) { + CAIRO_TRACE_BEGIN (__func__); cairo_pattern_t *pattern; cairo_matrix_t matrix; - if (unlikely (cr->status)) + if (unlikely (cr->status)) { + CAIRO_TRACE_END (__func__); return; + } pattern = cairo_pattern_create_for_surface (surface); @@ -2149,6 +2254,7 @@ cairo_mask_surface (cairo_t *cr, cairo_mask (cr, pattern); cairo_pattern_destroy (pattern); + CAIRO_TRACE_END (__func__); } /** @@ -2188,14 +2294,19 @@ cairo_mask_surface (cairo_t *cr, void cairo_stroke (cairo_t *cr) { + CAIRO_TRACE_BEGIN (__func__); cairo_status_t status; - if (unlikely (cr->status)) + if (unlikely (cr->status)) { + CAIRO_TRACE_END (__func__); return; + } status = cr->backend->stroke (cr); if (unlikely (status)) _cairo_set_error (cr, status); + + CAIRO_TRACE_END (__func__); } slim_hidden_def(cairo_stroke); @@ -2217,14 +2328,19 @@ slim_hidden_def(cairo_stroke); void cairo_stroke_preserve (cairo_t *cr) { + CAIRO_TRACE_BEGIN (__func__); cairo_status_t status; - if (unlikely (cr->status)) + if (unlikely (cr->status)) { + CAIRO_TRACE_END (__func__); return; + } status = cr->backend->stroke_preserve (cr); if (unlikely (status)) _cairo_set_error (cr, status); + + CAIRO_TRACE_END (__func__); } slim_hidden_def(cairo_stroke_preserve); @@ -2243,14 +2359,19 @@ slim_hidden_def(cairo_stroke_preserve); void cairo_fill (cairo_t *cr) { + CAIRO_TRACE_BEGIN (__func__); cairo_status_t status; - if (unlikely (cr->status)) + if (unlikely (cr->status)) { + CAIRO_TRACE_END (__func__); return; + } status = cr->backend->fill (cr); if (unlikely (status)) _cairo_set_error (cr, status); + + CAIRO_TRACE_END (__func__); } /** @@ -2269,14 +2390,19 @@ cairo_fill (cairo_t *cr) void cairo_fill_preserve (cairo_t *cr) { + CAIRO_TRACE_BEGIN (__func__); cairo_status_t status; - if (unlikely (cr->status)) + if (unlikely (cr->status)) { + CAIRO_TRACE_END (__func__); return; + } status = cr->backend->fill_preserve (cr); if (unlikely (status)) _cairo_set_error (cr, status); + + CAIRO_TRACE_END (__func__); } slim_hidden_def(cairo_fill_preserve); @@ -2436,6 +2562,7 @@ void cairo_stroke_extents (cairo_t *cr, double *x1, double *y1, double *x2, double *y2) { + CAIRO_TRACE_BEGIN (__func__); cairo_status_t status; if (unlikely (cr->status)) { @@ -2448,12 +2575,15 @@ cairo_stroke_extents (cairo_t *cr, if (y2) *y2 = 0.0; + CAIRO_TRACE_END (__func__); return; } status = cr->backend->stroke_extents (cr, x1, y1, x2, y2); if (unlikely (status)) _cairo_set_error (cr, status); + + CAIRO_TRACE_END (__func__); } /** @@ -2487,6 +2617,7 @@ void cairo_fill_extents (cairo_t *cr, double *x1, double *y1, double *x2, double *y2) { + CAIRO_TRACE_BEGIN (__func__); cairo_status_t status; if (unlikely (cr->status)) { @@ -2499,12 +2630,15 @@ cairo_fill_extents (cairo_t *cr, if (y2) *y2 = 0.0; + CAIRO_TRACE_END (__func__); return; } status = cr->backend->fill_extents (cr, x1, y1, x2, y2); if (unlikely (status)) _cairo_set_error (cr, status); + + CAIRO_TRACE_END (__func__); } /** @@ -2631,6 +2765,7 @@ cairo_clip_extents (cairo_t *cr, double *x1, double *y1, double *x2, double *y2) { + CAIRO_TRACE_BEGIN (__func__); cairo_status_t status; if (x1) @@ -2642,12 +2777,16 @@ cairo_clip_extents (cairo_t *cr, if (y2) *y2 = 0.0; - if (unlikely (cr->status)) + if (unlikely (cr->status)) { + CAIRO_TRACE_END (__func__); return; + } status = cr->backend->clip_extents (cr, x1, y1, x2, y2); if (unlikely (status)) _cairo_set_error (cr, status); + + CAIRO_TRACE_END (__func__); } /** @@ -3242,6 +3381,7 @@ cairo_glyph_extents (cairo_t *cr, void cairo_show_text (cairo_t *cr, const char *utf8) { + CAIRO_TRACE_BEGIN (__func__); cairo_text_extents_t extents; cairo_status_t status; cairo_glyph_t *glyphs, *last_glyph; @@ -3255,15 +3395,20 @@ cairo_show_text (cairo_t *cr, const char *utf8) cairo_scaled_font_t *scaled_font; cairo_glyph_text_info_t info, *i; - if (unlikely (cr->status)) + if (unlikely (cr->status)) { + CAIRO_TRACE_END (__func__); return; + } - if (utf8 == NULL) + if (utf8 == NULL) { + CAIRO_TRACE_END (__func__); return; + } scaled_font = cairo_get_scaled_font (cr); if (unlikely (scaled_font->status)) { _cairo_set_error (cr, scaled_font->status); + CAIRO_TRACE_END (__func__); return; } @@ -3293,8 +3438,10 @@ cairo_show_text (cairo_t *cr, const char *utf8) if (unlikely (status)) goto BAIL; - if (num_glyphs == 0) + if (num_glyphs == 0) { + CAIRO_TRACE_END (__func__); return; + } i = NULL; if (has_show_text_glyphs) { @@ -3327,6 +3474,8 @@ cairo_show_text (cairo_t *cr, const char *utf8) if (unlikely (status)) _cairo_set_error (cr, status); + + CAIRO_TRACE_END (__func__); } /** @@ -3344,27 +3493,36 @@ cairo_show_text (cairo_t *cr, const char *utf8) void cairo_show_glyphs (cairo_t *cr, const cairo_glyph_t *glyphs, int num_glyphs) { + CAIRO_TRACE_BEGIN (__func__); cairo_status_t status; - if (unlikely (cr->status)) + if (unlikely (cr->status)) { + CAIRO_TRACE_END (__func__); return; + } - if (num_glyphs == 0) + if (num_glyphs == 0) { + CAIRO_TRACE_END (__func__); return; + } if (num_glyphs < 0) { _cairo_set_error (cr, CAIRO_STATUS_NEGATIVE_COUNT); + CAIRO_TRACE_END (__func__); return; } if (glyphs == NULL) { _cairo_set_error (cr, CAIRO_STATUS_NULL_POINTER); + CAIRO_TRACE_END (__func__); return; } status = cr->backend->glyphs (cr, glyphs, num_glyphs, NULL); if (unlikely (status)) _cairo_set_error (cr, status); + + CAIRO_TRACE_END (__func__); } /** @@ -3411,10 +3569,13 @@ cairo_show_text_glyphs (cairo_t *cr, int num_clusters, cairo_text_cluster_flags_t cluster_flags) { + CAIRO_TRACE_BEGIN (__func__); cairo_status_t status; - if (unlikely (cr->status)) + if (unlikely (cr->status)) { + CAIRO_TRACE_END (__func__); return; + } /* A slew of sanity checks */ @@ -3427,6 +3588,7 @@ cairo_show_text_glyphs (cairo_t *cr, (utf8_len && utf8 == NULL) || (num_clusters && clusters == NULL)) { _cairo_set_error (cr, CAIRO_STATUS_NULL_POINTER); + CAIRO_TRACE_END (__func__); return; } @@ -3437,11 +3599,14 @@ cairo_show_text_glyphs (cairo_t *cr, /* Apart from that, no negatives */ if (num_glyphs < 0 || utf8_len < 0 || num_clusters < 0) { _cairo_set_error (cr, CAIRO_STATUS_NEGATIVE_COUNT); + CAIRO_TRACE_END (__func__); return; } - if (num_glyphs == 0 && utf8_len == 0) + if (num_glyphs == 0 && utf8_len == 0) { + CAIRO_TRACE_END (__func__); return; + } if (utf8) { /* Make sure clusters cover the entire glyphs and utf8 arrays, @@ -3474,6 +3639,8 @@ cairo_show_text_glyphs (cairo_t *cr, } if (unlikely (status)) _cairo_set_error (cr, status); + + CAIRO_TRACE_END (__func__); } /** @@ -3505,6 +3672,7 @@ cairo_show_text_glyphs (cairo_t *cr, void cairo_text_path (cairo_t *cr, const char *utf8) { + CAIRO_TRACE_BEGIN (__func__); cairo_status_t status; cairo_text_extents_t extents; cairo_glyph_t stack_glyphs[CAIRO_STACK_ARRAY_LENGTH (cairo_glyph_t)]; @@ -3513,11 +3681,15 @@ cairo_text_path (cairo_t *cr, const char *utf8) int num_glyphs; double x, y; - if (unlikely (cr->status)) + if (unlikely (cr->status)) { + CAIRO_TRACE_END (__func__); return; + } - if (utf8 == NULL) + if (utf8 == NULL) { + CAIRO_TRACE_END (__func__); return; + } glyphs = stack_glyphs; @@ -3526,6 +3698,7 @@ cairo_text_path (cairo_t *cr, const char *utf8) scaled_font = cairo_get_scaled_font (cr); if (unlikely (scaled_font->status)) { _cairo_set_error (cr, scaled_font->status); + CAIRO_TRACE_END (__func__); return; } @@ -3536,8 +3709,10 @@ cairo_text_path (cairo_t *cr, const char *utf8) &glyphs, &num_glyphs, NULL, NULL, NULL); - if (num_glyphs == 0) + if (num_glyphs == 0) { + CAIRO_TRACE_END (__func__); return; + } status = cr->backend->glyph_path (cr, glyphs, num_glyphs); @@ -3560,6 +3735,8 @@ cairo_text_path (cairo_t *cr, const char *utf8) if (unlikely (status)) _cairo_set_error (cr, status); + + CAIRO_TRACE_END (__func__); } /** @@ -3577,27 +3754,36 @@ cairo_text_path (cairo_t *cr, const char *utf8) void cairo_glyph_path (cairo_t *cr, const cairo_glyph_t *glyphs, int num_glyphs) { + CAIRO_TRACE_BEGIN (__func__); cairo_status_t status; - if (unlikely (cr->status)) + if (unlikely (cr->status)) { + CAIRO_TRACE_END (__func__); return; + } - if (num_glyphs == 0) + if (num_glyphs == 0) { + CAIRO_TRACE_END (__func__); return; + } if (unlikely (num_glyphs < 0)) { _cairo_set_error (cr, CAIRO_STATUS_NEGATIVE_COUNT); + CAIRO_TRACE_END (__func__); return; } if (unlikely (glyphs == NULL)) { _cairo_set_error (cr, CAIRO_STATUS_NULL_POINTER); + CAIRO_TRACE_END (__func__); return; } status = cr->backend->glyph_path (cr, glyphs, num_glyphs); if (unlikely (status)) _cairo_set_error (cr, status); + + CAIRO_TRACE_END (__func__); } /** |