From 04aed2c2db7cadb2ecde7de8d1b012a46bd151e8 Mon Sep 17 00:00:00 2001 From: Henry Song Date: Fri, 24 Jul 2015 22:52:05 -0700 Subject: [PATCH 01/16] gl: gradient texture edge pixel color adjust Change-Id: I13ca5ad468167896b4c043358df474a9ecc469c6 Signed-off-by: nisanthmp --- src/cairo-gl-gradient.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/cairo-gl-gradient.c b/src/cairo-gl-gradient.c index 2f8c725..b204b0b 100644 --- a/src/cairo-gl-gradient.c +++ b/src/cairo-gl-gradient.c @@ -182,8 +182,13 @@ _cairo_gl_gradient_render (const cairo_gl_context_t *ctx, * the neareset stop to the zeroth pixel centre in order to correctly * populate the border color. For completeness, do both edges. */ - ((uint32_t*)bytes)[0] = color_stop_to_pixel(&stops[0]); - ((uint32_t*)bytes)[width-1] = color_stop_to_pixel(&stops[n_stops-1]); + + /* This not needed as we have generated pixman pixels by using the + * half pixel from left and right border + */ + /* ((uint32_t*)bytes)[0] = color_stop_to_pixel(&stops[0]); + * ((uint32_t*)bytes)[width-1] = color_stop_to_pixel(&stops[n_stops-1]); + */ return CAIRO_STATUS_SUCCESS; } -- 2.7.4 From aed520904a01bff1ed1b84a45704d741b3fb0cc7 Mon Sep 17 00:00:00 2001 From: "hk57.kim" Date: Wed, 5 Aug 2015 08:46:24 +0900 Subject: [PATCH 02/16] [Cairo][Protex issue: fix build spec Change-Id: I55d1e02c12eb9fba700ae4f0f6786e4adc4477db Signed-off-by: hk57.kim --- packaging/cairo.spec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packaging/cairo.spec b/packaging/cairo.spec index e25c15d..3ca995e 100644 --- a/packaging/cairo.spec +++ b/packaging/cairo.spec @@ -9,7 +9,7 @@ Name: cairo #Version: 1.12.16 Version: 1.14.2 Release: 0 -License: LGPL-2.1+ or MPL-1.1 +License: MPL-1.1 or LGPL-2.1+ Summary: Vector Graphics Library with Cross-Device Output Support Url: http://cairographics.org/ Group: Graphics/Libraries @@ -112,7 +112,7 @@ hardware acceleration when available. This package contains various cairo utilities. %package devel -License: LGPL-2.1+ or MPL-1.1 +License: MPL-1.1 or LGPL-2.1+ Summary: Development environment for cairo Group: Development/Libraries Requires: libcairo = %{version} -- 2.7.4 From 5d640eb45902df1de66f158bb7a0f02ac05681f8 Mon Sep 17 00:00:00 2001 From: "mh0310.choi" Date: Wed, 26 Aug 2015 16:06:31 +0900 Subject: [PATCH 03/16] Prevent:ID-275424 (Dereference null return value) Null check for clip Change-Id: I83be56637cd3e3df3942bf5c70b8c93ede483559 --- src/cairo-xcb-surface-render.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/cairo-xcb-surface-render.c b/src/cairo-xcb-surface-render.c index eec45c7..8cf0a34 100644 --- a/src/cairo-xcb-surface-render.c +++ b/src/cairo-xcb-surface-render.c @@ -3638,6 +3638,9 @@ _cairo_xcb_render_compositor_paint (const cairo_compositor_t *compositor, return CAIRO_STATUS_SUCCESS; } + if (composite->clip == NULL) + return CAIRO_STATUS_NULL_POINTER; + _cairo_clip_steal_boxes(composite->clip, &boxes); status = _clip_and_composite_boxes (surface, op, source, &boxes, composite); _cairo_clip_unsteal_boxes (composite->clip, &boxes); -- 2.7.4 From ca3e6d75aaf63e5f77bc31975d77a20cbc5407ca Mon Sep 17 00:00:00 2001 From: "hk57.kim" Date: Mon, 14 Dec 2015 14:15:10 +0900 Subject: [PATCH 04/16] [Fix cairo.spec to disable backends(ps,pdf,script,svg,tee)] Change-Id: Ib502908920732182c44031ebe6ea1d88da81c3b8 Signed-off-by: hk57.kim --- packaging/cairo.spec | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packaging/cairo.spec b/packaging/cairo.spec index 3ca995e..2cf96ec 100644 --- a/packaging/cairo.spec +++ b/packaging/cairo.spec @@ -153,11 +153,11 @@ NOCONFIGURE=1 ./autogen.sh --enable-glesv2=yes \ --enable-evasgl=yes \ %endif - --enable-ps \ - --enable-pdf \ - --enable-script \ - --enable-svg \ - --enable-tee \ + --enable-ps=no \ + --enable-pdf=no \ + --enable-script=no \ + --enable-svg=no \ + --enable-tee=no \ %if %{with wayland} && !%{with x} --disable-xlib \ --disable-xcb \ -- 2.7.4 From 629101d0a6e2af32727ca0b14acaceddb0897e6c Mon Sep 17 00:00:00 2001 From: nisanthmp Date: Wed, 2 Dec 2015 12:57:34 +0530 Subject: [PATCH 05/16] Pattern/GL: Avoid texture creation for radial gradients with 2 color stops When there are only two color stops in the gradient, we can avoid creating textures before hand, and directly calculate the gradient color in the fragment shader. This speeds up gradient pattern rendering. Change-Id: I758b7bc8f37293edbe546fcc4a55f71a7f3c55ae Signed-off-by: nisanthmp --- src/cairo-gl-gradient-private.h | 3 +- src/cairo-gl-gradient.c | 61 +++---- src/cairo-gl-operand.c | 30 +++- src/cairo-gl-private.h | 12 ++ src/cairo-gl-shaders.c | 352 +++++++++++++++++++++++++++++++++++++++- 5 files changed, 423 insertions(+), 35 deletions(-) diff --git a/src/cairo-gl-gradient-private.h b/src/cairo-gl-gradient-private.h index d66f3dc..8d95f70 100644 --- a/src/cairo-gl-gradient-private.h +++ b/src/cairo-gl-gradient-private.h @@ -94,7 +94,8 @@ cairo_private cairo_int_status_t _cairo_gl_gradient_create (cairo_gl_context_t *ctx, unsigned int n_stops, const cairo_gradient_stop_t *stops, - cairo_gl_gradient_t **gradient_out); + cairo_gl_gradient_t **gradient_out, + cairo_pattern_type_t pat_type); cairo_private_no_warn cairo_gl_gradient_t * _cairo_gl_gradient_reference (cairo_gl_gradient_t *gradient); diff --git a/src/cairo-gl-gradient.c b/src/cairo-gl-gradient.c index b204b0b..a6084ce 100644 --- a/src/cairo-gl-gradient.c +++ b/src/cairo-gl-gradient.c @@ -233,7 +233,8 @@ cairo_int_status_t _cairo_gl_gradient_create (cairo_gl_context_t *ctx, unsigned int n_stops, const cairo_gradient_stop_t *stops, - cairo_gl_gradient_t **gradient_out) + cairo_gl_gradient_t **gradient_out, + cairo_pattern_type_t pat_type) { unsigned long hash; cairo_gl_gradient_t *gradient; @@ -269,36 +270,38 @@ _cairo_gl_gradient_create (cairo_gl_context_t *ctx, gradient->stops = gradient->stops_embedded; memcpy (gradient->stops_embedded, stops, n_stops * sizeof (cairo_gradient_stop_t)); - ctx->dispatch.GenTextures (1, &gradient->tex); - _cairo_gl_context_activate (ctx, CAIRO_GL_TEX_TEMP); - ctx->dispatch.BindTexture (ctx->tex_target, gradient->tex); - - data = _cairo_malloc_ab (tex_width, sizeof (uint32_t)); - if (unlikely (data == NULL)) { - status = _cairo_error (CAIRO_STATUS_NO_MEMORY); - goto cleanup_gradient; + if (pat_type != CAIRO_PATTERN_TYPE_RADIAL || n_stops != 2) { + ctx->dispatch.GenTextures (1, &gradient->tex); + _cairo_gl_context_activate (ctx, CAIRO_GL_TEX_TEMP); + ctx->dispatch.BindTexture (ctx->tex_target, gradient->tex); + + data = _cairo_malloc_ab (tex_width, sizeof (uint32_t)); + if (unlikely (data == NULL)) { + status = _cairo_error (CAIRO_STATUS_NO_MEMORY); + goto cleanup_gradient; + } + + status = _cairo_gl_gradient_render (ctx, n_stops, stops, data, tex_width); + if (unlikely (status)) + goto cleanup_data; + + /* + * In OpenGL ES 2.0 no format conversion is allowed i.e. 'internalFormat' + * must match 'format' in glTexImage2D. + */ + if (_cairo_gl_get_flavor (&ctx->dispatch) == CAIRO_GL_FLAVOR_ES2 || + _cairo_gl_get_flavor (&ctx->dispatch) == CAIRO_GL_FLAVOR_ES3) + internal_format = GL_BGRA; + else + internal_format = GL_RGBA; + + ctx->dispatch.TexImage2D (ctx->tex_target, 0, internal_format, + tex_width, 1, 0, + GL_BGRA, GL_UNSIGNED_BYTE, data); + + free (data); } - status = _cairo_gl_gradient_render (ctx, n_stops, stops, data, tex_width); - if (unlikely (status)) - goto cleanup_data; - - /* - * In OpenGL ES 2.0 no format conversion is allowed i.e. 'internalFormat' - * must match 'format' in glTexImage2D. - */ - if (_cairo_gl_get_flavor (&ctx->dispatch) == CAIRO_GL_FLAVOR_ES2 || - _cairo_gl_get_flavor (&ctx->dispatch) == CAIRO_GL_FLAVOR_ES3) - internal_format = GL_BGRA; - else - internal_format = GL_RGBA; - - ctx->dispatch.TexImage2D (ctx->tex_target, 0, internal_format, - tex_width, 1, 0, - GL_BGRA, GL_UNSIGNED_BYTE, data); - - free (data); - /* we ignore errors here and just return an uncached gradient */ if (unlikely (_cairo_cache_insert (&ctx->gradients, &gradient->cache_entry))) CAIRO_REFERENCE_COUNT_INIT (&gradient->ref_count, 1); diff --git a/src/cairo-gl-operand.c b/src/cairo-gl-operand.c index 2bbd99b..443d06a 100644 --- a/src/cairo-gl-operand.c +++ b/src/cairo-gl-operand.c @@ -65,7 +65,7 @@ _cairo_gl_create_gradient_texture (cairo_gl_surface_t *dst, if (unlikely (status)) return status; - status = _cairo_gl_gradient_create (ctx, pattern->n_stops, pattern->stops, gradient); + status = _cairo_gl_gradient_create (ctx, pattern->n_stops, pattern->stops, gradient, pattern->base.type); return _cairo_gl_context_release (ctx, status); } @@ -1206,6 +1206,7 @@ _cairo_gl_operand_bind_to_shader (cairo_gl_context_t *ctx, case CAIRO_GL_OPERAND_RADIAL_GRADIENT_NONE: case CAIRO_GL_OPERAND_RADIAL_GRADIENT_EXT: + _cairo_gl_shader_bind_float (ctx, ctx->current_shader->a_location[tex_unit], operand->gradient.a); @@ -1219,6 +1220,28 @@ _cairo_gl_operand_bind_to_shader (cairo_gl_context_t *ctx, _cairo_gl_shader_bind_float (ctx, ctx->current_shader->radius_0_location[tex_unit], operand->gradient.radius_0); + if (operand->gradient.gradient->n_stops == 2) { + _cairo_gl_shader_bind_vec4 (ctx, + ctx->current_shader->color_1_location[tex_unit], + operand->gradient.gradient->stops[0].color.red, + operand->gradient.gradient->stops[0].color.green, + operand->gradient.gradient->stops[0].color.blue, + operand->gradient.gradient->stops[0].color.alpha); + + _cairo_gl_shader_bind_vec4 (ctx, + ctx->current_shader->color_2_location[tex_unit], + operand->gradient.gradient->stops[1].color.red, + operand->gradient.gradient->stops[1].color.green, + operand->gradient.gradient->stops[1].color.blue, + operand->gradient.gradient->stops[1].color.alpha); + + _cairo_gl_shader_bind_float (ctx, + ctx->current_shader->offset_1_location[tex_unit], + operand->gradient.gradient->stops[0].offset); + _cairo_gl_shader_bind_float (ctx, + ctx->current_shader->offset_2_location[tex_unit], + operand->gradient.gradient->stops[1].offset); + } /* fall through */ case CAIRO_GL_OPERAND_LINEAR_GRADIENT: case CAIRO_GL_OPERAND_TEXTURE: @@ -1311,10 +1334,10 @@ _cairo_gl_operand_bind_to_shader (cairo_gl_context_t *ctx, if (operand->type == CAIRO_GL_OPERAND_TEXTURE || operand->type == CAIRO_GL_OPERAND_GAUSSIAN) { if (operand->texture.texgen) - texgen = &operand->texture.attributes.matrix; + texgen = &operand->texture.attributes.matrix; } else { if (operand->gradient.texgen) - texgen = &operand->gradient.m; + texgen = &operand->gradient.m; } if (texgen) { _cairo_gl_shader_bind_matrix(ctx, @@ -1427,7 +1450,6 @@ _cairo_gl_operand_emit (cairo_gl_operand_t *operand, double t = y; cairo_matrix_transform_point (&operand->gradient.m, &s, &t); - *(*vb)++ = s; *(*vb)++ = t; } diff --git a/src/cairo-gl-private.h b/src/cairo-gl-private.h index e5a709e..2c534fc 100644 --- a/src/cairo-gl-private.h +++ b/src/cairo-gl-private.h @@ -165,6 +165,10 @@ typedef enum cairo_gl_uniform_t { CAIRO_GL_UNIFORM_BLUR_X_AXIS, /* "source_blur_x_axis" */ CAIRO_GL_UNIFORM_BLUR_Y_AXIS, /* "source_blur_y_axis" */ CAIRO_GL_UNIFORM_ALPHA, /* "source_alpha */ + CAIRO_GL_UNIFORM_COLOR_1, /* "source_color_1 */ + CAIRO_GL_UNIFORM_COLOR_2, /* "source_color_2 */ + CAIRO_GL_UNIFORM_OFFSET_1, /* "source_offset_1 */ + CAIRO_GL_UNIFORM_OFFSET_2, /* "source_offset_2 */ CAIRO_GL_UNIFORM_MASK_TEXDIMS, /* "mask_texdims" */ CAIRO_GL_UNIFORM_MASK_TEXGEN, /* "mask_texgen" */ @@ -179,6 +183,10 @@ typedef enum cairo_gl_uniform_t { CAIRO_GL_UNIFORM_MASK_BLUR_X_AXIS, /* "mask_blur_x_axis" */ CAIRO_GL_UNIFORM_MASK_BLUR_Y_AXIS, /* "mask_blur_y_axis" */ CAIRO_GL_UNIFORM_MASK_ALPHA, /* "mask_alpha" */ + CAIRO_GL_UNIFORM_MASK_COLOR_1, /* "mask_color_1" */ + CAIRO_GL_UNIFORM_MASK_COLOR_2, /* "mask_color_2" */ + CAIRO_GL_UNIFORM_MASK_OFFSET_1, /* "mask_offset_1 */ + CAIRO_GL_UNIFORM_MASK_OFFSET_2, /* "mask_offset_2 */ CAIRO_GL_UNIFORM_PROJECTION_MATRIX, /* "ModelViewProjectionMatrix" */ @@ -330,6 +338,10 @@ typedef struct cairo_gl_shader { GLint blur_x_axis_location[2]; GLint blur_y_axis_location[2]; GLint alpha_location[2]; + GLint color_1_location[2]; + GLint color_2_location[2]; + GLint offset_1_location[2]; + GLint offset_2_location[2]; } cairo_gl_shader_t; typedef struct _cairo_gl_image_cache { diff --git a/src/cairo-gl-shaders.c b/src/cairo-gl-shaders.c index 7d7b669..623f8d6 100644 --- a/src/cairo-gl-shaders.c +++ b/src/cairo-gl-shaders.c @@ -551,7 +551,6 @@ cairo_gl_shader_get_vertex_source (cairo_gl_var_type_t src, status = _cairo_memory_stream_destroy (stream, &source, &length); if (unlikely (status)) return status; - *out = (char *) source; return CAIRO_STATUS_SUCCESS; } @@ -791,6 +790,7 @@ cairo_gl_shader_emit_color (cairo_output_stream_t *stream, } break; case CAIRO_GL_OPERAND_RADIAL_GRADIENT_A0: + if (op->gradient.gradient->n_stops != 2) { if (needs_glsl330 == CAIRO_GLSL_VERSION_330) { _cairo_output_stream_printf (stream, "in vec2 %s_texcoords;\n" @@ -850,8 +850,116 @@ cairo_gl_shader_emit_color (cairo_output_stream_t *stream, "}\n", textstr, rectstr, namestr, namestr); } + } else { // else of if (op->gradient.gradient->n_stops != 2) + if (needs_glsl330 == CAIRO_GLSL_VERSION_330) { + _cairo_output_stream_printf (stream, + "in vec2 %s_texcoords;\n" + "uniform vec2 %s_texdims;\n" + "uniform sampler2D%s %s_sampler;\n" + "uniform vec3 %s_circle_d;\n" + "uniform float %s_radius_0;\n" +//two_color_mod +#if 1 + "uniform vec4 %s_color_1;\n" + "uniform vec4 %s_color_2;\n" + "uniform float %s_offset_1;\n" + "uniform float %s_offset_2;\n" +#endif + "\n" + "vec4 get_%s()\n" + "{\n" + " vec3 pos = vec3 (%s_texcoords, %s_radius_0);\n" + " \n" + " float B = dot (pos, %s_circle_d);\n" + " float C = dot (pos, vec3 (pos.xy, -pos.z));\n" + " \n" + " float t = 0.5 * C / B;\n" + " float is_valid = step (-%s_radius_0, t * %s_circle_d.z);\n", + namestr, namestr, rectstr, namestr, namestr, namestr, namestr, + namestr, namestr, namestr, namestr, + namestr, namestr, namestr, namestr, namestr); + } else { + _cairo_output_stream_printf (stream, + "varying vec2 %s_texcoords;\n" + "uniform vec2 %s_texdims;\n" + "uniform sampler2D%s %s_sampler;\n" + "uniform vec3 %s_circle_d;\n" + "uniform float %s_radius_0;\n" +//two_color_mod +#if 1 + "uniform vec4 %s_color_1;\n" + "uniform vec4 %s_color_2;\n" + "uniform float %s_offset_1;\n" + "uniform float %s_offset_2;\n" +#endif + "\n" + "vec4 get_%s()\n" + "{\n" + " vec3 pos = vec3 (%s_texcoords, %s_radius_0);\n" + " \n" + " float B = dot (pos, %s_circle_d);\n" + " float C = dot (pos, vec3 (pos.xy, -pos.z));\n" + " \n" + " float t = 0.5 * C / B;\n" + " float is_valid = step (-%s_radius_0, t * %s_circle_d.z);\n", + namestr, namestr, rectstr, namestr, namestr, namestr, namestr, + namestr, namestr, namestr, namestr, + namestr, namestr, namestr, namestr, namestr); + } + + if ((ctx->gl_flavor == CAIRO_GL_FLAVOR_ES2 || + ctx->gl_flavor == CAIRO_GL_FLAVOR_ES3) && + _cairo_gl_shader_needs_border_fade (op)) + { + _cairo_output_stream_printf (stream, + " float border_fade = %s_border_fade (t, %s_texdims.x);\n" + //" vec4 texel = texture%s%s (%s_sampler, vec2 (t, 0.5));\n" +//two_color_mod + " vec4 texel;\n" + " float scale;\n" + " float factor;\n" + " if (t <= %s_offset_1) {\n" + " texel = %s_color_1;\n" + " } else if (t >= %s_offset_2) {\n" + " texel = %s_color_2;\n" + " } else {\n" + " scale = %s_offset_2 - %s_offset_1;\n" + " factor = (t - %s_offset_1)/scale;\n" + " texel = mix (%s_color_1, %s_color_2, factor);\n" + " }\n" + " return mix (vec4 (0.0), texel * border_fade, is_valid);\n" + "}\n", + namestr, namestr, namestr, namestr, namestr, namestr, + namestr, namestr, namestr, namestr, namestr); + } + else + { + _cairo_output_stream_printf (stream, + //" vec4 texel = texture%s%s (%s_sampler, %s_wrap (vec2 (t, 0.5)));\n" +//two_color_mod + " vec4 texel;\n" + " float scale;\n" + " float factor;\n" + " float upper_t = (vec2(%s_wrap (vec2 (t, 0.5)))).x;\n" + " if (upper_t <= %s_offset_1) {\n" + " texel = %s_color_1;\n" + " } else if (upper_t >= %s_offset_2) {\n" + " texel = %s_color_2;\n" + " } else {\n" + " scale = %s_offset_2 - %s_offset_1;\n" + " factor = (upper_t - %s_offset_1)/scale;\n" + " texel = mix (%s_color_1, %s_color_2, factor);\n" + " }\n" + " return mix (vec4 (0.0), texel, is_valid);\n" + "}\n", + namestr, namestr, namestr, namestr, namestr, + namestr, namestr, namestr, namestr, namestr); + } + + } //end of if (op->gradient.gradient->n_stops != 2) break; case CAIRO_GL_OPERAND_RADIAL_GRADIENT_NONE: + if (op->gradient.gradient->n_stops != 2) { if (needs_glsl330 == CAIRO_GLSL_VERSION_330) { _cairo_output_stream_printf (stream, "in vec2 %s_texcoords;\n" @@ -925,8 +1033,130 @@ cairo_gl_shader_emit_color (cairo_output_stream_t *stream, "}\n", textstr, rectstr, namestr, namestr); } + } else { //else of if (op->gradient.gradient->n_stops != 2) + if (needs_glsl330 == CAIRO_GLSL_VERSION_330) { + _cairo_output_stream_printf (stream, + "in vec2 %s_texcoords;\n" + "uniform vec2 %s_texdims;\n" + "uniform sampler2D%s %s_sampler;\n" + "uniform vec3 %s_circle_d;\n" + "uniform float %s_a;\n" + "uniform float %s_radius_0;\n" +//two_color_mod +#if 1 + "uniform vec4 %s_color_1;\n" + "uniform vec4 %s_color_2;\n" + "uniform float %s_offset_1;\n" + "uniform float %s_offset_2;\n" +#endif + "\n" + "vec4 get_%s()\n" + "{\n" + " vec3 pos = vec3 (%s_texcoords, %s_radius_0);\n" + " \n" + " float B = dot (pos, %s_circle_d);\n" + " float C = dot (pos, vec3 (pos.xy, -pos.z));\n" + " \n" + " float det = dot (vec2 (B, %s_a), vec2 (B, -C));\n" + " float sqrtdet = sqrt (abs (det));\n" + " vec2 t = (B + vec2 (sqrtdet, -sqrtdet)) / %s_a;\n" + " \n" + " vec2 is_valid = step (vec2 (0.0), t) * step (t, vec2(1.0));\n" + " float has_color = step (0., det) * max (is_valid.x, is_valid.y);\n" + " \n" + " float upper_t = mix (t.y, t.x, is_valid.x);\n", + namestr, namestr, rectstr, namestr, namestr, namestr, namestr, + namestr, namestr, namestr, namestr, + namestr, namestr, namestr, namestr, namestr, namestr); + } else { + _cairo_output_stream_printf (stream, + "varying vec2 %s_texcoords;\n" + "uniform vec2 %s_texdims;\n" + "uniform sampler2D%s %s_sampler;\n" + "uniform vec3 %s_circle_d;\n" + "uniform float %s_a;\n" + "uniform float %s_radius_0;\n" +//two_color_mod +#if 1 + "uniform vec4 %s_color_1;\n" + "uniform vec4 %s_color_2;\n" + "uniform float %s_offset_1;\n" + "uniform float %s_offset_2;\n" +#endif + "\n" + "vec4 get_%s()\n" + "{\n" + " vec3 pos = vec3 (%s_texcoords, %s_radius_0);\n" + " \n" + " float B = dot (pos, %s_circle_d);\n" + " float C = dot (pos, vec3 (pos.xy, -pos.z));\n" + " \n" + " float det = dot (vec2 (B, %s_a), vec2 (B, -C));\n" + " float sqrtdet = sqrt (abs (det));\n" + " vec2 t = (B + vec2 (sqrtdet, -sqrtdet)) / %s_a;\n" + " \n" + " vec2 is_valid = step (vec2 (0.0), t) * step (t, vec2(1.0));\n" + " float has_color = step (0., det) * max (is_valid.x, is_valid.y);\n" + " \n" + " float upper_t = mix (t.y, t.x, is_valid.x);\n", + namestr, namestr, rectstr, namestr, namestr, namestr, namestr, + namestr, namestr, namestr, namestr, + namestr, namestr, namestr, namestr, namestr, namestr); + } + + if ((ctx->gl_flavor == CAIRO_GL_FLAVOR_ES2 || + ctx->gl_flavor == CAIRO_GL_FLAVOR_ES3) && + _cairo_gl_shader_needs_border_fade (op)) + { + _cairo_output_stream_printf (stream, + " float border_fade = %s_border_fade (upper_t, %s_texdims.x);\n" + //" vec4 texel = texture%s%s (%s_sampler, vec2 (upper_t, 0.5));\n" +//two_color_mod + " vec4 texel;\n" + " float scale;\n" + " float factor;\n" + " if (upper_t <= %s_offset_1) {\n" + " texel = %s_color_1;\n" + " } else if (upper_t >= %s_offset_2) {\n" + " texel = %s_color_2;\n" + " } else {\n" + " scale = %s_offset_2 - %s_offset_1;\n" + " factor = (upper_t - %s_offset_1)/scale;\n" + " texel = mix (%s_color_1, %s_color_2, factor);\n" + " }\n" + " return mix (vec4 (0.0), texel * border_fade, has_color);\n" + "}\n", + namestr, namestr, namestr, namestr, namestr, namestr, + namestr, namestr, namestr, namestr, namestr); + } + else + { + _cairo_output_stream_printf (stream, + //" vec4 texel = texture%s%s (%s_sampler, %s_wrap (vec2(upper_t, 0.5)));\n" +//two_color_mod + " vec4 texel;\n" + " float scale;\n" + " float factor;\n" + " float upper_tw = (vec2(%s_wrap (vec2(upper_t, 0.5)))).x;\n" + " if (upper_tw <= %s_offset_1) {\n" + " texel = %s_color_1;\n" + " } else if (upper_tw >= %s_offset_2) {\n" + " texel = %s_color_2;\n" + " } else {\n" + " scale = %s_offset_2 - %s_offset_1;\n" + " factor = (upper_tw - %s_offset_1)/scale;\n" + " texel = mix (%s_color_1, %s_color_2, factor);\n" + " }\n" + " return mix (vec4 (0.0), texel, has_color);\n" + "}\n", + namestr, namestr, namestr, namestr, namestr, + namestr, namestr, namestr, namestr, namestr); + } + + } //end of if (op->gradient.gradient->n_stops != 2) break; case CAIRO_GL_OPERAND_RADIAL_GRADIENT_EXT: + if (op->gradient.gradient->n_stops != 2) { if (needs_glsl330 == CAIRO_GLSL_VERSION_330) { _cairo_output_stream_printf (stream, "in vec2 %s_texcoords;\n" @@ -982,10 +1212,119 @@ cairo_gl_shader_emit_color (cairo_output_stream_t *stream, " vec4 texel = texture%s%s (%s_sampler, %s_wrap (vec2(upper_t, 0.5)));\n" " return mix (vec4 (0.0), texel, has_color);\n" "}\n", + namestr, rectstr, namestr, namestr, namestr, namestr, namestr, namestr, namestr, namestr, namestr, namestr, namestr, namestr, textstr, rectstr, namestr, namestr); } + } else { //else of if (op->gradient.gradient->n_stops != 2) + if (needs_glsl330 == CAIRO_GLSL_VERSION_330) { + _cairo_output_stream_printf (stream, + "in vec2 %s_texcoords;\n" + "uniform sampler2D%s %s_sampler;\n" + "uniform vec3 %s_circle_d;\n" + "uniform float %s_a;\n" + "uniform float %s_radius_0;\n" +//two_color_mod +#if 1 + "uniform vec4 %s_color_1;\n" + "uniform vec4 %s_color_2;\n" + "uniform float %s_offset_1;\n" + "uniform float %s_offset_2;\n" +#endif + "\n" + "vec4 get_%s()\n" + "{\n" + " vec3 pos = vec3 (%s_texcoords, %s_radius_0);\n" + " \n" + " float B = dot (pos, %s_circle_d);\n" + " float C = dot (pos, vec3 (pos.xy, -pos.z));\n" + " \n" + " float det = dot (vec2 (B, %s_a), vec2 (B, -C));\n" + " float sqrtdet = sqrt (abs (det));\n" + " vec2 t = (B + vec2 (sqrtdet, -sqrtdet)) / %s_a;\n" + " \n" + " vec2 is_valid = step (vec2 (-%s_radius_0), t * %s_circle_d.z);\n" + " float has_color = step (0., det) * max (is_valid.x, is_valid.y);\n" + " \n" + " float upper_t = mix (t.y, t.x, is_valid.x);\n" +//two_color_mod + " vec4 texel;\n" + " float scale;\n" + " float factor;\n" + " float upper_tw = (vec2(%s_wrap (vec2(upper_t, 0.5)))).x;\n" + " if (upper_tw <= %s_offset_1) {\n" + " texel = %s_color_1;\n" + " } else if (upper_tw >= %s_offset_2) {\n" + " texel = %s_color_2;\n" + " } else {\n" + " scale = %s_offset_2 - %s_offset_1;\n" + " factor = (upper_tw - %s_offset_1)/scale;\n" + " texel = mix (%s_color_1, %s_color_2, factor);\n" + " }\n" + " return mix (vec4 (0.0), texel, has_color);\n" + "}\n", + namestr, rectstr, namestr, namestr, namestr, namestr, + namestr, namestr, namestr, namestr, + namestr, namestr, namestr, namestr, namestr, + namestr, namestr, namestr, + namestr, namestr, namestr, namestr, namestr, namestr, namestr, + namestr, namestr, namestr); + } else { + _cairo_output_stream_printf (stream, + "varying vec2 %s_texcoords;\n" + "uniform sampler2D%s %s_sampler;\n" + "uniform vec3 %s_circle_d;\n" + "uniform float %s_a;\n" + "uniform float %s_radius_0;\n" +//two_color_mod +#if 1 + "uniform vec4 %s_color_1;\n" + "uniform vec4 %s_color_2;\n" + "uniform float %s_offset_1;\n" + "uniform float %s_offset_2;\n" +#endif + "\n" + "vec4 get_%s()\n" + "{\n" + " vec3 pos = vec3 (%s_texcoords, %s_radius_0);\n" + " \n" + " float B = dot (pos, %s_circle_d);\n" + " float C = dot (pos, vec3 (pos.xy, -pos.z));\n" + " \n" + " float det = dot (vec2 (B, %s_a), vec2 (B, -C));\n" + " float sqrtdet = sqrt (abs (det));\n" + " vec2 t = (B + vec2 (sqrtdet, -sqrtdet)) / %s_a;\n" + " \n" + " vec2 is_valid = step (vec2 (-%s_radius_0), t * %s_circle_d.z);\n" + " float has_color = step (0., det) * max (is_valid.x, is_valid.y);\n" + " \n" + " float upper_t = mix (t.y, t.x, is_valid.x);\n" +//two_color_mod + " vec4 texel;\n" + " float scale;\n" + " float factor;\n" + " float upper_tw = (vec2(%s_wrap (vec2(upper_t, 0.5)))).x;\n" + " if (upper_tw <= %s_offset_1) {\n" + " texel = %s_color_1;\n" + " } else if (upper_tw >= %s_offset_2) {\n" + " texel = %s_color_2;\n" + " } else {\n" + " scale = %s_offset_2 - %s_offset_1;\n" + " factor = (upper_tw - %s_offset_1)/scale;\n" + " texel = mix (%s_color_1, %s_color_2, factor);\n" + " }\n" + " return mix (vec4 (0.0), texel, has_color);\n" + "}\n", + namestr, rectstr, namestr, namestr, namestr, namestr, + namestr, namestr, namestr, namestr, + namestr, namestr, namestr, namestr, namestr, + namestr, namestr, namestr, + namestr, namestr, namestr, namestr, namestr, namestr, namestr, + namestr, namestr, namestr); + } + + } // end of if (op->gradient.gradient->n_stops != 2) break; } } @@ -1435,6 +1774,16 @@ _cairo_gl_shader_compile_and_link (cairo_gl_context_t *ctx, _cairo_gl_get_op_uniform_location (ctx, shader, i, "blur_y_axis"); shader->alpha_location[i] = _cairo_gl_get_op_uniform_location (ctx, shader, i, "alpha"); + +//two_color_mod + shader->color_1_location[i] = + _cairo_gl_get_op_uniform_location (ctx, shader, i, "color_1"); + shader->color_2_location[i] = + _cairo_gl_get_op_uniform_location (ctx, shader, i, "color_2"); + shader->offset_1_location[i] = + _cairo_gl_get_op_uniform_location (ctx, shader, i, "offset_1"); + shader->offset_2_location[i] = + _cairo_gl_get_op_uniform_location (ctx, shader, i, "offset_2"); } return CAIRO_STATUS_SUCCESS; @@ -1539,6 +1888,7 @@ _cairo_gl_shader_bind_vec4 (cairo_gl_context_t *ctx, float value2, float value3) { cairo_gl_dispatch_t *dispatch = &ctx->dispatch; + assert (location != -1); dispatch->Uniform4f (location, value0, value1, value2, value3); } -- 2.7.4 From 35254423f4ca6aa94f9f264b60fb09a5c58e8ae6 Mon Sep 17 00:00:00 2001 From: nisanthmp Date: Fri, 18 Dec 2015 11:30:06 +0530 Subject: [PATCH 06/16] Pattern/GL: Two Color Stops optimization for linear gradients. Also 1) Updated shader cache lookup code to include 2 stops case. 2) 2 stop opt code now supports repeat and reflect patterns. 3) texel R,G and B values are now pre-multiplied by alpha. Change-Id: I053a074660635fc362a8ae37f2782009ef08f125 Signed-off-by: nisanthmp --- src/cairo-gl-gradient-private.h | 3 +- src/cairo-gl-gradient.c | 5 +- src/cairo-gl-operand.c | 5 +- src/cairo-gl-shaders.c | 159 +++++++++++++++++++++++++++++++--------- 4 files changed, 132 insertions(+), 40 deletions(-) diff --git a/src/cairo-gl-gradient-private.h b/src/cairo-gl-gradient-private.h index 8d95f70..d66f3dc 100644 --- a/src/cairo-gl-gradient-private.h +++ b/src/cairo-gl-gradient-private.h @@ -94,8 +94,7 @@ cairo_private cairo_int_status_t _cairo_gl_gradient_create (cairo_gl_context_t *ctx, unsigned int n_stops, const cairo_gradient_stop_t *stops, - cairo_gl_gradient_t **gradient_out, - cairo_pattern_type_t pat_type); + cairo_gl_gradient_t **gradient_out); cairo_private_no_warn cairo_gl_gradient_t * _cairo_gl_gradient_reference (cairo_gl_gradient_t *gradient); diff --git a/src/cairo-gl-gradient.c b/src/cairo-gl-gradient.c index a6084ce..325612b 100644 --- a/src/cairo-gl-gradient.c +++ b/src/cairo-gl-gradient.c @@ -233,8 +233,7 @@ cairo_int_status_t _cairo_gl_gradient_create (cairo_gl_context_t *ctx, unsigned int n_stops, const cairo_gradient_stop_t *stops, - cairo_gl_gradient_t **gradient_out, - cairo_pattern_type_t pat_type) + cairo_gl_gradient_t **gradient_out) { unsigned long hash; cairo_gl_gradient_t *gradient; @@ -270,7 +269,7 @@ _cairo_gl_gradient_create (cairo_gl_context_t *ctx, gradient->stops = gradient->stops_embedded; memcpy (gradient->stops_embedded, stops, n_stops * sizeof (cairo_gradient_stop_t)); - if (pat_type != CAIRO_PATTERN_TYPE_RADIAL || n_stops != 2) { + if (n_stops != 2) { ctx->dispatch.GenTextures (1, &gradient->tex); _cairo_gl_context_activate (ctx, CAIRO_GL_TEX_TEMP); ctx->dispatch.BindTexture (ctx->tex_target, gradient->tex); diff --git a/src/cairo-gl-operand.c b/src/cairo-gl-operand.c index 443d06a..575096a 100644 --- a/src/cairo-gl-operand.c +++ b/src/cairo-gl-operand.c @@ -65,7 +65,7 @@ _cairo_gl_create_gradient_texture (cairo_gl_surface_t *dst, if (unlikely (status)) return status; - status = _cairo_gl_gradient_create (ctx, pattern->n_stops, pattern->stops, gradient, pattern->base.type); + status = _cairo_gl_gradient_create (ctx, pattern->n_stops, pattern->stops, gradient); return _cairo_gl_context_release (ctx, status); } @@ -1220,6 +1220,8 @@ _cairo_gl_operand_bind_to_shader (cairo_gl_context_t *ctx, _cairo_gl_shader_bind_float (ctx, ctx->current_shader->radius_0_location[tex_unit], operand->gradient.radius_0); + /* fall through */ + case CAIRO_GL_OPERAND_LINEAR_GRADIENT: if (operand->gradient.gradient->n_stops == 2) { _cairo_gl_shader_bind_vec4 (ctx, ctx->current_shader->color_1_location[tex_unit], @@ -1243,7 +1245,6 @@ _cairo_gl_operand_bind_to_shader (cairo_gl_context_t *ctx, operand->gradient.gradient->stops[1].offset); } /* fall through */ - case CAIRO_GL_OPERAND_LINEAR_GRADIENT: case CAIRO_GL_OPERAND_TEXTURE: case CAIRO_GL_OPERAND_GAUSSIAN: /* diff --git a/src/cairo-gl-shaders.c b/src/cairo-gl-shaders.c index 623f8d6..b5796f7 100644 --- a/src/cairo-gl-shaders.c +++ b/src/cairo-gl-shaders.c @@ -125,6 +125,9 @@ typedef struct _cairo_shader_cache_entry { cairo_bool_t src_use_atlas; cairo_bool_t mask_use_atlas; + cairo_bool_t src_n_stops_is_two; + cairo_bool_t mask_n_stops_is_two; + cairo_gl_context_t *ctx; /* XXX: needed to destroy the program */ cairo_gl_shader_t shader; } cairo_shader_cache_entry_t; @@ -144,7 +147,9 @@ _cairo_gl_shader_cache_equal_desktop (const void *key_a, const void *key_b) a->use_coverage == b->use_coverage && a->in == b->in && (both_have_npot_repeat || a->src_extend == b->src_extend) && - (both_have_npot_repeat || a->mask_extend == b->mask_extend)); + (both_have_npot_repeat || a->mask_extend == b->mask_extend) && + a->src_n_stops_is_two == b->src_n_stops_is_two && + a->mask_n_stops_is_two == b->mask_n_stops_is_two); } /* @@ -171,13 +176,17 @@ _cairo_gl_shader_cache_equal_gles2 (const void *key_a, const void *key_b) (both_have_npot_repeat || a->src_extend == b->src_extend) && a->mask_gl_filter == b->mask_gl_filter && a->mask_border_fade == b->mask_border_fade && - (both_have_npot_repeat || a->mask_extend == b->mask_extend)); + (both_have_npot_repeat || a->mask_extend == b->mask_extend) && + a->src_n_stops_is_two == b->src_n_stops_is_two && + a->mask_n_stops_is_two == b->mask_n_stops_is_two); } static unsigned long _cairo_gl_shader_cache_hash (const cairo_shader_cache_entry_t *entry) { - return ((entry->src << 15) | + return ((entry->src_n_stops_is_two << 19) | + (entry->mask_n_stops_is_two << 18) | + (entry->src << 15) | (entry->mask << 12) | (entry->dest << 9) | (entry->in << 7) | @@ -749,6 +758,7 @@ cairo_gl_shader_emit_color (cairo_output_stream_t *stream, } break; case CAIRO_GL_OPERAND_LINEAR_GRADIENT: + if (op->gradient.gradient->n_stops != 2) { if (needs_glsl330 == CAIRO_GLSL_VERSION_330) { _cairo_output_stream_printf (stream, "in vec2 %s_texcoords;\n" @@ -788,6 +798,91 @@ cairo_gl_shader_emit_color (cairo_output_stream_t *stream, "}\n", textstr, rectstr, namestr, namestr, namestr); } + } else { // else of if (op->gradient.gradient->n_stops != 2) + if (needs_glsl330 == CAIRO_GLSL_VERSION_330) { + _cairo_output_stream_printf (stream, + "in vec2 %s_texcoords;\n" + "uniform vec2 %s_texdims;\n" + "uniform sampler2D%s %s_sampler;\n" + "uniform vec4 %s_color_1;\n" + "uniform vec4 %s_color_2;\n" + "uniform float %s_offset_1;\n" + "uniform float %s_offset_2;\n" + "\n" + "vec4 get_%s()\n" + "{\n", + namestr, namestr, rectstr, namestr, namestr, + namestr, namestr, namestr, namestr); + } + else { + _cairo_output_stream_printf (stream, + "varying vec2 %s_texcoords;\n" + "uniform vec2 %s_texdims;\n" + "uniform sampler2D%s %s_sampler;\n" + "uniform vec4 %s_color_1;\n" + "uniform vec4 %s_color_2;\n" + "uniform float %s_offset_1;\n" + "uniform float %s_offset_2;\n" + "\n" + "vec4 get_%s()\n" + "{\n", + namestr, namestr, rectstr, namestr, namestr, + namestr, namestr, namestr, namestr); + } + + if ((ctx->gl_flavor == CAIRO_GL_FLAVOR_ES2 || + ctx->gl_flavor == CAIRO_GL_FLAVOR_ES3) && + _cairo_gl_shader_needs_border_fade (op)) + { + _cairo_output_stream_printf (stream, + " float border_fade = %s_border_fade (%s_texcoords.x, %s_texdims.x);\n" + " vec4 texel;\n" + " float scale;\n" + " float factor;\n" + " float upper_t = %s_texcoords.x;\n" + " if (upper_t <= %s_offset_1) {\n" + " texel = %s_color_1;\n" + " } else if (upper_t >= %s_offset_2) {\n" + " texel = %s_color_2;\n" + " } else {\n" + " scale = %s_offset_2 - %s_offset_1;\n" + " factor = (upper_t - %s_offset_1)/scale;\n" + " texel = mix (%s_color_1, %s_color_2, factor);\n" + " }\n" + " texel = vec4(texel.rgb * texel.a, texel.a);\n" + " return texel * border_fade;\n" + "}\n", + namestr, namestr, namestr, + namestr, namestr, namestr, namestr, + namestr, + namestr, namestr, namestr, namestr, namestr); + } + else + { + _cairo_output_stream_printf (stream, + " vec4 texel;\n" + " float scale;\n" + " float factor;\n" + " float upper_t = (vec2(%s_wrap (vec2 (%s_texcoords.x, 0.5)))).x;\n" + " if (upper_t <= %s_offset_1) {\n" + " texel = %s_color_1;\n" + " } else if (upper_t >= %s_offset_2) {\n" + " texel = %s_color_2;\n" + " } else {\n" + " scale = %s_offset_2 - %s_offset_1;\n" + " factor = (upper_t - %s_offset_1)/scale;\n" + " texel = mix (%s_color_1, %s_color_2, factor);\n" + " }\n" + " texel = vec4(texel.rgb * texel.a, texel.a);\n" + " return texel;\n" + "}\n", + namestr, namestr, namestr, namestr, namestr, namestr, + namestr, namestr, namestr, namestr, namestr + ); + } + + } //end of if (op->gradient.gradient->n_stops != 2) + break; case CAIRO_GL_OPERAND_RADIAL_GRADIENT_A0: if (op->gradient.gradient->n_stops != 2) { @@ -858,13 +953,10 @@ cairo_gl_shader_emit_color (cairo_output_stream_t *stream, "uniform sampler2D%s %s_sampler;\n" "uniform vec3 %s_circle_d;\n" "uniform float %s_radius_0;\n" -//two_color_mod -#if 1 "uniform vec4 %s_color_1;\n" "uniform vec4 %s_color_2;\n" "uniform float %s_offset_1;\n" "uniform float %s_offset_2;\n" -#endif "\n" "vec4 get_%s()\n" "{\n" @@ -885,13 +977,10 @@ cairo_gl_shader_emit_color (cairo_output_stream_t *stream, "uniform sampler2D%s %s_sampler;\n" "uniform vec3 %s_circle_d;\n" "uniform float %s_radius_0;\n" -//two_color_mod -#if 1 "uniform vec4 %s_color_1;\n" "uniform vec4 %s_color_2;\n" "uniform float %s_offset_1;\n" "uniform float %s_offset_2;\n" -#endif "\n" "vec4 get_%s()\n" "{\n" @@ -913,8 +1002,6 @@ cairo_gl_shader_emit_color (cairo_output_stream_t *stream, { _cairo_output_stream_printf (stream, " float border_fade = %s_border_fade (t, %s_texdims.x);\n" - //" vec4 texel = texture%s%s (%s_sampler, vec2 (t, 0.5));\n" -//two_color_mod " vec4 texel;\n" " float scale;\n" " float factor;\n" @@ -927,6 +1014,7 @@ cairo_gl_shader_emit_color (cairo_output_stream_t *stream, " factor = (t - %s_offset_1)/scale;\n" " texel = mix (%s_color_1, %s_color_2, factor);\n" " }\n" + " texel = vec4(texel.rgb * texel.a, texel.a);\n" " return mix (vec4 (0.0), texel * border_fade, is_valid);\n" "}\n", namestr, namestr, namestr, namestr, namestr, namestr, @@ -935,8 +1023,6 @@ cairo_gl_shader_emit_color (cairo_output_stream_t *stream, else { _cairo_output_stream_printf (stream, - //" vec4 texel = texture%s%s (%s_sampler, %s_wrap (vec2 (t, 0.5)));\n" -//two_color_mod " vec4 texel;\n" " float scale;\n" " float factor;\n" @@ -950,6 +1036,7 @@ cairo_gl_shader_emit_color (cairo_output_stream_t *stream, " factor = (upper_t - %s_offset_1)/scale;\n" " texel = mix (%s_color_1, %s_color_2, factor);\n" " }\n" + " texel = vec4(texel.rgb * texel.a, texel.a);\n" " return mix (vec4 (0.0), texel, is_valid);\n" "}\n", namestr, namestr, namestr, namestr, namestr, @@ -1042,13 +1129,10 @@ cairo_gl_shader_emit_color (cairo_output_stream_t *stream, "uniform vec3 %s_circle_d;\n" "uniform float %s_a;\n" "uniform float %s_radius_0;\n" -//two_color_mod -#if 1 "uniform vec4 %s_color_1;\n" "uniform vec4 %s_color_2;\n" "uniform float %s_offset_1;\n" "uniform float %s_offset_2;\n" -#endif "\n" "vec4 get_%s()\n" "{\n" @@ -1076,13 +1160,10 @@ cairo_gl_shader_emit_color (cairo_output_stream_t *stream, "uniform vec3 %s_circle_d;\n" "uniform float %s_a;\n" "uniform float %s_radius_0;\n" -//two_color_mod -#if 1 "uniform vec4 %s_color_1;\n" "uniform vec4 %s_color_2;\n" "uniform float %s_offset_1;\n" "uniform float %s_offset_2;\n" -#endif "\n" "vec4 get_%s()\n" "{\n" @@ -1110,8 +1191,6 @@ cairo_gl_shader_emit_color (cairo_output_stream_t *stream, { _cairo_output_stream_printf (stream, " float border_fade = %s_border_fade (upper_t, %s_texdims.x);\n" - //" vec4 texel = texture%s%s (%s_sampler, vec2 (upper_t, 0.5));\n" -//two_color_mod " vec4 texel;\n" " float scale;\n" " float factor;\n" @@ -1124,6 +1203,7 @@ cairo_gl_shader_emit_color (cairo_output_stream_t *stream, " factor = (upper_t - %s_offset_1)/scale;\n" " texel = mix (%s_color_1, %s_color_2, factor);\n" " }\n" + " texel = vec4(texel.rgb * texel.a, texel.a);\n" " return mix (vec4 (0.0), texel * border_fade, has_color);\n" "}\n", namestr, namestr, namestr, namestr, namestr, namestr, @@ -1132,8 +1212,6 @@ cairo_gl_shader_emit_color (cairo_output_stream_t *stream, else { _cairo_output_stream_printf (stream, - //" vec4 texel = texture%s%s (%s_sampler, %s_wrap (vec2(upper_t, 0.5)));\n" -//two_color_mod " vec4 texel;\n" " float scale;\n" " float factor;\n" @@ -1147,6 +1225,7 @@ cairo_gl_shader_emit_color (cairo_output_stream_t *stream, " factor = (upper_tw - %s_offset_1)/scale;\n" " texel = mix (%s_color_1, %s_color_2, factor);\n" " }\n" + " texel = vec4(texel.rgb * texel.a, texel.a);\n" " return mix (vec4 (0.0), texel, has_color);\n" "}\n", namestr, namestr, namestr, namestr, namestr, @@ -1225,13 +1304,10 @@ cairo_gl_shader_emit_color (cairo_output_stream_t *stream, "uniform vec3 %s_circle_d;\n" "uniform float %s_a;\n" "uniform float %s_radius_0;\n" -//two_color_mod -#if 1 "uniform vec4 %s_color_1;\n" "uniform vec4 %s_color_2;\n" "uniform float %s_offset_1;\n" "uniform float %s_offset_2;\n" -#endif "\n" "vec4 get_%s()\n" "{\n" @@ -1248,7 +1324,6 @@ cairo_gl_shader_emit_color (cairo_output_stream_t *stream, " float has_color = step (0., det) * max (is_valid.x, is_valid.y);\n" " \n" " float upper_t = mix (t.y, t.x, is_valid.x);\n" -//two_color_mod " vec4 texel;\n" " float scale;\n" " float factor;\n" @@ -1262,6 +1337,7 @@ cairo_gl_shader_emit_color (cairo_output_stream_t *stream, " factor = (upper_tw - %s_offset_1)/scale;\n" " texel = mix (%s_color_1, %s_color_2, factor);\n" " }\n" + " texel = vec4(texel.rgb * texel.a, texel.a);\n" " return mix (vec4 (0.0), texel, has_color);\n" "}\n", namestr, rectstr, namestr, namestr, namestr, namestr, @@ -1277,13 +1353,10 @@ cairo_gl_shader_emit_color (cairo_output_stream_t *stream, "uniform vec3 %s_circle_d;\n" "uniform float %s_a;\n" "uniform float %s_radius_0;\n" -//two_color_mod -#if 1 "uniform vec4 %s_color_1;\n" "uniform vec4 %s_color_2;\n" "uniform float %s_offset_1;\n" "uniform float %s_offset_2;\n" -#endif "\n" "vec4 get_%s()\n" "{\n" @@ -1300,7 +1373,6 @@ cairo_gl_shader_emit_color (cairo_output_stream_t *stream, " float has_color = step (0., det) * max (is_valid.x, is_valid.y);\n" " \n" " float upper_t = mix (t.y, t.x, is_valid.x);\n" -//two_color_mod " vec4 texel;\n" " float scale;\n" " float factor;\n" @@ -1314,6 +1386,7 @@ cairo_gl_shader_emit_color (cairo_output_stream_t *stream, " factor = (upper_tw - %s_offset_1)/scale;\n" " texel = mix (%s_color_1, %s_color_2, factor);\n" " }\n" + " texel = vec4(texel.rgb * texel.a, texel.a);\n" " return mix (vec4 (0.0), texel, has_color);\n" "}\n", namestr, rectstr, namestr, namestr, namestr, namestr, @@ -1456,7 +1529,12 @@ _cairo_gl_shader_emit_wrap (cairo_gl_context_t *ctx, } } else { - if (! ctx->has_npot_repeat && + if (((! ctx->has_npot_repeat) || + ((operand->type == CAIRO_GL_OPERAND_LINEAR_GRADIENT || + operand->type == CAIRO_GL_OPERAND_RADIAL_GRADIENT_A0 || + operand->type == CAIRO_GL_OPERAND_RADIAL_GRADIENT_NONE || + operand->type == CAIRO_GL_OPERAND_RADIAL_GRADIENT_EXT) && + operand->gradient.gradient->n_stops == 2)) && (extend == CAIRO_EXTEND_REPEAT || extend == CAIRO_EXTEND_REFLECT)) { if (extend == CAIRO_EXTEND_REPEAT) { @@ -1775,7 +1853,6 @@ _cairo_gl_shader_compile_and_link (cairo_gl_context_t *ctx, shader->alpha_location[i] = _cairo_gl_get_op_uniform_location (ctx, shader, i, "alpha"); -//two_color_mod shader->color_1_location[i] = _cairo_gl_get_op_uniform_location (ctx, shader, i, "color_1"); shader->color_2_location[i] = @@ -1955,6 +2032,22 @@ _cairo_gl_get_shader_by_type (cairo_gl_context_t *ctx, use_coverage, CAIRO_GL_VAR_NONE); + if (source->type == CAIRO_GL_OPERAND_LINEAR_GRADIENT || + source->type == CAIRO_GL_OPERAND_RADIAL_GRADIENT_A0 || + source->type == CAIRO_GL_OPERAND_RADIAL_GRADIENT_NONE || + source->type == CAIRO_GL_OPERAND_RADIAL_GRADIENT_EXT) + lookup.src_n_stops_is_two = source->gradient.gradient->n_stops == 2; + else + lookup.src_n_stops_is_two = FALSE; + + if (mask->type == CAIRO_GL_OPERAND_LINEAR_GRADIENT || + mask->type == CAIRO_GL_OPERAND_RADIAL_GRADIENT_A0 || + mask->type == CAIRO_GL_OPERAND_RADIAL_GRADIENT_NONE || + mask->type == CAIRO_GL_OPERAND_RADIAL_GRADIENT_EXT) + lookup.mask_n_stops_is_two = mask->gradient.gradient->n_stops == 2; + else + lookup.mask_n_stops_is_two = FALSE; + lookup.src = source->type; lookup.mask = mask->type; lookup.dest = CAIRO_GL_OPERAND_NONE; -- 2.7.4 From 74b9e248c50891879b456a80aa1abf55f1168285 Mon Sep 17 00:00:00 2001 From: "hk57.kim" Date: Thu, 24 Dec 2015 09:17:53 +0900 Subject: [PATCH 07/16] [FIX PROTEX ISSUE]remove cairo-tools comments in cairo.spec Change-Id: Ie0d73fe28ad43f620b2bac49a73173e1efdd12db Signed-off-by: hk57.kim --- packaging/cairo.spec | 33 +++------------------------------ 1 file changed, 3 insertions(+), 30 deletions(-) diff --git a/packaging/cairo.spec b/packaging/cairo.spec index 2cf96ec..39165e6 100644 --- a/packaging/cairo.spec +++ b/packaging/cairo.spec @@ -55,7 +55,7 @@ identical output on all output media while taking advantage of display hardware acceleration when available. %package -n libcairo -License: LGPL-2.1+ or MPL-1.1 +License: MPL-1.1 or LGPL-2.1+ Summary: Vector Graphics Library with Cross-Device Output Support Group: Graphics/Libraries Provides: cairo = %{version} @@ -69,7 +69,7 @@ identical output on all output media while taking advantage of display hardware acceleration when available. %package -n libcairo-gobject -License: LGPL-2.1+ or MPL-1.1 +License: MPL-1.1 or LGPL-2.1+ Summary: Vector Graphics Library with Cross-Device Output Support Group: Graphics/Libraries @@ -84,7 +84,7 @@ This library contains GType declarations for Cairo types. It is also meant to support gobject-introspection binding creation. %package -n libcairo-script-interpreter -License: LGPL-2.1+ or MPL-1.1 +License: MPL-1.1 or LGPL-2.1+ Summary: Vector Graphics Library with Cross-Device Output Support Group: Graphics/Libraries @@ -95,22 +95,6 @@ in-memory image buffers, and PostScript. Cairo is designed to produce identical output on all output media while taking advantage of display hardware acceleration when available. -%package -n tools -License: GPL-3.0+ -Summary: Vector Graphics Library with Cross-Device Output Support -- Utilities -Group: Development/Libraries -# We need an explicit requires since nothing links to the cairo library -#Requires: libcairo = %{version} - -%description -n tools -Cairo is a vector graphics library with cross-device output support. -Currently supported output targets include the X Window System, -in-memory image buffers, and PostScript. Cairo is designed to produce -identical output on all output media while taking advantage of display -hardware acceleration when available. - -This package contains various cairo utilities. - %package devel License: MPL-1.1 or LGPL-2.1+ Summary: Development environment for cairo @@ -203,17 +187,6 @@ make %{?_smp_mflags} V=1 %license util/cairo-script/COPYING %{_libdir}/libcairo-script-interpreter.so.* -#%files -n tools -#%manifest %{name}.manifest -#%defattr(-, root, root) -#%license util/cairo-trace/COPYING util/cairo-trace/COPYING-GPL-3 -#%{_bindir}/cairo-sphinx -#%{_bindir}/cairo-trace -#%dir %{_libdir}/cairo -#%{_libdir}/cairo/cairo-fdr.so* -#%{_libdir}/cairo/cairo-sphinx.so* -#%{_libdir}/cairo/libcairo-trace.so* - %files devel %manifest %{name}.manifest %defattr(-, root, root) -- 2.7.4 From de73355cecef0b9466408c7b334928e33c3f990b Mon Sep 17 00:00:00 2001 From: "hk57.kim" Date: Wed, 2 Mar 2016 13:23:27 +0900 Subject: [PATCH 08/16] [Add error handling for cairo_gl_device_set_thread_aware() API] Change-Id: Ie948efb70a0ac1b2db49bf7f4babc61b149be1f0 Signed-off-by: hk57.kim --- src/cairo-gl-device.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/cairo-gl-device.c b/src/cairo-gl-device.c index 7069c83..5dce9fb 100644 --- a/src/cairo-gl-device.c +++ b/src/cairo-gl-device.c @@ -1100,11 +1100,24 @@ void cairo_gl_device_set_thread_aware (cairo_device_t *device, cairo_bool_t thread_aware) { + if ((! device)||(cairo_device_status(device)!= CAIRO_STATUS_SUCCESS)) { + fprintf (stderr, "cairo_gl_device_set_thread_aware(): cairo_device is NULL or not available\n"); + _cairo_error_throw (CAIRO_STATUS_DEVICE_ERROR); + return; + } if (device->backend->type != CAIRO_DEVICE_TYPE_GL) { _cairo_error_throw (CAIRO_STATUS_DEVICE_TYPE_MISMATCH); return; } - ((cairo_gl_context_t *) device)->thread_aware = thread_aware; + if(thread_aware == 0 || thread_aware == 1) + { + ((cairo_gl_context_t *) device)->thread_aware = thread_aware; + } + else + { + _cairo_device_set_error (device, CAIRO_STATUS_INVALID_STATUS); + return; + } } void _cairo_gl_context_reset (cairo_gl_context_t *ctx) -- 2.7.4 From 40baa053e3c51937535d41a9b9279e94496d5889 Mon Sep 17 00:00:00 2001 From: jerry kim Date: Wed, 2 Mar 2016 18:05:33 -0800 Subject: [PATCH 09/16] Revert "[Fix cairo.spec to disable backends(ps,pdf,script,svg,tee)]" This reverts commit ca3e6d75aaf63e5f77bc31975d77a20cbc5407ca. Change-Id: I42794fd7ff139598ed39fba31622709562250948 --- packaging/cairo.spec | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packaging/cairo.spec b/packaging/cairo.spec index 2cf96ec..3ca995e 100644 --- a/packaging/cairo.spec +++ b/packaging/cairo.spec @@ -153,11 +153,11 @@ NOCONFIGURE=1 ./autogen.sh --enable-glesv2=yes \ --enable-evasgl=yes \ %endif - --enable-ps=no \ - --enable-pdf=no \ - --enable-script=no \ - --enable-svg=no \ - --enable-tee=no \ + --enable-ps \ + --enable-pdf \ + --enable-script \ + --enable-svg \ + --enable-tee \ %if %{with wayland} && !%{with x} --disable-xlib \ --disable-xcb \ -- 2.7.4 From 9b738f2d3f7af9b8bd690cff49aff785289e9071 Mon Sep 17 00:00:00 2001 From: jerry kim Date: Thu, 3 Mar 2016 00:39:19 -0800 Subject: [PATCH 10/16] Revert "Revert "[Fix cairo.spec to disable backends(ps,pdf,script,svg,tee)]"" This reverts commit 40baa053e3c51937535d41a9b9279e94496d5889. Change-Id: If42a5c34f855042dbb07ea4f3ffc7f3ba049dc95 --- packaging/cairo.spec | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packaging/cairo.spec b/packaging/cairo.spec index 3ca995e..2cf96ec 100644 --- a/packaging/cairo.spec +++ b/packaging/cairo.spec @@ -153,11 +153,11 @@ NOCONFIGURE=1 ./autogen.sh --enable-glesv2=yes \ --enable-evasgl=yes \ %endif - --enable-ps \ - --enable-pdf \ - --enable-script \ - --enable-svg \ - --enable-tee \ + --enable-ps=no \ + --enable-pdf=no \ + --enable-script=no \ + --enable-svg=no \ + --enable-tee=no \ %if %{with wayland} && !%{with x} --disable-xlib \ --disable-xcb \ -- 2.7.4 From dc73636f375442d20568a193cba72438137c235a Mon Sep 17 00:00:00 2001 From: "hk57.kim" Date: Fri, 4 Mar 2016 12:39:35 +0900 Subject: [PATCH 11/16] fix build spec for poppler(enable) Change-Id: I1fc9df13a22c6f4b553d27272cc0bbcd8264f9d8 Signed-off-by: hk57.kim --- packaging/cairo.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/cairo.spec b/packaging/cairo.spec index 39165e6..514f89f 100644 --- a/packaging/cairo.spec +++ b/packaging/cairo.spec @@ -138,7 +138,7 @@ NOCONFIGURE=1 ./autogen.sh --enable-evasgl=yes \ %endif --enable-ps=no \ - --enable-pdf=no \ + --enable-pdf=yes \ --enable-script=no \ --enable-svg=no \ --enable-tee=no \ -- 2.7.4 From 298d7cd81cd92c17662c0c127a467a7b94721067 Mon Sep 17 00:00:00 2001 From: "hk57.kim" Date: Fri, 4 Mar 2016 14:13:57 +0900 Subject: [PATCH 12/16] fix obs buid error :enable poppler to enable poppler module build in OBS, should enable not only cairo-pdf, cairo-ps and cairo-svg. Change-Id: I14e2647f76ded09a04b31afbd0fe93841551d78e Signed-off-by: hk57.kim --- packaging/cairo.spec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packaging/cairo.spec b/packaging/cairo.spec index 514f89f..23a02c4 100644 --- a/packaging/cairo.spec +++ b/packaging/cairo.spec @@ -137,10 +137,10 @@ NOCONFIGURE=1 ./autogen.sh --enable-glesv2=yes \ --enable-evasgl=yes \ %endif - --enable-ps=no \ + --enable-ps=yes \ --enable-pdf=yes \ --enable-script=no \ - --enable-svg=no \ + --enable-svg=yes \ --enable-tee=no \ %if %{with wayland} && !%{with x} --disable-xlib \ -- 2.7.4 From ea5563808b7f553121fbed5bc6b4bf908b1a8c05 Mon Sep 17 00:00:00 2001 From: "hk57.kim" Date: Wed, 9 Mar 2016 16:13:24 +0900 Subject: [PATCH 13/16] fix rootstrap error : enable-script occurred missing cairo-gobject, cairo-script-interpreter error. fix this issue. Change-Id: I14fd5fda295c06ebe167d7e37352413e278b53b5 Signed-off-by: hk57.kim --- packaging/cairo.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/cairo.spec b/packaging/cairo.spec index 23a02c4..3d6bc60 100644 --- a/packaging/cairo.spec +++ b/packaging/cairo.spec @@ -139,7 +139,7 @@ NOCONFIGURE=1 ./autogen.sh %endif --enable-ps=yes \ --enable-pdf=yes \ - --enable-script=no \ + --enable-script=yes \ --enable-svg=yes \ --enable-tee=no \ %if %{with wayland} && !%{with x} -- 2.7.4 From af39a3b110b53f9ab84de1a91483b5fc952ce6c0 Mon Sep 17 00:00:00 2001 From: "hk57.kim" Date: Wed, 16 Mar 2016 16:42:19 +0900 Subject: [PATCH 14/16] fix build warning Change-Id: Iff4a3ad9811ba4454be3e29d8876a5f3974f4c7f Signed-off-by: hk57.kim --- src/cairo-array.c | 2 +- src/cairo-botor-scan-converter.c | 6 ++++++ src/cairo-gl-device.c | 9 +++++---- src/cairo-gl-gradient.c | 3 +++ src/cairo-gl-info.c | 4 ++-- src/cairo-gl-msaa-compositor.c | 3 +++ src/cairo-gl-private.h | 6 +++--- src/cairo-gl-surface.c | 3 +++ src/cairo-path-stroke.c | 5 ++++- src/cairo-pattern.c | 2 +- src/cairo-polygon-intersect.c | 2 +- src/cairo-polygon-reduce.c | 2 +- src/cairo-ps-surface.c | 2 +- src/cairo-script-surface.c | 6 ++++-- src/cairo-type3-glyph-surface.c | 6 ++++-- 15 files changed, 42 insertions(+), 19 deletions(-) diff --git a/src/cairo-array.c b/src/cairo-array.c index e37bb99..7cc2bf0 100644 --- a/src/cairo-array.c +++ b/src/cairo-array.c @@ -240,7 +240,7 @@ _cairo_array_copy_element (const cairo_array_t *array, unsigned int index, void *dst) { - void *src = _cairo_array_index_const (array, index); + void *src = (void *)_cairo_array_index_const (array, index); if(src != NULL) memcpy (dst, src, array->element_size); } diff --git a/src/cairo-botor-scan-converter.c b/src/cairo-botor-scan-converter.c index 515305b..880fe8c 100644 --- a/src/cairo-botor-scan-converter.c +++ b/src/cairo-botor-scan-converter.c @@ -194,6 +194,8 @@ floored_divrem (int a, int b) return qr; } +/* + # to avoid warning : defined but not used [-Wunused-function] static struct quorem floored_muldivrem(int x, int a, int b) { @@ -207,6 +209,7 @@ floored_muldivrem(int x, int a, int b) } return qr; } +*/ static cairo_fixed_t line_compute_intersection_x_for_y (const cairo_line_t *line, @@ -2045,6 +2048,8 @@ _cairo_botor_scan_converter_generate (void *converter, return status; } +/* +# to avoid warning : defined but not used [-Wunused-function] static edge_t * botor_allocate_edge (cairo_botor_scan_converter_t *self) { @@ -2127,6 +2132,7 @@ botor_add_edge (cairo_botor_scan_converter_t *self, return CAIRO_STATUS_SUCCESS; } +*/ static void _cairo_botor_scan_converter_destroy (void *converter) diff --git a/src/cairo-gl-device.c b/src/cairo-gl-device.c index 5dce9fb..3258388 100644 --- a/src/cairo-gl-device.c +++ b/src/cairo-gl-device.c @@ -507,7 +507,7 @@ _cairo_gl_context_activate (cairo_gl_context_t *ctx, _cairo_gl_composite_flush (ctx); _cairo_gl_context_destroy_operand (ctx, ctx->max_textures - 1); } - if (ctx->states_cache.active_texture != ctx->max_textures - 1) { + if (ctx->states_cache.active_texture != (GLenum)(ctx->max_textures - 1)) { ctx->dispatch.ActiveTexture (ctx->max_textures - 1); ctx->states_cache.active_texture = ctx->max_textures - 1; } @@ -850,8 +850,8 @@ bind_multisample_framebuffer (cairo_gl_context_t *ctx, cairo_gl_surface_t *surface) { #if CAIRO_HAS_GL_SURFACE || CAIRO_HAS_EVASGL_SURFACE - cairo_bool_t stencil_test_enabled, scissor_test_enabled; - cairo_bool_t has_stencil_cache; + cairo_bool_t stencil_test_enabled = FALSE, scissor_test_enabled = FALSE; + cairo_bool_t has_stencil_cache = FALSE; GLbitfield mask; if (ctx->gl_flavor == CAIRO_GL_FLAVOR_DESKTOP) { @@ -1115,7 +1115,8 @@ cairo_gl_device_set_thread_aware (cairo_device_t *device, } else { - _cairo_device_set_error (device, CAIRO_STATUS_INVALID_STATUS); + cairo_status_t ret; + ret = _cairo_device_set_error (device, CAIRO_STATUS_INVALID_STATUS); return; } } diff --git a/src/cairo-gl-gradient.c b/src/cairo-gl-gradient.c index 325612b..53801ff 100644 --- a/src/cairo-gl-gradient.c +++ b/src/cairo-gl-gradient.c @@ -83,6 +83,8 @@ _cairo_gl_gradient_sample_width (unsigned int n_stops, return (width + 7) & -8; } +/* + # to avoid warning : defined but not used [-Wunused-function] static uint8_t premultiply(double c, double a) { int v = c * a * 256; @@ -103,6 +105,7 @@ static uint32_t color_stop_to_pixel(const cairo_gradient_stop_t *stop) else return a << 0 | r << 8 | g << 16 | b << 24; } +*/ static cairo_status_t _cairo_gl_gradient_render (const cairo_gl_context_t *ctx, diff --git a/src/cairo-gl-info.c b/src/cairo-gl-info.c index fffea58..5da1eac 100644 --- a/src/cairo-gl-info.c +++ b/src/cairo-gl-info.c @@ -124,11 +124,11 @@ _cairo_gl_has_extension (cairo_gl_dispatch_t *dispatch, const char *ext) { int version = _cairo_gl_get_version (dispatch); if (version >= CAIRO_GL_VERSION_ENCODE (3, 0)) { - GLuint max_num_extensions; + GLint max_num_extensions; int i; dispatch->GetIntegerv (GL_NUM_EXTENSIONS, &max_num_extensions); - for (i = 0; i < max_num_extensions; i++) { + for (i = 0; i < (int)max_num_extensions; i++) { const char *extension = (const char *) dispatch->GetStringi (GL_EXTENSIONS, i); if (strstr (extension, ext) == 0) return TRUE; diff --git a/src/cairo-gl-msaa-compositor.c b/src/cairo-gl-msaa-compositor.c index 99d8cc0..49717f0 100644 --- a/src/cairo-gl-msaa-compositor.c +++ b/src/cairo-gl-msaa-compositor.c @@ -833,6 +833,8 @@ _stroke_shaper_add_quad (void *closure, quad); } +/* + # to avoid warning : defined but not used [-Wunused-function] static cairo_bool_t _is_continuous_arc (const cairo_path_fixed_t *path, const cairo_stroke_style_t *style) @@ -840,6 +842,7 @@ _is_continuous_arc (const cairo_path_fixed_t *path, return (_cairo_path_fixed_is_single_arc (path) && style->dash == NULL); } +*/ static cairo_int_status_t _prevent_overlapping_strokes (cairo_gl_context_t *ctx, diff --git a/src/cairo-gl-private.h b/src/cairo-gl-private.h index 2c534fc..c013b8d 100644 --- a/src/cairo-gl-private.h +++ b/src/cairo-gl-private.h @@ -857,7 +857,7 @@ _cairo_gl_ensure_drawbuffers (cairo_gl_context_t *ctx) if ((ctx->vao != 0 && (ctx->vao != ctx->states_cache.bound_vao))) { ctx->dispatch.GetIntegerv (GL_VERTEX_ARRAY_BINDING, &vao); - if (vao != ctx->states_cache.bound_vao) { + if (vao != (GLint)ctx->states_cache.bound_vao) { ctx->dispatch.BindVertexArray (ctx->vao); ctx->states_cache.bound_vao = ctx->vao; @@ -872,7 +872,7 @@ _cairo_gl_ensure_drawbuffers (cairo_gl_context_t *ctx) if ((ctx->vbo != 0 && (ctx->vbo != ctx->states_cache.bound_vbo))) { ctx->dispatch.GetIntegerv (GL_ARRAY_BUFFER_BINDING, &vbo); - if (vbo != (GLint) ctx->states_cache.bound_vbo) { + if (vbo != (GLint)ctx->states_cache.bound_vbo) { ctx->dispatch.BindBuffer (GL_ARRAY_BUFFER, ctx->vbo); } ctx->states_cache.bound_vbo = ctx->vbo; @@ -881,7 +881,7 @@ _cairo_gl_ensure_drawbuffers (cairo_gl_context_t *ctx) if ((ctx->ibo != 0 && (ctx->ibo != ctx->states_cache.bound_ibo))) { ctx->dispatch.GetIntegerv (GL_ELEMENT_ARRAY_BUFFER_BINDING, &ibo); - if (ibo != (GLint) ctx->states_cache.bound_ibo) { + if (ibo != (GLint)ctx->states_cache.bound_ibo) { ctx->dispatch.BindBuffer (GL_ELEMENT_ARRAY_BUFFER, ctx->ibo); } ctx->states_cache.bound_ibo = ctx->ibo; diff --git a/src/cairo-gl-surface.c b/src/cairo-gl-surface.c index e156a0a..7938f30 100644 --- a/src/cairo-gl-surface.c +++ b/src/cairo-gl-surface.c @@ -1441,11 +1441,14 @@ FAIL: return status; } +/* + # to avoid warning : defined but not used [-Wunused-function] static int _cairo_gl_surface_flavor (cairo_gl_surface_t *surface) { cairo_gl_context_t *ctx = (cairo_gl_context_t *)surface->base.device; return ctx->gl_flavor; } +*/ static cairo_status_t _cairo_gl_surface_finish (void *abstract_surface) diff --git a/src/cairo-path-stroke.c b/src/cairo-path-stroke.c index 5c260c9..c3f022b 100644 --- a/src/cairo-path-stroke.c +++ b/src/cairo-path-stroke.c @@ -90,6 +90,8 @@ typedef struct cairo_stroker { cairo_box_t bounds; } cairo_stroker_t; +/* + # to avoid warning : defined but not used [-Wunused-function] static cairo_bool_t _cairo_stroke_segment_intersect (cairo_point_t *p1, cairo_point_t *p2, cairo_point_t *p3, cairo_point_t *p4, @@ -117,7 +119,7 @@ _cairo_stroke_segment_intersect (cairo_point_t *p1, cairo_point_t *p2, x = (pre * (x3 - x4) - (x1 - x2) * post) / d; y = (pre * (y3 - y4) - (y1 - y2) * post) / d; - /* check if x, y are within both segments */ + // check if x, y are within both segments if (x < MIN (x1, x2) || x > MAX (x1, x2) || x < MIN (x3, x4) || x > MAX (x3, x4)) return FALSE; @@ -129,6 +131,7 @@ _cairo_stroke_segment_intersect (cairo_point_t *p1, cairo_point_t *p2, p->y = _cairo_fixed_from_double (y); return TRUE; } +*/ static void _cairo_stroker_limit (cairo_stroker_t *stroker, diff --git a/src/cairo-pattern.c b/src/cairo-pattern.c index c7d269c..a07c22f 100644 --- a/src/cairo-pattern.c +++ b/src/cairo-pattern.c @@ -297,7 +297,7 @@ _cairo_mesh_pattern_init_copy (cairo_mesh_pattern_t *pattern, *pattern = *other; _cairo_array_init (&pattern->patches, sizeof (cairo_mesh_patch_t)); - data = _cairo_array_index_const (&other->patches, 0); + data = (void *)_cairo_array_index_const (&other->patches, 0); if (data == NULL) return CAIRO_STATUS_NULL_POINTER; return _cairo_array_append_multiple (&pattern->patches, diff --git a/src/cairo-polygon-intersect.c b/src/cairo-polygon-intersect.c index 2cd73d2..fc8b249 100644 --- a/src/cairo-polygon-intersect.c +++ b/src/cairo-polygon-intersect.c @@ -444,7 +444,7 @@ edges_compare_x_for_y (const cairo_bo_edge_t *a, HAVE_BX = 0x2, HAVE_BOTH = HAVE_AX | HAVE_BX } have_ax_bx = HAVE_BOTH; - int32_t ax, bx; + int32_t ax = 0, bx = 0; if (y == a->edge.line.p1.y) ax = a->edge.line.p1.x; diff --git a/src/cairo-polygon-reduce.c b/src/cairo-polygon-reduce.c index ea457fe..da6c9ab 100644 --- a/src/cairo-polygon-reduce.c +++ b/src/cairo-polygon-reduce.c @@ -445,7 +445,7 @@ edges_compare_x_for_y (const cairo_bo_edge_t *a, HAVE_BX = 0x2, HAVE_BOTH = HAVE_AX | HAVE_BX } have_ax_bx = HAVE_BOTH; - int32_t ax, bx; + int32_t ax = 0, bx = 0; if (y == a->edge.line.p1.y) ax = a->edge.line.p1.x; diff --git a/src/cairo-ps-surface.c b/src/cairo-ps-surface.c index 4fc15f6..b59ccaa 100644 --- a/src/cairo-ps-surface.c +++ b/src/cairo-ps-surface.c @@ -1907,7 +1907,7 @@ _cairo_ps_surface_create_padded_image_from_image (cairo_ps_surface_t * if (pad_image->status) { status = pad_image->status; cairo_surface_destroy (pad_image); - status; + //status; } _cairo_pattern_init_for_surface (&pad_pattern, &source->base); diff --git a/src/cairo-script-surface.c b/src/cairo-script-surface.c index 68c1528..fdea7bb 100644 --- a/src/cairo-script-surface.c +++ b/src/cairo-script-surface.c @@ -3778,7 +3778,8 @@ cairo_script_create (const char *filename) stream = _cairo_output_stream_create_for_filename (filename); if ((status = _cairo_output_stream_get_status (stream))) { - _cairo_output_stream_destroy (stream); + cairo_status_t ret; + ret = _cairo_output_stream_destroy (stream); return _cairo_device_create_in_error (status); } @@ -3812,7 +3813,8 @@ cairo_script_create_for_stream (cairo_write_func_t write_func, stream = _cairo_output_stream_create (write_func, NULL, closure); if ((status = _cairo_output_stream_get_status (stream))) { - _cairo_output_stream_destroy (stream); + cairo_status_t ret; + ret = _cairo_output_stream_destroy (stream); return _cairo_device_create_in_error (status); } diff --git a/src/cairo-type3-glyph-surface.c b/src/cairo-type3-glyph-surface.c index 63d2bd7..e7f31de 100644 --- a/src/cairo-type3-glyph-surface.c +++ b/src/cairo-type3-glyph-surface.c @@ -431,7 +431,8 @@ _cairo_type3_glyph_surface_analyze_glyph (void *abstract_surface, null_stream = _cairo_null_stream_create (); if (unlikely (null_stream->status)) { status = null_stream->status; - _cairo_output_stream_destroy (null_stream); + cairo_status_t ret; + ret = _cairo_output_stream_destroy (null_stream); return status; } @@ -538,7 +539,8 @@ _cairo_type3_glyph_surface_emit_glyph (void *abstract_surface, mem_stream = _cairo_memory_stream_create (); status = mem_stream->status; if (unlikely (status)) { - _cairo_output_stream_destroy (mem_stream); + cairo_status_t ret; + ret = _cairo_output_stream_destroy (mem_stream); goto FAIL; } -- 2.7.4 From c279cf141e79f15eccd5ff386cf008c8cba8fb64 Mon Sep 17 00:00:00 2001 From: "hk57.kim" Date: Thu, 2 Jun 2016 19:00:31 +0900 Subject: [PATCH 15/16] [ft]fix to enable color-glyph Change-Id: I56bec59db8ce3f5a0e54f4dd121d96f677ee40cd Signed-off-by: hk57.kim --- src/cairo-ft-font.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/cairo-ft-font.c b/src/cairo-ft-font.c index 868ccc2..c74eaab 100644 --- a/src/cairo-ft-font.c +++ b/src/cairo-ft-font.c @@ -1235,7 +1235,6 @@ _get_bitmap_surface (FT_Bitmap *bitmap, } break; // color font - #if 0 // TODO(suyambu.rm) Build error for Tizen 3.0 case FT_PIXEL_MODE_BGRA: stride = bitmap->pitch; @@ -1252,7 +1251,6 @@ _get_bitmap_surface (FT_Bitmap *bitmap, format = CAIRO_FORMAT_ARGB32; component_alpha = FALSE; break; - #endif case FT_PIXEL_MODE_GRAY2: case FT_PIXEL_MODE_GRAY4: convert: -- 2.7.4 From 0943bf528f223f9ccf2fcb15c87053f694052bfc Mon Sep 17 00:00:00 2001 From: "hk57.kim" Date: Thu, 30 Jun 2016 15:54:38 +0900 Subject: [PATCH 16/16] [T-Trace] Enable T-trace tracing utility for Cairo. By default T-trace is disabled in the build. Use --enable-ttrace=yes for enabling the same. Change-Id: I697c0a3f05bc9010620db563a4121c2ed0e46599 Signed-off-by: hk57.kim --- boilerplate/Makefile.win32.features | 9 + build/Makefile.win32.features | 1 + build/Makefile.win32.features-h | 3 + build/configure.ac.features | 1 + configure.ac | 16 ++ packaging/cairo.spec | 2 + src/Makefile.win32.features | 9 + src/cairo-compositor.c | 77 +++++--- src/cairo-default-context.c | 50 +++-- src/cairo-device.c | 16 +- src/cairo-egl-context.c | 53 +++-- src/cairo-gl-composite.c | 43 ++-- src/cairo-gl-device.c | 118 ++++++++--- src/cairo-gl-msaa-compositor.c | 112 ++++++++--- src/cairo-gl-surface.c | 246 ++++++++++++++++++----- src/cairo-gstate.c | 96 +++++++-- src/cairo-image-surface.c | 104 ++++++++-- src/cairo-png.c | 23 ++- src/cairo-region.c | 23 ++- src/cairo-surface.c | 384 +++++++++++++++++++++++++++--------- src/cairo-traps-compositor.c | 35 +++- src/cairo-ttrace.h | 47 +++++ src/cairo.c | 272 +++++++++++++++++++++---- 23 files changed, 1385 insertions(+), 355 deletions(-) create mode 100644 src/cairo-ttrace.h diff --git a/boilerplate/Makefile.win32.features b/boilerplate/Makefile.win32.features index 6087bff..c93b3b8 100644 --- a/boilerplate/Makefile.win32.features +++ b/boilerplate/Makefile.win32.features @@ -540,6 +540,15 @@ enabled_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_trace_cxx_sources) enabled_cairo_boilerplate_sources += $(cairo_boilerplate_trace_sources) endif +all_cairo_boilerplate_private += $(cairo_boilerplate_ttrace_private) $(cairo_boilerplate_ttrace_headers) +all_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_ttrace_cxx_sources) +all_cairo_boilerplate_sources += $(cairo_boilerplate_ttrace_sources) +ifeq ($(CAIRO_HAS_TTRACE),1) +enabled_cairo_boilerplate_private += $(cairo_boilerplate_ttrace_private) $(cairo_boilerplate_ttrace_headers) +enabled_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_ttrace_cxx_sources) +enabled_cairo_boilerplate_sources += $(cairo_boilerplate_ttrace_sources) +endif + all_cairo_boilerplate_private += $(cairo_boilerplate_interpreter_private) $(cairo_boilerplate_interpreter_headers) all_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_interpreter_cxx_sources) all_cairo_boilerplate_sources += $(cairo_boilerplate_interpreter_sources) diff --git a/build/Makefile.win32.features b/build/Makefile.win32.features index 5a5848d..be59490 100644 --- a/build/Makefile.win32.features +++ b/build/Makefile.win32.features @@ -40,5 +40,6 @@ CAIRO_HAS_XML_SURFACE=0 CAIRO_HAS_PTHREAD=0 CAIRO_HAS_GOBJECT_FUNCTIONS=0 CAIRO_HAS_TRACE=0 +CAIRO_HAS_TTRACE=0 CAIRO_HAS_INTERPRETER=1 CAIRO_HAS_SYMBOL_LOOKUP=0 diff --git a/build/Makefile.win32.features-h b/build/Makefile.win32.features-h index 6c0e91f..ed33c7c 100644 --- a/build/Makefile.win32.features-h +++ b/build/Makefile.win32.features-h @@ -130,6 +130,9 @@ endif ifeq ($(CAIRO_HAS_TRACE),1) @echo "#define CAIRO_HAS_TRACE 1" >> $(top_srcdir)/src/cairo-features.h endif +ifeq ($(CAIRO_HAS_TTRACE),1) + @echo "#define CAIRO_HAS_TTRACE 1" >> $(top_srcdir)/src/cairo-features.h +endif ifeq ($(CAIRO_HAS_INTERPRETER),1) @echo "#define CAIRO_HAS_INTERPRETER 1" >> $(top_srcdir)/src/cairo-features.h endif diff --git a/build/configure.ac.features b/build/configure.ac.features index adb840f..baac63e 100644 --- a/build/configure.ac.features +++ b/build/configure.ac.features @@ -410,6 +410,7 @@ AC_DEFUN([CAIRO_REPORT], echo "" echo "The following features and utilities:" echo " cairo-trace: $use_trace" + echo " cairo-ttrace: $use_ttrace" echo " cairo-script-interpreter: $use_interpreter" echo "" echo "And the following internal features:" diff --git a/configure.ac b/configure.ac index 0d85c2f..ef5725f 100644 --- a/configure.ac +++ b/configure.ac @@ -50,6 +50,16 @@ AC_CHECK_LIB(z, compress, [have_libz="no (requires zlib http://www.gzip.org/zlib/)"])], [have_libz="no (requires zlib http://www.gzip.org/zlib/)"]) +AC_CHECK_LIB(ttrace, traceBegin, + [AC_CHECK_HEADER(ttrace.h, [ + have_ttrace=yes + AC_DEFINE(HAVE_TTRACE, 1, [Define to 1 if you have ttrace available]) + ttrace_LIBS="-lttrace" + ], + [have_ttrace="no (requires ttrace)"])], + [have_ttrace="no (requires ttraec)"]) +LIBS="$ttrace_LIBS $LIBS" + AC_CHECK_LIB(wayland-client, wl_display_connect, [AC_CHECK_HEADER(wayland-client.h, [ have_wayland=yes @@ -843,6 +853,12 @@ CAIRO_ENABLE(trace, cairo-trace, auto, [ fi ]) +CAIRO_ENABLE(ttrace, cairo-ttrace, no, [ + if test "x$have_ttrace" != "xyes"; then + use_ttrace="no (requires ttrace)" + fi +]) + CAIRO_ENABLE(interpreter, cairo-script-interpreter, yes, [ if test "x$have_libz" != "xyes"; then use_interpreter="no (requires zlib)" diff --git a/packaging/cairo.spec b/packaging/cairo.spec index 3d6bc60..51c24f7 100644 --- a/packaging/cairo.spec +++ b/packaging/cairo.spec @@ -27,6 +27,7 @@ BuildRequires: pkgconfig(pixman-1) BuildRequires: which BuildRequires: pkgconfig(ecore) BuildRequires: pkgconfig(evas) +BuildRequires: pkgconfig(ttrace) %if %{with cairo_gl_backend} %if %{with x} && %{with desktop} BuildRequires: pkgconfig(gl) @@ -142,6 +143,7 @@ NOCONFIGURE=1 ./autogen.sh --enable-script=yes \ --enable-svg=yes \ --enable-tee=no \ + --enable-ttrace=no \ %if %{with wayland} && !%{with x} --disable-xlib \ --disable-xcb \ diff --git a/src/Makefile.win32.features b/src/Makefile.win32.features index fe7627c..5f08272 100644 --- a/src/Makefile.win32.features +++ b/src/Makefile.win32.features @@ -690,6 +690,15 @@ enabled_cairo_cxx_sources += $(cairo_trace_cxx_sources) enabled_cairo_sources += $(cairo_trace_sources) endif +all_cairo_private += $(cairo_ttrace_private) $(cairo_ttrace_headers) +all_cairo_cxx_sources += $(cairo_ttrace_cxx_sources) +all_cairo_sources += $(cairo_ttrace_sources) +ifeq ($(CAIRO_HAS_TTRACE),1) +enabled_cairo_private += $(cairo_ttrace_private) $(cairo_ttrace_headers) +enabled_cairo_cxx_sources += $(cairo_ttrace_cxx_sources) +enabled_cairo_sources += $(cairo_ttrace_sources) +endif + all_cairo_private += $(cairo_interpreter_private) $(cairo_interpreter_headers) all_cairo_cxx_sources += $(cairo_interpreter_cxx_sources) all_cairo_sources += $(cairo_interpreter_sources) diff --git a/src/cairo-compositor.c b/src/cairo-compositor.c index 0c4d34c..32ca8d8 100644 --- a/src/cairo-compositor.c +++ b/src/cairo-compositor.c @@ -40,6 +40,7 @@ #include "cairo-compositor-private.h" #include "cairo-damage-private.h" #include "cairo-error-private.h" +#include "cairo-ttrace.h" cairo_int_status_t _cairo_compositor_paint (const cairo_compositor_t *compositor, @@ -48,6 +49,7 @@ _cairo_compositor_paint (const cairo_compositor_t *compositor, const cairo_pattern_t *source, const cairo_clip_t *clip) { + CAIRO_TRACE_BEGIN (__func__); cairo_composite_rectangles_t extents; cairo_int_status_t status; cairo_bool_t initialized = TRUE; @@ -66,8 +68,10 @@ _cairo_compositor_paint (const cairo_compositor_t *compositor, surface, op, source, clip); - if (unlikely (status)) - return status; + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); + return status; + } do { while (compositor->paint == NULL) @@ -82,8 +86,10 @@ _cairo_compositor_paint (const cairo_compositor_t *compositor, clip); initialized = TRUE; - if (unlikely (status)) - return status; + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); + return status; + } } status = compositor->paint (compositor, &extents); @@ -102,6 +108,7 @@ _cairo_compositor_paint (const cairo_compositor_t *compositor, _cairo_composite_rectangles_fini (&extents); + CAIRO_TRACE_END (__func__); return status; } @@ -113,6 +120,7 @@ _cairo_compositor_mask (const cairo_compositor_t *compositor, const cairo_pattern_t *mask, const cairo_clip_t *clip) { + CAIRO_TRACE_BEGIN (__func__); cairo_composite_rectangles_t extents; cairo_int_status_t status; cairo_bool_t initialized = TRUE; @@ -130,8 +138,10 @@ _cairo_compositor_mask (const cairo_compositor_t *compositor, surface, op, source, mask, clip); - if (unlikely (status)) - return status; + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); + return status; + } do { while (compositor->mask == NULL) @@ -146,8 +156,10 @@ _cairo_compositor_mask (const cairo_compositor_t *compositor, mask, clip); initialized = TRUE; - if (unlikely (status)) - return status; + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); + return status; + } } status = compositor->mask (compositor, &extents); @@ -166,6 +178,7 @@ _cairo_compositor_mask (const cairo_compositor_t *compositor, _cairo_composite_rectangles_fini (&extents); + CAIRO_TRACE_END (__func__); return status; } @@ -182,14 +195,17 @@ _cairo_compositor_stroke (const cairo_compositor_t *compositor, cairo_antialias_t antialias, const cairo_clip_t *clip) { + CAIRO_TRACE_BEGIN (__func__); cairo_composite_rectangles_t extents; cairo_int_status_t status; cairo_bool_t initialized = TRUE; TRACE ((stderr, "%s\n", __FUNCTION__)); - if (_cairo_pen_vertices_needed (tolerance, style->line_width/2, ctm) <= 1) - return CAIRO_INT_STATUS_NOTHING_TO_DO; + if (_cairo_pen_vertices_needed (tolerance, style->line_width/2, ctm) <= 1) { + CAIRO_TRACE_END (__func__); + return CAIRO_INT_STATUS_NOTHING_TO_DO; + } if (compositor->lazy_init) { status = _cairo_composite_rectangles_lazy_init_for_stroke (&extents, @@ -205,8 +221,10 @@ _cairo_compositor_stroke (const cairo_compositor_t *compositor, op, source, path, style, ctm, clip); - if (unlikely (status)) - return status; + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); + return status; + } do { while (compositor->stroke == NULL) @@ -225,8 +243,10 @@ _cairo_compositor_stroke (const cairo_compositor_t *compositor, clip); initialized = TRUE; - if (unlikely (status)) - return status; + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); + return status; + } } status = compositor->stroke (compositor, &extents, @@ -247,6 +267,7 @@ _cairo_compositor_stroke (const cairo_compositor_t *compositor, _cairo_composite_rectangles_fini (&extents); + CAIRO_TRACE_END (__func__); return status; } @@ -261,6 +282,7 @@ _cairo_compositor_fill (const cairo_compositor_t *compositor, cairo_antialias_t antialias, const cairo_clip_t *clip) { + CAIRO_TRACE_BEGIN (__func__); cairo_composite_rectangles_t extents; cairo_int_status_t status; cairo_bool_t initialized = TRUE; @@ -279,8 +301,10 @@ _cairo_compositor_fill (const cairo_compositor_t *compositor, surface, op, source, path, clip); - if (unlikely (status)) - return status; + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); + return status; + } do { while (compositor->fill == NULL) @@ -295,8 +319,10 @@ _cairo_compositor_fill (const cairo_compositor_t *compositor, path, clip); initialized = TRUE; - if (unlikely (status)) - return status; + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); + return status; + } } status = compositor->fill (compositor, &extents, @@ -316,6 +342,7 @@ _cairo_compositor_fill (const cairo_compositor_t *compositor, _cairo_composite_rectangles_fini (&extents); + CAIRO_TRACE_END (__func__); return status; } @@ -329,6 +356,7 @@ _cairo_compositor_glyphs (const cairo_compositor_t *compositor, cairo_scaled_font_t *scaled_font, const cairo_clip_t *clip) { + CAIRO_TRACE_BEGIN (__func__); cairo_composite_rectangles_t extents; cairo_bool_t overlap; cairo_int_status_t status; @@ -349,8 +377,10 @@ _cairo_compositor_glyphs (const cairo_compositor_t *compositor, scaled_font, glyphs, num_glyphs, clip, &overlap); - if (unlikely (status)) - return status; + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); + return status; + } do { while (compositor->glyphs == NULL) @@ -366,8 +396,10 @@ _cairo_compositor_glyphs (const cairo_compositor_t *compositor, clip, &overlap); initialized = TRUE; - if (unlikely (status)) - return status; + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); + return status; + } } status = compositor->glyphs (compositor, &extents, @@ -387,5 +419,6 @@ _cairo_compositor_glyphs (const cairo_compositor_t *compositor, _cairo_composite_rectangles_fini (&extents); + CAIRO_TRACE_END (__func__); return status; } diff --git a/src/cairo-default-context.c b/src/cairo-default-context.c index 4b63d53..26644ea 100644 --- a/src/cairo-default-context.c +++ b/src/cairo-default-context.c @@ -49,6 +49,7 @@ #include "cairo-freed-pool-private.h" #include "cairo-path-private.h" #include "cairo-pattern-private.h" +#include "cairo-ttrace.h" #define CAIRO_TOLERANCE_MINIMUM _cairo_fixed_to_double(1) @@ -88,6 +89,7 @@ _cairo_default_context_fini (cairo_default_context_t *cr) static void _cairo_default_context_destroy (void *abstract_cr) { + CAIRO_TRACE_BEGIN (__func__); cairo_default_context_t *cr = abstract_cr; _cairo_default_context_fini (cr); @@ -95,6 +97,7 @@ _cairo_default_context_destroy (void *abstract_cr) /* mark the context as invalid to protect against misuse */ cr->base.status = CAIRO_STATUS_NULL_POINTER; _freed_pool_put (&context_pool, cr); + CAIRO_TRACE_END (__func__); } static cairo_surface_t * @@ -288,24 +291,32 @@ _current_source_matches_solid (const cairo_pattern_t *pattern, static cairo_status_t _cairo_default_context_set_source_rgba (void *abstract_cr, double red, double green, double blue, double alpha) { + CAIRO_TRACE_BEGIN (__func__); cairo_default_context_t *cr = abstract_cr; cairo_pattern_t *pattern; cairo_status_t status; if (_current_source_matches_solid (cr->gstate->source, - red, green, blue, alpha)) - return CAIRO_STATUS_SUCCESS; + red, green, blue, alpha)) { + CAIRO_TRACE_END (__func__); + return CAIRO_STATUS_SUCCESS; + } /* push the current pattern to the freed lists */ _cairo_default_context_set_source (cr, (cairo_pattern_t *) &_cairo_pattern_black); pattern = cairo_pattern_create_rgba (red, green, blue, alpha); - if (unlikely (pattern->status)) - return pattern->status; + if (unlikely (pattern->status)) { + status = pattern->status; + cairo_pattern_destroy (pattern); + CAIRO_TRACE_END (__func__); + return pattern->status; + } status = _cairo_default_context_set_source (cr, pattern); cairo_pattern_destroy (pattern); + CAIRO_TRACE_END (__func__); return status; } @@ -324,8 +335,11 @@ _cairo_default_context_set_source_surface (void *abstract_cr, _cairo_default_context_set_source (cr, (cairo_pattern_t *) &_cairo_pattern_black); pattern = cairo_pattern_create_for_surface (surface); - if (unlikely (pattern->status)) - return pattern->status; + if (unlikely (pattern->status)) { + status = pattern->status; + cairo_pattern_destroy (pattern); + return status; + } cairo_matrix_init_translate (&matrix, -x, -y); cairo_pattern_set_matrix (pattern, &matrix); @@ -1122,9 +1136,12 @@ _cairo_default_context_append_path (void *abstract_cr, static cairo_status_t _cairo_default_context_paint (void *abstract_cr) { + CAIRO_TRACE_BEGIN (__func__); cairo_default_context_t *cr = abstract_cr; - return _cairo_gstate_paint (cr->gstate); + cairo_status_t status = _cairo_gstate_paint (cr->gstate); + CAIRO_TRACE_END (__func__); + return status; } static cairo_status_t @@ -1220,7 +1237,7 @@ _cairo_default_context_fill (void *abstract_cr) { cairo_default_context_t *cr = abstract_cr; cairo_status_t status; - + status = _cairo_gstate_fill (cr->gstate, cr->path); if (unlikely (status)) return status; @@ -1695,21 +1712,26 @@ _cairo_default_context_init (cairo_default_context_t *cr, void *target) cairo_t * _cairo_default_context_create (void *target) { + CAIRO_TRACE_BEGIN (__func__); cairo_default_context_t *cr; cairo_status_t status; cr = _freed_pool_get (&context_pool); if (unlikely (cr == NULL)) { - cr = malloc (sizeof (cairo_default_context_t)); - if (unlikely (cr == NULL)) - return _cairo_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY)); - } + cr = malloc (sizeof (cairo_default_context_t)); + if (unlikely (cr == NULL)) { + CAIRO_TRACE_END (__func__); + return _cairo_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY)); + } + } status = _cairo_default_context_init (cr, target); if (unlikely (status)) { - _freed_pool_put (&context_pool, cr); - return _cairo_create_in_error (status); + _freed_pool_put (&context_pool, cr); + CAIRO_TRACE_END (__func__); + return _cairo_create_in_error (status); } + CAIRO_TRACE_END (__func__); return &cr->base; } diff --git a/src/cairo-device.c b/src/cairo-device.c index b4d1f84..d858650 100644 --- a/src/cairo-device.c +++ b/src/cairo-device.c @@ -37,6 +37,7 @@ #include "cairo-device-private.h" #include "cairo-error-private.h" #include "cairo-list-inline.h" +#include "cairo-ttrace.h" /** * SECTION:cairo-device @@ -170,6 +171,7 @@ void _cairo_device_init (cairo_device_t *device, const cairo_device_backend_t *backend) { + CAIRO_TRACE_BEGIN (__func__); CAIRO_REFERENCE_COUNT_INIT (&device->ref_count, 1); device->status = CAIRO_STATUS_SUCCESS; @@ -184,6 +186,7 @@ _cairo_device_init (cairo_device_t *device, cairo_list_init (&device->shadow_caches); device->shadow_caches_size = 0; + CAIRO_TRACE_END (__func__); } /** @@ -331,22 +334,26 @@ slim_hidden_def (cairo_device_finish); void cairo_device_destroy (cairo_device_t *device) { + CAIRO_TRACE_BEGIN (__func__); cairo_user_data_array_t user_data; if (device == NULL || CAIRO_REFERENCE_COUNT_IS_INVALID (&device->ref_count)) { - return; + CAIRO_TRACE_END (__func__); + return; } assert (CAIRO_REFERENCE_COUNT_HAS_REFERENCE (&device->ref_count)); - if (! _cairo_reference_count_dec_and_test (&device->ref_count)) - return; + if (! _cairo_reference_count_dec_and_test (&device->ref_count)) { + CAIRO_TRACE_END (__func__); + return; + } while (! cairo_list_is_empty (&device->shadow_caches)) { cairo_shadow_cache_t *shadow; - shadow = cairo_list_first_entry (&device->shadow_caches, + shadow = cairo_list_first_entry (&device->shadow_caches, cairo_shadow_cache_t, link); @@ -366,6 +373,7 @@ cairo_device_destroy (cairo_device_t *device) device->backend->destroy (device); _cairo_user_data_array_fini (&user_data); + CAIRO_TRACE_END (__func__); } slim_hidden_def (cairo_device_destroy); diff --git a/src/cairo-egl-context.c b/src/cairo-egl-context.c index 0a13c6a..5884f61 100644 --- a/src/cairo-egl-context.c +++ b/src/cairo-egl-context.c @@ -41,6 +41,7 @@ #include "cairo-gl-private.h" #include "cairo-error-private.h" +#include "cairo-ttrace.h" #if CAIRO_HAS_EVASGL_SURFACE && CAIRO_HAS_GLESV2_SURFACE extern void glActiveTexture (GLenum texture); @@ -179,21 +180,25 @@ static void _egl_swap_buffers (void *abstract_ctx, cairo_gl_surface_t *abstract_surface) { + CAIRO_TRACE_BEGIN (__func__); cairo_egl_context_t *ctx = abstract_ctx; cairo_egl_surface_t *surface = (cairo_egl_surface_t *) abstract_surface; eglSwapBuffers (ctx->display, surface->egl); + CAIRO_TRACE_END (__func__); } static void _egl_destroy (void *abstract_ctx) { + CAIRO_TRACE_BEGIN (__func__); cairo_egl_context_t *ctx = abstract_ctx; eglMakeCurrent (ctx->display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); if (ctx->dummy_surface != EGL_NO_SURFACE) eglDestroySurface (ctx->display, ctx->dummy_surface); + CAIRO_TRACE_END (__func__); } static cairo_bool_t @@ -269,6 +274,7 @@ _cairo_egl_get_proc_address (void *data, const char *name) cairo_device_t * cairo_egl_device_create (EGLDisplay dpy, EGLContext egl) { + CAIRO_TRACE_BEGIN (__func__); cairo_egl_context_t *ctx; cairo_status_t status; int attribs[] = { @@ -280,8 +286,10 @@ cairo_egl_device_create (EGLDisplay dpy, EGLContext egl) EGLint numConfigs; ctx = calloc (1, sizeof (cairo_egl_context_t)); - if (unlikely (ctx == NULL)) - return _cairo_gl_context_create_in_error (CAIRO_STATUS_NO_MEMORY); + if (unlikely (ctx == NULL)) { + CAIRO_TRACE_END (__func__); + return _cairo_gl_context_create_in_error (CAIRO_STATUS_NO_MEMORY); + } ctx->display = dpy; ctx->context = egl; @@ -315,11 +323,13 @@ cairo_egl_device_create (EGLDisplay dpy, EGLContext egl) ctx->dummy_surface = eglCreatePbufferSurface (dpy, config, attribs); if (ctx->dummy_surface == NULL) { free (ctx); + CAIRO_TRACE_END (__func__); return _cairo_gl_context_create_in_error (CAIRO_STATUS_NO_MEMORY); } if (!eglMakeCurrent (dpy, ctx->dummy_surface, ctx->dummy_surface, egl)) { free (ctx); + CAIRO_TRACE_END (__func__); return _cairo_gl_context_create_in_error (CAIRO_STATUS_NO_MEMORY); } } @@ -327,16 +337,18 @@ cairo_egl_device_create (EGLDisplay dpy, EGLContext egl) status = _cairo_gl_dispatch_init (&ctx->base.dispatch, _cairo_egl_get_proc_address, NULL); if (unlikely (status)) { - free (ctx); - return _cairo_gl_context_create_in_error (status); + free (ctx); + CAIRO_TRACE_END (__func__); + return _cairo_gl_context_create_in_error (status); } status = _cairo_gl_context_init (&ctx->base); if (unlikely (status)) { - if (ctx->dummy_surface != EGL_NO_SURFACE) - eglDestroySurface (dpy, ctx->dummy_surface); - free (ctx); - return _cairo_gl_context_create_in_error (status); + if (ctx->dummy_surface != EGL_NO_SURFACE) + eglDestroySurface (dpy, ctx->dummy_surface); + free (ctx); + CAIRO_TRACE_END (__func__); + return _cairo_gl_context_create_in_error (status); } /* Tune the default VBO size to reduce overhead on embedded devices. @@ -349,6 +361,7 @@ cairo_egl_device_create (EGLDisplay dpy, EGLContext egl) ctx->current_surface = EGL_NO_SURFACE; + CAIRO_TRACE_END (__func__); return &ctx->base.base; } @@ -358,25 +371,35 @@ cairo_gl_surface_create_for_egl (cairo_device_t *device, int width, int height) { + CAIRO_TRACE_BEGIN (__func__); cairo_egl_surface_t *surface; - if (unlikely (device->status)) - return _cairo_surface_create_in_error (device->status); + if (unlikely (device->status)) { + CAIRO_TRACE_END (__func__); + return _cairo_surface_create_in_error (device->status); + } - if (device->backend->type != CAIRO_DEVICE_TYPE_GL) - return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_SURFACE_TYPE_MISMATCH)); + if (device->backend->type != CAIRO_DEVICE_TYPE_GL) { + CAIRO_TRACE_END (__func__); + return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_SURFACE_TYPE_MISMATCH)); + } - if (width <= 0 || height <= 0) + if (width <= 0 || height <= 0) { + CAIRO_TRACE_END (__func__); return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_SIZE)); + } surface = calloc (1, sizeof (cairo_egl_surface_t)); - if (unlikely (surface == NULL)) - return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY)); + if (unlikely (surface == NULL)) { + CAIRO_TRACE_END (__func__); + return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY)); + } _cairo_gl_surface_init (device, &surface->base, CAIRO_CONTENT_COLOR_ALPHA, width, height); surface->egl = egl; + CAIRO_TRACE_END (__func__); return &surface->base.base; } diff --git a/src/cairo-gl-composite.c b/src/cairo-gl-composite.c index e8c0137..0683862 100644 --- a/src/cairo-gl-composite.c +++ b/src/cairo-gl-composite.c @@ -51,6 +51,7 @@ #include "cairo-clip-private.h" #include "cairo-error-private.h" #include "cairo-image-surface-private.h" +#include "cairo-ttrace.h" cairo_int_status_t _cairo_gl_composite_set_source (cairo_gl_composite_t *setup, @@ -76,7 +77,7 @@ _cairo_gl_composite_set_source_operand (cairo_gl_composite_t *setup, _cairo_gl_operand_copy (&setup->src, source); if (source->type == CAIRO_GL_OPERAND_TEXTURE || source->type == CAIRO_GL_OPERAND_GAUSSIAN) - status = _cairo_gl_surface_resolve_multisampling (source->texture.surface); + status = _cairo_gl_surface_resolve_multisampling (source->texture.surface); } void @@ -112,7 +113,7 @@ _cairo_gl_composite_set_mask_operand (cairo_gl_composite_t *setup, _cairo_gl_operand_copy (&setup->mask, mask); if (mask->type == CAIRO_GL_OPERAND_TEXTURE || mask->type == CAIRO_GL_OPERAND_GAUSSIAN) - status = _cairo_gl_surface_resolve_multisampling (mask->texture.surface); + status = _cairo_gl_surface_resolve_multisampling (mask->texture.surface); } } @@ -830,14 +831,17 @@ cairo_status_t _cairo_gl_composite_begin (cairo_gl_composite_t *setup, cairo_gl_context_t **ctx_out) { + CAIRO_TRACE_BEGIN (__func__); cairo_gl_context_t *ctx; cairo_status_t status; assert (setup->dst); status = _cairo_gl_context_acquire (setup->dst->base.device, &ctx); - if (unlikely (status)) - return status; + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); + return status; + } setup->dst->content_cleared = FALSE; @@ -862,12 +866,14 @@ FAIL: if (unlikely (status)) status = _cairo_gl_context_release (ctx, status); + CAIRO_TRACE_END (__func__); return status; } static inline void _cairo_gl_composite_draw_tristrip (cairo_gl_context_t *ctx) { + CAIRO_TRACE_BEGIN (__func__); cairo_array_t* indices = &ctx->tristrip_indices; const unsigned short *indices_array = _cairo_array_index_const (indices, 0); @@ -890,11 +896,13 @@ _cairo_gl_composite_draw_tristrip (cairo_gl_context_t *ctx) ctx->dispatch.DrawElements (GL_TRIANGLE_STRIP, _cairo_array_num_elements (indices), GL_UNSIGNED_SHORT, ctx->ibo ? 0 :indices_array); _cairo_array_truncate (indices, 0); + CAIRO_TRACE_END (__func__); } static inline void _cairo_gl_composite_draw_line (cairo_gl_context_t *ctx) { + CAIRO_TRACE_BEGIN (__func__); GLenum type = GL_LINE_STRIP; cairo_array_t* indices = &ctx->tristrip_indices; const unsigned short *indices_array = _cairo_array_index_const (indices, 0); @@ -921,12 +929,14 @@ _cairo_gl_composite_draw_line (cairo_gl_context_t *ctx) ctx->dispatch.DrawElements (type, _cairo_array_num_elements (indices), GL_UNSIGNED_SHORT, ctx->ibo ? 0 : indices_array); _cairo_array_truncate (indices, 0); + CAIRO_TRACE_END (__func__); } static inline void _cairo_gl_composite_draw_triangles (cairo_gl_context_t *ctx, unsigned int count) { + CAIRO_TRACE_BEGIN (__func__); if (! ctx->pre_shader) { ctx->dispatch.DrawArrays (GL_TRIANGLES, 0, count); } else { @@ -940,17 +950,20 @@ _cairo_gl_composite_draw_triangles (cairo_gl_context_t *ctx, _cairo_gl_set_operator (ctx, CAIRO_OPERATOR_ADD, TRUE); ctx->dispatch.DrawArrays (GL_TRIANGLES, 0, count); } + CAIRO_TRACE_END (__func__); } static void _cairo_gl_composite_draw_triangles_with_clip_region (cairo_gl_context_t *ctx, unsigned int count) { + CAIRO_TRACE_BEGIN (__func__); int i, num_rectangles; if (!ctx->clip_region) { - _cairo_gl_composite_draw_triangles (ctx, count); - return; + _cairo_gl_composite_draw_triangles (ctx, count); + CAIRO_TRACE_END (__func__); + return; } num_rectangles = cairo_region_num_rectangles (ctx->clip_region); @@ -963,6 +976,7 @@ _cairo_gl_composite_draw_triangles_with_clip_region (cairo_gl_context_t *ctx, _enable_scissor_buffer (ctx); _cairo_gl_composite_draw_triangles (ctx, count); } + CAIRO_TRACE_END (__func__); } static void @@ -979,14 +993,14 @@ _cairo_gl_composite_unmap_vertex_buffer (cairo_gl_context_t *ctx) void _cairo_gl_composite_flush (cairo_gl_context_t *ctx) { + CAIRO_TRACE_BEGIN (__func__); unsigned int count; int i; - if (_cairo_gl_context_is_flushed (ctx)) + if (_cairo_gl_context_is_flushed (ctx)) { + CAIRO_TRACE_END (__func__); return; - - /* ensure we are binding to vbo and ibo */ - _cairo_gl_ensure_drawbuffers (ctx); + } count = ctx->vb_offset / ctx->vertex_size; @@ -1007,6 +1021,7 @@ _cairo_gl_composite_flush (cairo_gl_context_t *ctx) _cairo_gl_glyph_cache_unlock (&ctx->glyph_cache[i]); _cairo_gl_image_cache_unlock (ctx); + CAIRO_TRACE_END (__func__); } static void @@ -1482,18 +1497,22 @@ _cairo_gl_composite_init (cairo_gl_composite_t *setup, cairo_gl_surface_t *dst, cairo_bool_t assume_component_alpha) { + CAIRO_TRACE_BEGIN (__func__); cairo_status_t status; memset (setup, 0, sizeof (cairo_gl_composite_t)); status = _cairo_gl_composite_set_operator (setup, op, assume_component_alpha); - if (status) - return status; + if (status) { + CAIRO_TRACE_END (__func__); + return status; + } setup->dst = dst; setup->clip_region = dst->clip_region; + CAIRO_TRACE_END (__func__); return CAIRO_STATUS_SUCCESS; } diff --git a/src/cairo-gl-device.c b/src/cairo-gl-device.c index 3258388..8ca2ed2 100644 --- a/src/cairo-gl-device.c +++ b/src/cairo-gl-device.c @@ -45,6 +45,7 @@ #include "cairo-error-private.h" #include "cairo-gl-private.h" #include "cairo-rtree-private.h" +#include "cairo-ttrace.h" #if CAIRO_HAS_EVASGL_SURFACE #include "cairo-evas-gl.h" @@ -272,6 +273,7 @@ test_can_read_bgra (cairo_gl_context_t *ctx, cairo_gl_flavor_t gl_flavor) cairo_status_t _cairo_gl_context_init (cairo_gl_context_t *ctx) { + CAIRO_TRACE_BEGIN (__func__); cairo_status_t status; cairo_gl_dispatch_t *dispatch = &ctx->dispatch; int gl_version = _cairo_gl_get_version (dispatch); @@ -306,8 +308,10 @@ _cairo_gl_context_init (cairo_gl_context_t *ctx) cairo_list_init (&ctx->fonts); /* Support only GL version >= 1.3 */ - if (gl_version < CAIRO_GL_VERSION_ENCODE (1, 3)) - return _cairo_error (CAIRO_STATUS_DEVICE_ERROR); + if (gl_version < CAIRO_GL_VERSION_ENCODE (1, 3)) { + CAIRO_TRACE_END (__func__); + return _cairo_error (CAIRO_STATUS_DEVICE_ERROR); + } /* Check for required extensions */ if (is_desktop) { @@ -318,8 +322,10 @@ _cairo_gl_context_init (cairo_gl_context_t *ctx) } else if (_cairo_gl_has_extension (&ctx->dispatch, "GL_ARB_texture_rectangle")) { ctx->tex_target = GL_TEXTURE_RECTANGLE; ctx->has_npot_repeat = FALSE; - } else + } else { + CAIRO_TRACE_END (__func__); return _cairo_error (CAIRO_STATUS_DEVICE_ERROR); + } } else { ctx->tex_target = GL_TEXTURE_2D; if (_cairo_gl_has_extension (&ctx->dispatch, "GL_OES_texture_npot") || @@ -330,11 +336,15 @@ _cairo_gl_context_init (cairo_gl_context_t *ctx) } if (is_desktop && gl_version < CAIRO_GL_VERSION_ENCODE (2, 1) && - ! _cairo_gl_has_extension (&ctx->dispatch, "GL_ARB_pixel_buffer_object")) - return _cairo_error (CAIRO_STATUS_DEVICE_ERROR); + ! _cairo_gl_has_extension (&ctx->dispatch, "GL_ARB_pixel_buffer_object")) { + CAIRO_TRACE_END (__func__); + return _cairo_error (CAIRO_STATUS_DEVICE_ERROR); + } - if (is_gles && ! _cairo_gl_has_extension (&ctx->dispatch, "GL_EXT_texture_format_BGRA8888")) - return _cairo_error (CAIRO_STATUS_DEVICE_ERROR); + if (is_gles && ! _cairo_gl_has_extension (&ctx->dispatch, "GL_EXT_texture_format_BGRA8888")) { + CAIRO_TRACE_END (__func__); + return _cairo_error (CAIRO_STATUS_DEVICE_ERROR); + } ctx->has_map_buffer = is_desktop || (is_gles && _cairo_gl_has_extension (&ctx->dispatch, "GL_OES_mapbuffer")); @@ -420,16 +430,20 @@ _cairo_gl_context_init (cairo_gl_context_t *ctx) ctx->gl_flavor = gl_flavor; status = _cairo_gl_context_init_shaders (ctx); - if (unlikely (status)) + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); return status; + } status = _cairo_cache_init (&ctx->gradients, _cairo_gl_gradient_equal, NULL, (cairo_destroy_func_t) _cairo_gl_gradient_destroy, CAIRO_GL_GRADIENT_CACHE_SIZE); - if (unlikely (status)) + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); return status; + } ctx->vbo_size = _cairo_gl_get_vbo_size(); @@ -460,11 +474,12 @@ _cairo_gl_context_init (cairo_gl_context_t *ctx) ctx->vb = malloc (ctx->vbo_size); if (unlikely (ctx->vb == NULL)) { - _cairo_cache_fini (&ctx->gradients); - ctx->dispatch.DeleteVertexArrays (1, &ctx->vao); - ctx->dispatch.DeleteBuffers (1, &ctx->vbo); - ctx->dispatch.DeleteBuffers (1, &ctx->ibo); - return _cairo_error (CAIRO_STATUS_NO_MEMORY); + _cairo_cache_fini (&ctx->gradients); + ctx->dispatch.DeleteVertexArrays (1, &ctx->vao); + ctx->dispatch.DeleteBuffers (1, &ctx->vbo); + ctx->dispatch.DeleteBuffers (1, &ctx->ibo); + CAIRO_TRACE_END (__func__); + return _cairo_error (CAIRO_STATUS_NO_MEMORY); } ctx->primitive_type = CAIRO_GL_PRIMITIVE_TYPE_TRIANGLES; @@ -495,6 +510,7 @@ _cairo_gl_context_init (cairo_gl_context_t *ctx) _cairo_gl_context_reset (ctx); + CAIRO_TRACE_END (__func__); return CAIRO_STATUS_SUCCESS; } @@ -547,6 +563,7 @@ static void _cairo_gl_clear_framebuffer (cairo_gl_context_t *ctx, cairo_gl_surface_t *surface) { + CAIRO_TRACE_BEGIN (__func__); if (ctx->gl_flavor == CAIRO_GL_FLAVOR_DESKTOP) return; @@ -555,6 +572,7 @@ _cairo_gl_clear_framebuffer (cairo_gl_context_t *ctx, _disable_stencil_buffer (ctx); ctx->dispatch.Clear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); } + CAIRO_TRACE_END (__func__); } #if CAIRO_HAS_GLESV2_SURFACE || CAIRO_HAS_EVASGL_SURFACE @@ -562,11 +580,16 @@ static void _cairo_gl_ensure_msaa_gles_framebuffer (cairo_gl_context_t *ctx, cairo_gl_surface_t *surface) { - if (ctx->has_angle_multisampling) - return; + CAIRO_TRACE_BEGIN (__func__); + if (ctx->has_angle_multisampling) { + CAIRO_TRACE_END (__func__); + return; + } - if (surface->msaa_active) - return; + if (surface->msaa_active) { + CAIRO_TRACE_END (__func__); + return; + } ctx->dispatch.FramebufferTexture2DMultisample(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, @@ -577,6 +600,7 @@ _cairo_gl_ensure_msaa_gles_framebuffer (cairo_gl_context_t *ctx, /* From now on MSAA will always be active on this surface. */ surface->msaa_active = TRUE; + CAIRO_TRACE_END (__func__); } #endif @@ -584,11 +608,14 @@ void _cairo_gl_ensure_framebuffer (cairo_gl_context_t *ctx, cairo_gl_surface_t *surface) { + CAIRO_TRACE_BEGIN (__func__); GLenum status; cairo_gl_dispatch_t *dispatch = &ctx->dispatch; - if (likely (surface->fb)) + if (likely (surface->fb)) { + CAIRO_TRACE_END (__func__); return; + } /* Create a framebuffer object wrapping the texture so that we can render * to it. @@ -639,22 +666,27 @@ _cairo_gl_ensure_framebuffer (cairo_gl_context_t *ctx, "destination is framebuffer incomplete: %s [%#x]\n", str, status); } + CAIRO_TRACE_END (__func__); } static void _cairo_gl_ensure_multisampling (cairo_gl_context_t *ctx, cairo_gl_surface_t *surface) { + CAIRO_TRACE_BEGIN (__func__); GLenum rgba; if (ctx->gl_flavor == CAIRO_GL_FLAVOR_ES2 && - ! ctx->has_angle_multisampling) - return; - + ! ctx->has_angle_multisampling) { + CAIRO_TRACE_END (__func__); + return; + } assert (surface->supports_msaa); - if (surface->msaa_fb) - return; + if (surface->msaa_fb) { + CAIRO_TRACE_END (__func__); + return; + } /* We maintain a separate framebuffer for multisampling operations. This allows us to do a fast paint to the non-multisampling framebuffer @@ -695,6 +727,7 @@ _cairo_gl_ensure_multisampling (cairo_gl_context_t *ctx, surface->msaa_rb = 0; ctx->dispatch.DeleteRenderbuffers (1, &surface->msaa_fb); surface->msaa_fb = 0; + CAIRO_TRACE_END (__func__); return; } @@ -705,16 +738,19 @@ _cairo_gl_ensure_multisampling (cairo_gl_context_t *ctx, memset (&ctx->states_cache.clear_red, 0, sizeof (GLclampf) * 4); ctx->dispatch.Clear (GL_COLOR_BUFFER_BIT); - + CAIRO_TRACE_END (__func__); } static cairo_bool_t _cairo_gl_ensure_msaa_depth_stencil_buffer (cairo_gl_context_t *ctx, cairo_gl_surface_t *surface) { + CAIRO_TRACE_BEGIN (__func__); cairo_gl_dispatch_t *dispatch = &ctx->dispatch; - if (surface->msaa_depth_stencil) - return TRUE; + if (surface->msaa_depth_stencil) { + CAIRO_TRACE_END (__func__); + return TRUE; + } //_cairo_gl_ensure_framebuffer (ctx, surface); @@ -754,9 +790,11 @@ _cairo_gl_ensure_msaa_depth_stencil_buffer (cairo_gl_context_t *ctx, if (dispatch->CheckFramebufferStatus (GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) { dispatch->DeleteRenderbuffers (1, &surface->msaa_depth_stencil); surface->msaa_depth_stencil = 0; + CAIRO_TRACE_END (__func__); return FALSE; } + CAIRO_TRACE_END (__func__); return TRUE; } @@ -764,10 +802,13 @@ static cairo_bool_t _cairo_gl_ensure_depth_stencil_buffer (cairo_gl_context_t *ctx, cairo_gl_surface_t *surface) { + CAIRO_TRACE_BEGIN (__func__); cairo_gl_dispatch_t *dispatch = &ctx->dispatch; - if (surface->depth_stencil) + if (surface->depth_stencil) { + CAIRO_TRACE_END (__func__); return TRUE; + } _cairo_gl_ensure_framebuffer (ctx, surface); @@ -784,9 +825,11 @@ _cairo_gl_ensure_depth_stencil_buffer (cairo_gl_context_t *ctx, if (dispatch->CheckFramebufferStatus (GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) { dispatch->DeleteRenderbuffers (1, &surface->depth_stencil); surface->depth_stencil = 0; + CAIRO_TRACE_END (__func__); return FALSE; } + CAIRO_TRACE_END (__func__); return TRUE; } @@ -849,6 +892,7 @@ static void bind_multisample_framebuffer (cairo_gl_context_t *ctx, cairo_gl_surface_t *surface) { + CAIRO_TRACE_BEGIN (__func__); #if CAIRO_HAS_GL_SURFACE || CAIRO_HAS_EVASGL_SURFACE cairo_bool_t stencil_test_enabled = FALSE, scissor_test_enabled = FALSE; cairo_bool_t has_stencil_cache = FALSE; @@ -872,6 +916,7 @@ bind_multisample_framebuffer (cairo_gl_context_t *ctx, #endif ctx->dispatch.BindFramebuffer (GL_FRAMEBUFFER, surface->msaa_fb); + CAIRO_TRACE_END (__func__); return; } @@ -913,21 +958,25 @@ bind_multisample_framebuffer (cairo_gl_context_t *ctx, _enable_scissor_buffer (ctx); } #endif + CAIRO_TRACE_END (__func__); } static void bind_singlesample_framebuffer (cairo_gl_context_t *ctx, cairo_gl_surface_t *surface) { + CAIRO_TRACE_BEGIN (__func__); cairo_bool_t has_stencil_cache = surface->clip_on_stencil_buffer ? TRUE : FALSE; cairo_bool_t stencil_test_enabled; cairo_bool_t scissor_test_enabled; GLbitfield mask = GL_COLOR_BUFFER_BIT; if (ctx->gl_flavor == CAIRO_GL_FLAVOR_ES2 && - ! ctx->has_angle_multisampling) + ! ctx->has_angle_multisampling) { + CAIRO_TRACE_END (__func__); return; - + } + _cairo_gl_ensure_framebuffer (ctx, surface); if (! surface->msaa_active) { @@ -936,6 +985,7 @@ bind_singlesample_framebuffer (cairo_gl_context_t *ctx, ctx->dispatch.Disable (GL_MULTISAMPLE); #endif ctx->dispatch.BindFramebuffer (GL_FRAMEBUFFER, surface->fb); + CAIRO_TRACE_END (__func__); return; } @@ -984,6 +1034,7 @@ bind_singlesample_framebuffer (cairo_gl_context_t *ctx, _enable_stencil_buffer (ctx); if (scissor_test_enabled) _enable_scissor_buffer (ctx); + CAIRO_TRACE_END (__func__); } void @@ -991,6 +1042,7 @@ _cairo_gl_context_bind_framebuffer (cairo_gl_context_t *ctx, cairo_gl_surface_t *surface, cairo_bool_t multisampling) { + CAIRO_TRACE_BEGIN (__func__); if (_cairo_gl_surface_is_texture (surface)) { /* OpenGL ES surfaces only have either a multisample framebuffer or a * singlesample framebuffer, so we cannot switch back and forth. */ @@ -999,6 +1051,7 @@ _cairo_gl_context_bind_framebuffer (cairo_gl_context_t *ctx, _cairo_gl_ensure_framebuffer (ctx, surface); ctx->dispatch.BindFramebuffer (GL_FRAMEBUFFER, surface->fb); _cairo_gl_clear_framebuffer (ctx, surface); + CAIRO_TRACE_END (__func__); return; } @@ -1029,6 +1082,7 @@ _cairo_gl_context_bind_framebuffer (cairo_gl_context_t *ctx, if (ctx->gl_flavor != CAIRO_GL_FLAVOR_DESKTOP && multisampling) _cairo_gl_clear_framebuffer (ctx, surface); + CAIRO_TRACE_END (__func__); } void @@ -1036,6 +1090,7 @@ _cairo_gl_context_set_destination (cairo_gl_context_t *ctx, cairo_gl_surface_t *surface, cairo_bool_t multisampling) { + CAIRO_TRACE_BEGIN (__func__); cairo_bool_t changing_surface, changing_sampling; /* The decision whether or not to use multisampling happens when @@ -1050,11 +1105,13 @@ _cairo_gl_context_set_destination (cairo_gl_context_t *ctx, if (! changing_surface && ! changing_sampling) { if (surface->needs_update) _cairo_gl_composite_flush (ctx); + CAIRO_TRACE_END (__func__); return; } if (! changing_surface) { _cairo_gl_composite_flush (ctx); _cairo_gl_context_bind_framebuffer (ctx, surface, multisampling); + CAIRO_TRACE_END (__func__); return; } @@ -1094,6 +1151,7 @@ _cairo_gl_context_set_destination (cairo_gl_context_t *ctx, else _gl_identity_ortho (ctx->modelviewprojection_matrix, 0, surface->width, surface->height, 0); + CAIRO_TRACE_END (__func__); } void diff --git a/src/cairo-gl-msaa-compositor.c b/src/cairo-gl-msaa-compositor.c index 49717f0..888f7da 100644 --- a/src/cairo-gl-msaa-compositor.c +++ b/src/cairo-gl-msaa-compositor.c @@ -48,6 +48,7 @@ #include "cairo-path-private.h" #include "cairo-traps-private.h" #include "cairo-convex-fill-private.h" +#include "cairo-ttrace.h" static cairo_bool_t can_use_msaa_compositor (cairo_gl_surface_t *surface, @@ -238,15 +239,19 @@ _cairo_gl_msaa_compositor_draw_clip (cairo_gl_context_t *ctx, cairo_gl_composite_t *setup, cairo_clip_t *clip) { + CAIRO_TRACE_BEGIN (__func__); cairo_int_status_t status; cairo_traps_t traps; status = _clip_to_traps (clip, &traps); - if (unlikely (status)) + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); return status; + } status = _draw_traps (ctx, setup, &traps); _cairo_traps_fini (&traps); + CAIRO_TRACE_END (__func__); return status; } @@ -484,6 +489,7 @@ static cairo_int_status_t _cairo_gl_msaa_compositor_mask_source_operator (const cairo_compositor_t *compositor, cairo_composite_rectangles_t *composite) { + CAIRO_TRACE_BEGIN (__func__); cairo_gl_composite_t setup; cairo_gl_surface_t *dst = (cairo_gl_surface_t *) composite->surface; cairo_gl_context_t *ctx = NULL; @@ -502,22 +508,27 @@ _cairo_gl_msaa_compositor_mask_source_operator (const cairo_compositor_t *compos status = _clip_to_traps (clip, &traps); if (unlikely (status)) { _cairo_traps_fini (&traps); + CAIRO_TRACE_END (__func__); return status; } } if (! is_pixel_aligned) { status = _blit_texture_to_renderbuffer (dst); - if (unlikely (status)) + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); return status; + } } status = _cairo_gl_composite_init (&setup, CAIRO_OPERATOR_DEST_OUT, dst, FALSE /* assume_component_alpha */); - if (unlikely (status)) + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); return status; + } status = _cairo_gl_composite_set_source (&setup, composite->original_mask_pattern, &composite->mask_sample_area, @@ -583,6 +594,7 @@ finish: if (clip) _cairo_traps_fini (&traps); + CAIRO_TRACE_END (__func__); return status; } @@ -590,6 +602,7 @@ static cairo_int_status_t _cairo_gl_msaa_compositor_mask (const cairo_compositor_t *compositor, cairo_composite_rectangles_t *composite) { + CAIRO_TRACE_BEGIN (__func__); cairo_gl_composite_t setup; cairo_gl_surface_t *dst = (cairo_gl_surface_t *) composite->surface; cairo_gl_context_t *ctx = NULL; @@ -598,12 +611,16 @@ _cairo_gl_msaa_compositor_mask (const cairo_compositor_t *compositor, cairo_clip_t *clip = composite->clip; cairo_bool_t is_pixel_aligned = FALSE; - if (! can_use_msaa_compositor (dst, CAIRO_ANTIALIAS_DEFAULT)) + if (! can_use_msaa_compositor (dst, CAIRO_ANTIALIAS_DEFAULT)) { + CAIRO_TRACE_END (__func__); return CAIRO_INT_STATUS_UNSUPPORTED; + } if (composite->op == CAIRO_OPERATOR_CLEAR && - composite->original_mask_pattern != NULL) + composite->original_mask_pattern != NULL) { + CAIRO_TRACE_END (__func__); return CAIRO_INT_STATUS_UNSUPPORTED; + } /* GL compositing operators cannot properly represent a mask operation using the SOURCE compositing operator in one pass. This only matters if @@ -616,6 +633,7 @@ _cairo_gl_msaa_compositor_mask (const cairo_compositor_t *compositor, if (! _cairo_pattern_is_opaque (&composite->source_pattern.base, &composite->source_sample_area)) { + CAIRO_TRACE_END (__func__); return _cairo_gl_msaa_compositor_mask_source_operator (compositor, composite); } @@ -626,8 +644,10 @@ _cairo_gl_msaa_compositor_mask (const cairo_compositor_t *compositor, if (_should_use_unbounded_surface (composite)) { cairo_surface_t* surface = _prepare_unbounded_surface (dst); - if (unlikely (surface == NULL)) + if (unlikely (surface == NULL)) { + CAIRO_TRACE_END (__func__); return CAIRO_INT_STATUS_UNSUPPORTED; + } /* This may be a paint operation. */ if (composite->original_mask_pattern == NULL) { @@ -645,9 +665,11 @@ _cairo_gl_msaa_compositor_mask (const cairo_compositor_t *compositor, if (unlikely (status)) { cairo_surface_destroy (surface); + CAIRO_TRACE_END (__func__); return status; } + CAIRO_TRACE_END (__func__); return _paint_back_unbounded_surface (compositor, composite, surface); } @@ -658,16 +680,20 @@ _cairo_gl_msaa_compositor_mask (const cairo_compositor_t *compositor, if (! is_pixel_aligned) { status = _blit_texture_to_renderbuffer (dst); - if (unlikely (status)) + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); return status; + } } status = _cairo_gl_composite_init (&setup, op, dst, FALSE /* assume_component_alpha */); - if (unlikely (status)) + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); return status; + } status = _cairo_gl_composite_set_source (&setup, composite->original_source_pattern, @@ -719,7 +745,7 @@ _cairo_gl_msaa_compositor_mask (const cairo_compositor_t *compositor, if (clip) { cairo_clip_t *clip_copy = _cairo_clip_copy (clip); - + clip_copy = _cairo_clip_intersect_rectangle (clip_copy, &rect); status = _cairo_gl_msaa_compositor_draw_clip (ctx, &setup, clip_copy); @@ -740,6 +766,7 @@ finish: if (ctx) status = _cairo_gl_context_release (ctx, status); + CAIRO_TRACE_END (__func__); return status; } @@ -963,24 +990,28 @@ _cairo_gl_msaa_compositor_stroke (const cairo_compositor_t *compositor, double tolerance, cairo_antialias_t antialias) { + CAIRO_TRACE_BEGIN (__func__); cairo_int_status_t status; cairo_gl_surface_t *dst = (cairo_gl_surface_t *) composite->surface; struct _tristrip_composite_info info; cairo_bool_t use_color_attribute; cairo_rectangle_int_t stroke_extents; - if (! can_use_msaa_compositor (dst, antialias)) + if (! can_use_msaa_compositor (dst, antialias)) { + CAIRO_TRACE_END (__func__); return CAIRO_INT_STATUS_UNSUPPORTED; + } if (! _cairo_path_fixed_stroke_is_rectilinear (path)) { _cairo_path_fixed_approximate_fill_extents (path, &stroke_extents); if (stroke_extents.width != 0 && stroke_extents.height != 0) { - if ((stroke_extents.width / stroke_extents.height > 10 && + if ((stroke_extents.width / stroke_extents.height > 10 && stroke_extents.height < 10) || - (stroke_extents.height / stroke_extents.width > 10 && + (stroke_extents.height / stroke_extents.width > 10 && stroke_extents.width < 10)) { + CAIRO_TRACE_END (__func__); return CAIRO_INT_STATUS_UNSUPPORTED; } } @@ -989,8 +1020,10 @@ _cairo_gl_msaa_compositor_stroke (const cairo_compositor_t *compositor, if (composite->is_bounded == FALSE) { cairo_surface_t* surface = _prepare_unbounded_surface (dst); - if (unlikely (surface == NULL)) + if (unlikely (surface == NULL)) { + CAIRO_TRACE_END (__func__); return CAIRO_INT_STATUS_UNSUPPORTED; + } status = _cairo_compositor_stroke (compositor, surface, CAIRO_OPERATOR_SOURCE, @@ -999,24 +1032,30 @@ _cairo_gl_msaa_compositor_stroke (const cairo_compositor_t *compositor, tolerance, antialias, NULL); if (unlikely (status)) { cairo_surface_destroy (surface); + CAIRO_TRACE_END (__func__); return status; } + CAIRO_TRACE_END (__func__); return _paint_back_unbounded_surface (compositor, composite, surface); } if (antialias != CAIRO_ANTIALIAS_NONE) { status = _blit_texture_to_renderbuffer (dst); - if (unlikely (status)) + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); return status; + } } status = _cairo_gl_composite_init (&info.setup, composite->op, dst, FALSE /* assume_component_alpha */); - if (unlikely (status)) + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); return status; + } info.ctx = NULL; use_color_attribute = _cairo_gl_hairline_style_is_hairline (style, ctm); @@ -1102,6 +1141,7 @@ finish: if (info.ctx) status = _cairo_gl_context_release (info.ctx, status); + CAIRO_TRACE_END (__func__); return status; } @@ -1136,6 +1176,7 @@ _cairo_gl_msaa_compositor_fill (const cairo_compositor_t *compositor, double tolerance, cairo_antialias_t antialias) { + CAIRO_TRACE_BEGIN (__func__); cairo_gl_composite_t setup; cairo_gl_surface_t *dst = (cairo_gl_surface_t *) composite->surface; cairo_gl_context_t *ctx = NULL; @@ -1145,17 +1186,20 @@ _cairo_gl_msaa_compositor_fill (const cairo_compositor_t *compositor, cairo_rectangle_int_t fill_extents; struct _tristrip_composite_info info; - if (! can_use_msaa_compositor (dst, antialias)) + if (! can_use_msaa_compositor (dst, antialias)) { + CAIRO_TRACE_END (__func__); return CAIRO_INT_STATUS_UNSUPPORTED; + } if (! _cairo_path_fixed_fill_is_rectilinear (path)) { _cairo_path_fixed_approximate_fill_extents (path, &fill_extents); if (fill_extents.width != 0 && fill_extents.height != 0) { - if ((fill_extents.width / fill_extents.height > 10 && + if ((fill_extents.width / fill_extents.height > 10 && fill_extents.height < 10) || - (fill_extents.height / fill_extents.width > 10 && + (fill_extents.height / fill_extents.width > 10 && fill_extents.width < 10)) { + CAIRO_TRACE_END (__func__); return CAIRO_INT_STATUS_UNSUPPORTED; } } @@ -1164,8 +1208,10 @@ _cairo_gl_msaa_compositor_fill (const cairo_compositor_t *compositor, if (composite->is_bounded == FALSE) { cairo_surface_t* surface = _prepare_unbounded_surface (dst); - if (unlikely (surface == NULL)) + if (unlikely (surface == NULL)) { + CAIRO_TRACE_END (__func__); return CAIRO_INT_STATUS_UNSUPPORTED; + } status = _cairo_compositor_fill (compositor, surface, @@ -1176,16 +1222,20 @@ _cairo_gl_msaa_compositor_fill (const cairo_compositor_t *compositor, if (unlikely (status)) { cairo_surface_destroy (surface); + CAIRO_TRACE_END (__func__); return status; } + CAIRO_TRACE_END (__func__); return _paint_back_unbounded_surface (compositor, composite, surface); } if (antialias != CAIRO_ANTIALIAS_NONE) { status = _blit_texture_to_renderbuffer (dst); - if (unlikely (status)) + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); return status; + } } draw_path_with_traps = ! _cairo_path_fixed_is_simple_quad (path); @@ -1208,7 +1258,7 @@ _cairo_gl_msaa_compositor_fill (const cairo_compositor_t *compositor, _cairo_gl_msaa_compositor_set_clip (composite, &setup); if (antialias != CAIRO_ANTIALIAS_NONE) _cairo_gl_composite_set_multisample (&setup); - + status = _cairo_gl_composite_begin (&setup, &ctx); if (unlikely (status)) goto cleanup_setup; @@ -1261,6 +1311,7 @@ cleanup_traps: if (draw_path_with_traps && !path->is_convex) _cairo_traps_fini (&traps); + CAIRO_TRACE_END (__func__); return status; } @@ -1272,6 +1323,7 @@ _cairo_gl_msaa_compositor_glyphs (const cairo_compositor_t *compositor, int num_glyphs, cairo_bool_t overlap) { + CAIRO_TRACE_BEGIN (__func__); cairo_int_status_t status; cairo_surface_t *src = NULL; int src_x, src_y; @@ -1280,17 +1332,23 @@ _cairo_gl_msaa_compositor_glyphs (const cairo_compositor_t *compositor, cairo_gl_surface_t *dst = (cairo_gl_surface_t *) composite->surface; query_surface_capabilities (dst); - if (! dst->supports_stencil) + if (! dst->supports_stencil) { + CAIRO_TRACE_END (__func__); return CAIRO_INT_STATUS_UNSUPPORTED; + } - if (composite->op == CAIRO_OPERATOR_CLEAR) + if (composite->op == CAIRO_OPERATOR_CLEAR) { + CAIRO_TRACE_END (__func__); return CAIRO_INT_STATUS_UNSUPPORTED; + } if (composite->is_bounded == FALSE) { cairo_surface_t* surface = _prepare_unbounded_surface (dst); - if (unlikely (surface == NULL)) + if (unlikely (surface == NULL)) { + CAIRO_TRACE_END (__func__); return CAIRO_INT_STATUS_UNSUPPORTED; + } status = _cairo_compositor_glyphs (compositor, surface, CAIRO_OPERATOR_SOURCE, @@ -1300,9 +1358,11 @@ _cairo_gl_msaa_compositor_glyphs (const cairo_compositor_t *compositor, if (unlikely (status)) { cairo_surface_destroy (surface); + CAIRO_TRACE_END (__func__); return status; } + CAIRO_TRACE_END (__func__); return _paint_back_unbounded_surface (compositor, composite, surface); } /* @@ -1351,7 +1411,7 @@ _cairo_gl_msaa_compositor_glyphs (const cairo_compositor_t *compositor, finish: if (src) cairo_surface_destroy (src); - + CAIRO_TRACE_END (__func__); return status; } @@ -1359,6 +1419,7 @@ static void _cairo_gl_msaa_compositor_init (cairo_compositor_t *compositor, const cairo_compositor_t *delegate) { + CAIRO_TRACE_BEGIN (__func__); compositor->delegate = delegate; compositor->lazy_init = TRUE; compositor->paint = _cairo_gl_msaa_compositor_paint; @@ -1366,6 +1427,7 @@ _cairo_gl_msaa_compositor_init (cairo_compositor_t *compositor, compositor->fill = _cairo_gl_msaa_compositor_fill; compositor->stroke = _cairo_gl_msaa_compositor_stroke; compositor->glyphs = _cairo_gl_msaa_compositor_glyphs; + CAIRO_TRACE_END (__func__); } const cairo_compositor_t * diff --git a/src/cairo-gl-surface.c b/src/cairo-gl-surface.c index 7938f30..52c0772 100644 --- a/src/cairo-gl-surface.c +++ b/src/cairo-gl-surface.c @@ -50,6 +50,7 @@ #include "cairo-surface-backend-private.h" #include "cairo-surface-shadow-private.h" #include "cairo-surface-scale-translate-private.h" +#include "cairo-ttrace.h" static const cairo_surface_backend_t _cairo_gl_surface_backend; @@ -67,16 +68,19 @@ _cairo_gl_surface_shadow_surface (void *surface, int width, int height, int *width_out, int *height_out) { + CAIRO_TRACE_BEGIN (__func__); int shadow_width, shadow_height; cairo_gl_surface_t *shadow_surface = NULL; cairo_gl_surface_t *dst = (cairo_gl_surface_t *)surface; cairo_gl_context_t *ctx = (cairo_gl_context_t *)dst->base.device; - if (ctx == NULL) + if (ctx == NULL) { + CAIRO_TRACE_END (__func__); return NULL; + } shadow_surface = ctx->shadow_scratch_surfaces[0]; - + if (shadow_surface) { shadow_width = shadow_surface->width; shadow_height = shadow_surface->height; @@ -86,6 +90,7 @@ _cairo_gl_surface_shadow_surface (void *surface, shadow_height >= height) { *width_out = width; *height_out = height; + CAIRO_TRACE_END (__func__); return cairo_surface_reference (&shadow_surface->base); } else { @@ -161,6 +166,7 @@ _cairo_gl_surface_shadow_surface (void *surface, shadow_height); if (unlikely (shadow_surface->base.status)) { cairo_surface_destroy (&shadow_surface->base); + CAIRO_TRACE_END (__func__); return NULL; } @@ -191,6 +197,7 @@ _cairo_gl_surface_shadow_surface (void *surface, *height_out *= 0.5; } + CAIRO_TRACE_END (__func__); return cairo_surface_reference (&shadow_surface->base); } @@ -199,15 +206,20 @@ _cairo_gl_surface_shadow_mask_surface (void *surface, int width, int height, unsigned int index) { + CAIRO_TRACE_BEGIN (__func__); cairo_gl_surface_t *mask_surface = NULL; cairo_gl_surface_t *dst = (cairo_gl_surface_t *)surface; cairo_gl_context_t *ctx = (cairo_gl_context_t *)dst->base.device; - if (ctx == NULL) + if (ctx == NULL) { + CAIRO_TRACE_END (__func__); return NULL; + } - if (index > 1) + if (index > 1) { + CAIRO_TRACE_END (__func__); return NULL; + } mask_surface = ctx->shadow_masks[index]; @@ -228,6 +240,7 @@ _cairo_gl_surface_shadow_mask_surface (void *surface, height); if (unlikely (mask_surface->base.status)) { cairo_surface_destroy (&mask_surface->base); + CAIRO_TRACE_END (__func__); return NULL; } _cairo_surface_release_device_reference (&mask_surface->base); @@ -237,7 +250,7 @@ _cairo_gl_surface_shadow_mask_surface (void *surface, mask_surface->needs_to_cache = FALSE; mask_surface->force_no_cache = TRUE; - + CAIRO_TRACE_END (__func__); return cairo_surface_reference (&mask_surface->base); } @@ -246,19 +259,22 @@ _cairo_gl_surface_glyph_shadow_surface (void *surface, int width, int height, cairo_bool_t for_source) { + CAIRO_TRACE_BEGIN (__func__); int shadow_width, shadow_height; cairo_gl_surface_t *shadow_surface = NULL; cairo_gl_surface_t *dst = (cairo_gl_surface_t *)surface; cairo_gl_context_t *ctx = (cairo_gl_context_t *)dst->base.device; - if (ctx == NULL) + if (ctx == NULL) { + CAIRO_TRACE_END (__func__); return NULL; + } if (! for_source) shadow_surface = ctx->shadow_scratch_surfaces[1]; else shadow_surface = ctx->shadow_scratch_surfaces[2]; - + if (shadow_surface) { shadow_width = shadow_surface->width; shadow_height = shadow_surface->height; @@ -273,10 +289,11 @@ _cairo_gl_surface_glyph_shadow_surface (void *surface, if (! shadow_surface) { shadow_surface = (cairo_gl_surface_t *) _cairo_gl_surface_create_scratch (ctx, - CAIRO_CONTENT_COLOR_ALPHA, + CAIRO_CONTENT_COLOR_ALPHA, width, height); if (unlikely (shadow_surface->base.status)) { cairo_surface_destroy (&shadow_surface->base); + CAIRO_TRACE_END (__func__); return NULL; } _cairo_surface_release_device_reference (&shadow_surface->base); @@ -290,6 +307,7 @@ _cairo_gl_surface_glyph_shadow_surface (void *surface, shadow_surface->needs_to_cache = FALSE; shadow_surface->force_no_cache = TRUE; + CAIRO_TRACE_END (__func__); return cairo_surface_reference (&shadow_surface->base); } @@ -298,21 +316,26 @@ _cairo_gl_surface_glyph_shadow_mask_surface (void *surface, int width, int height, unsigned index) { + CAIRO_TRACE_BEGIN (__func__); cairo_gl_surface_t *mask_surface = NULL; cairo_gl_surface_t *dst = (cairo_gl_surface_t *)surface; cairo_gl_context_t *ctx = (cairo_gl_context_t *)dst->base.device; - if (ctx == NULL) + if (ctx == NULL) { + CAIRO_TRACE_END (__func__); return NULL; + } - if (index > 1) + if (index > 1) { + CAIRO_TRACE_END (__func__); return NULL; + } mask_surface = ctx->shadow_masks[index + 2]; - + if (mask_surface) { if (mask_surface->width != width || - mask_surface->height != height) { + mask_surface->height != height) { cairo_surface_destroy (&mask_surface->base); mask_surface = NULL; ctx->shadow_masks[index + 2] = NULL; @@ -327,6 +350,7 @@ _cairo_gl_surface_glyph_shadow_mask_surface (void *surface, height); if (unlikely (mask_surface->base.status)) { cairo_surface_destroy (&mask_surface->base); + CAIRO_TRACE_END (__func__); return NULL; } _cairo_surface_release_device_reference (&mask_surface->base); @@ -337,6 +361,7 @@ _cairo_gl_surface_glyph_shadow_mask_surface (void *surface, mask_surface->needs_to_cache = FALSE; mask_surface->force_no_cache = TRUE; + CAIRO_TRACE_END (__func__); return cairo_surface_reference (&mask_surface->base); } @@ -666,6 +691,7 @@ _cairo_gl_surface_init (cairo_device_t *device, cairo_content_t content, int width, int height) { + CAIRO_TRACE_BEGIN (__func__); assert (width > 0 && height > 0); _cairo_surface_init (&surface->base, @@ -691,6 +717,7 @@ _cairo_gl_surface_init (cairo_device_t *device, surface->content_cleared = FALSE; _cairo_gl_surface_embedded_operand_init (surface); + CAIRO_TRACE_END (__func__); } static cairo_bool_t @@ -717,11 +744,14 @@ _cairo_gl_surface_create_scratch_for_texture (cairo_gl_context_t *ctx, int width, int height) { + CAIRO_TRACE_BEGIN (__func__); cairo_gl_surface_t *surface; surface = calloc (1, sizeof (cairo_gl_surface_t)); - if (unlikely (surface == NULL)) + if (unlikely (surface == NULL)) { + CAIRO_TRACE_END (__func__); return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY)); + } surface->tex = tex; _cairo_gl_surface_init (&ctx->base, surface, content, width, height); @@ -736,6 +766,7 @@ _cairo_gl_surface_create_scratch_for_texture (cairo_gl_context_t *ctx, ctx->dispatch.TexParameteri (ctx->tex_target, GL_TEXTURE_MIN_FILTER, GL_NEAREST); ctx->dispatch.TexParameteri (ctx->tex_target, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + CAIRO_TRACE_END (__func__); return &surface->base; } @@ -746,6 +777,7 @@ _create_scratch_internal (cairo_gl_context_t *ctx, int height, cairo_bool_t for_caching) { + CAIRO_TRACE_BEGIN (__func__); cairo_gl_surface_t *surface; GLenum format; GLuint tex; @@ -754,8 +786,10 @@ _create_scratch_internal (cairo_gl_context_t *ctx, surface = (cairo_gl_surface_t *) _cairo_gl_surface_create_scratch_for_texture (ctx, content, tex, width, height); - if (unlikely (surface->base.status)) + if (unlikely (surface->base.status)) { + CAIRO_TRACE_END (__func__); return &surface->base; + } surface->owns_tex = TRUE; @@ -797,6 +831,7 @@ _create_scratch_internal (cairo_gl_context_t *ctx, width, height, 0, format, GL_UNSIGNED_BYTE, NULL); + CAIRO_TRACE_END (__func__); return &surface->base; } @@ -822,13 +857,16 @@ static cairo_status_t _cairo_gl_surface_clear (cairo_gl_surface_t *surface, const cairo_color_t *color) { + CAIRO_TRACE_BEGIN (__func__); cairo_gl_context_t *ctx; cairo_status_t status; double r, g, b, a; status = _cairo_gl_context_acquire (surface->base.device, &ctx); - if (unlikely (status)) + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); return status; + } if (ctx->current_target == surface) _cairo_gl_composite_flush (ctx); @@ -887,6 +925,7 @@ _cairo_gl_surface_clear (cairo_gl_surface_t *surface, surface->content_changed = TRUE; surface->content_synced = FALSE; surface->content_cleared = TRUE; + CAIRO_TRACE_END (__func__); return _cairo_gl_context_release (ctx, status); } @@ -896,21 +935,26 @@ _cairo_gl_surface_create_and_clear_scratch (cairo_gl_context_t *ctx, int width, int height) { + CAIRO_TRACE_BEGIN (__func__); cairo_gl_surface_t *surface; cairo_int_status_t status; surface = (cairo_gl_surface_t *) _cairo_gl_surface_create_scratch (ctx, content, width, height); - if (unlikely (surface->base.status)) + if (unlikely (surface->base.status)) { + CAIRO_TRACE_END (__func__); return &surface->base; + } /* Cairo surfaces start out initialized to transparent (black) */ status = _cairo_gl_surface_clear (surface, CAIRO_COLOR_TRANSPARENT); if (unlikely (status)) { cairo_surface_destroy (&surface->base); + CAIRO_TRACE_END (__func__); return _cairo_surface_create_in_error (status); } + CAIRO_TRACE_END (__func__); return &surface->base; } @@ -920,28 +964,40 @@ cairo_gl_surface_create (cairo_device_t *abstract_device, int width, int height) { + CAIRO_TRACE_BEGIN (__func__); cairo_gl_context_t *ctx; cairo_gl_surface_t *surface; cairo_status_t status; - if (! CAIRO_CONTENT_VALID (content)) + if (! CAIRO_CONTENT_VALID (content)) { + CAIRO_TRACE_END (__func__); return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_CONTENT)); + } - if (abstract_device == NULL) + if (abstract_device == NULL) { + CAIRO_TRACE_END (__func__); return _cairo_image_surface_create_with_content (content, width, height); + } - if (abstract_device->status) + if (abstract_device->status) { + CAIRO_TRACE_END (__func__); return _cairo_surface_create_in_error (abstract_device->status); + } - if (abstract_device->backend->type != CAIRO_DEVICE_TYPE_GL) + if (abstract_device->backend->type != CAIRO_DEVICE_TYPE_GL) { + CAIRO_TRACE_END (__func__); return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_SURFACE_TYPE_MISMATCH)); + } status = _cairo_gl_context_acquire (abstract_device, &ctx); - if (unlikely (status)) + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); return _cairo_surface_create_in_error (status); + } if (! _cairo_gl_surface_size_valid_for_context (ctx, width, height)) { status = _cairo_gl_context_release (ctx, status); + CAIRO_TRACE_END (__func__); return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_SIZE)); } @@ -950,15 +1006,18 @@ cairo_gl_surface_create (cairo_device_t *abstract_device, if (unlikely (surface->base.status)) { status = _cairo_gl_context_release (ctx, surface->base.status); cairo_surface_destroy (&surface->base); + CAIRO_TRACE_END (__func__); return _cairo_surface_create_in_error (status); } status = _cairo_gl_context_release (ctx, status); if (unlikely (status)) { cairo_surface_destroy (&surface->base); + CAIRO_TRACE_END (__func__); return _cairo_surface_create_in_error (status); } + CAIRO_TRACE_END (__func__); return &surface->base; } slim_hidden_def (cairo_gl_surface_create); @@ -997,28 +1056,40 @@ cairo_gl_surface_create_for_texture (cairo_device_t *abstract_device, int width, int height) { + CAIRO_TRACE_BEGIN (__func__); cairo_gl_context_t *ctx; cairo_gl_surface_t *surface; cairo_status_t status; - if (! CAIRO_CONTENT_VALID (content)) + if (! CAIRO_CONTENT_VALID (content)) { + CAIRO_TRACE_END (__func__); return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_CONTENT)); + } - if (abstract_device == NULL) + if (abstract_device == NULL) { + CAIRO_TRACE_END (__func__); return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NULL_POINTER)); + } - if (abstract_device->status) + if (abstract_device->status) { + CAIRO_TRACE_END (__func__); return _cairo_surface_create_in_error (abstract_device->status); + } - if (abstract_device->backend->type != CAIRO_DEVICE_TYPE_GL) + if (abstract_device->backend->type != CAIRO_DEVICE_TYPE_GL) { + CAIRO_TRACE_END (__func__); return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_DEVICE_TYPE_MISMATCH)); + } status = _cairo_gl_context_acquire (abstract_device, &ctx); - if (unlikely (status)) + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); return _cairo_surface_create_in_error (status); + } if (! _cairo_gl_surface_size_valid_for_context (ctx, width, height)) { status = _cairo_gl_context_release (ctx, status); + CAIRO_TRACE_END (__func__); return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_SIZE)); } @@ -1026,7 +1097,7 @@ cairo_gl_surface_create_for_texture (cairo_device_t *abstract_device, _cairo_gl_surface_create_scratch_for_texture (ctx, content, tex, width, height); status = _cairo_gl_context_release (ctx, status); - + CAIRO_TRACE_END (__func__); return &surface->base; } slim_hidden_def (cairo_gl_surface_create_for_texture); @@ -1088,17 +1159,22 @@ cairo_gl_surface_swapbuffers (cairo_surface_t *abstract_surface) { cairo_gl_surface_t *surface = (cairo_gl_surface_t *) abstract_surface; - if (unlikely (abstract_surface->status)) + if (unlikely (abstract_surface->status)) { + CAIRO_TRACE_END (__func__); return; + } if (unlikely (abstract_surface->finished)) { _cairo_surface_set_error (abstract_surface, _cairo_error (CAIRO_STATUS_SURFACE_FINISHED)); + CAIRO_TRACE_END (__func__); return; } if (! _cairo_surface_is_gl (abstract_surface)) { _cairo_surface_set_error (abstract_surface, CAIRO_STATUS_SURFACE_TYPE_MISMATCH); + + CAIRO_TRACE_END (__func__); return; } @@ -1107,8 +1183,11 @@ cairo_gl_surface_swapbuffers (cairo_surface_t *abstract_surface) cairo_status_t status; status = _cairo_gl_context_acquire (surface->base.device, &ctx); - if (unlikely (status)) + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); return; + } + /* And in any case we should flush any pending operations. */ _cairo_gl_composite_flush (ctx); @@ -1128,6 +1207,7 @@ cairo_gl_surface_swapbuffers (cairo_surface_t *abstract_surface) if (status) status = _cairo_surface_set_error (abstract_surface, status); } + CAIRO_TRACE_END (__func__); } static cairo_surface_t * @@ -1136,25 +1216,32 @@ _cairo_gl_surface_create_similar (void *abstract_surface, int width, int height) { + CAIRO_TRACE_BEGIN (__func__); cairo_surface_t *surface = abstract_surface; cairo_gl_context_t *ctx; cairo_status_t status; - if (! _cairo_gl_surface_size_valid (abstract_surface, width, height)) + if (! _cairo_gl_surface_size_valid (abstract_surface, width, height)) { + CAIRO_TRACE_END (__func__); return _cairo_image_surface_create_with_content (content, width, height); + } status = _cairo_gl_context_acquire (surface->device, &ctx); - if (unlikely (status)) + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); return _cairo_surface_create_in_error (status); + } surface = _cairo_gl_surface_create_and_clear_scratch (ctx, content, width, height); status = _cairo_gl_context_release (ctx, status); if (unlikely (status)) { cairo_surface_destroy (surface); + CAIRO_TRACE_END (__func__); return _cairo_surface_create_in_error (status); } + CAIRO_TRACE_END (__func__); return surface; } @@ -1164,6 +1251,7 @@ _cairo_gl_surface_fill_alpha_channel (cairo_gl_surface_t *dst, int x, int y, int width, int height) { + CAIRO_TRACE_BEGIN (__func__); cairo_gl_composite_t setup; cairo_status_t status; @@ -1191,6 +1279,7 @@ _cairo_gl_surface_fill_alpha_channel (cairo_gl_surface_t *dst, _cairo_gl_composite_flush (ctx); ctx->dispatch.ColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); + CAIRO_TRACE_END (__func__); return status; } @@ -1202,6 +1291,7 @@ _cairo_gl_surface_draw_image (cairo_gl_surface_t *dst, int dst_x, int dst_y, cairo_bool_t force_flush) { + CAIRO_TRACE_BEGIN (__func__); GLenum internal_format, format, type; cairo_bool_t has_alpha, needs_swap; cairo_image_surface_t *clone = NULL; @@ -1211,8 +1301,10 @@ _cairo_gl_surface_draw_image (cairo_gl_surface_t *dst, cairo_int_status_t status = CAIRO_INT_STATUS_SUCCESS; status = _cairo_gl_context_acquire (dst->base.device, &ctx); - if (unlikely (status)) + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); return status; + } if (_cairo_gl_get_flavor (&ctx->dispatch) == CAIRO_GL_FLAVOR_ES2 || _cairo_gl_get_flavor (&ctx->dispatch) == CAIRO_GL_FLAVOR_ES3) { @@ -1438,6 +1530,7 @@ FAIL: dst->content_synced = FALSE; } + CAIRO_TRACE_END (__func__); return status; } @@ -1453,13 +1546,16 @@ static int _cairo_gl_surface_flavor (cairo_gl_surface_t *surface) static cairo_status_t _cairo_gl_surface_finish (void *abstract_surface) { + CAIRO_TRACE_BEGIN (__func__); cairo_gl_surface_t *surface = abstract_surface; cairo_status_t status; cairo_gl_context_t *ctx; status = _cairo_gl_context_acquire (surface->base.device, &ctx); - if (unlikely (status)) + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); return status; + } if ((ctx->operands[CAIRO_GL_TEX_SOURCE].type == CAIRO_GL_OPERAND_TEXTURE || ctx->operands[CAIRO_GL_TEX_SOURCE].type == CAIRO_GL_OPERAND_GAUSSIAN) && @@ -1495,6 +1591,7 @@ _cairo_gl_surface_finish (void *abstract_surface) if (surface->clip_on_stencil_buffer) _cairo_clip_destroy (surface->clip_on_stencil_buffer); + CAIRO_TRACE_END (__func__); return _cairo_gl_context_release (ctx, status); } @@ -1502,6 +1599,7 @@ static cairo_image_surface_t * _cairo_gl_surface_map_to_image (void *abstract_surface, const cairo_rectangle_int_t *extents) { + CAIRO_TRACE_BEGIN (__func__); cairo_gl_surface_t *surface = abstract_surface; cairo_image_surface_t *image; cairo_gl_context_t *ctx; @@ -1514,6 +1612,7 @@ _cairo_gl_surface_map_to_image (void *abstract_surface, status = _cairo_gl_context_acquire (surface->base.device, &ctx); if (unlikely (status)) { + CAIRO_TRACE_END (__func__); return _cairo_image_surface_create_in_error (status); } @@ -1535,6 +1634,7 @@ _cairo_gl_surface_map_to_image (void *abstract_surface, cpp = 1; } else { ASSERT_NOT_REACHED; + CAIRO_TRACE_END (__func__); return NULL; } @@ -1571,6 +1671,7 @@ _cairo_gl_surface_map_to_image (void *abstract_surface, -1); if (unlikely (image->base.status)) { status = _cairo_gl_context_release (ctx, status); + CAIRO_TRACE_END (__func__); return image; } @@ -1580,6 +1681,7 @@ _cairo_gl_surface_map_to_image (void *abstract_surface, * is clear, we can avoid downloading data. */ if (surface->base.is_clear || surface->base.serial == 0) { status = _cairo_gl_context_release (ctx, status); + CAIRO_TRACE_END (__func__); return image; } @@ -1616,6 +1718,7 @@ _cairo_gl_surface_map_to_image (void *abstract_surface, status = _cairo_gl_context_release (ctx, status); if (unlikely (status)) { cairo_surface_destroy (&image->base); + CAIRO_TRACE_END (__func__); return _cairo_image_surface_create_in_error (status); } @@ -1629,6 +1732,7 @@ _cairo_gl_surface_map_to_image (void *abstract_surface, row = malloc (image->stride); if (unlikely (row == NULL)) { cairo_surface_destroy (&image->base); + CAIRO_TRACE_END (__func__); return _cairo_image_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY)); } } @@ -1647,6 +1751,7 @@ _cairo_gl_surface_map_to_image (void *abstract_surface, image->base.is_clear = FALSE; + CAIRO_TRACE_END (__func__); return image; } @@ -1696,6 +1801,7 @@ static cairo_int_status_t _cairo_gl_surface_unmap_image (void *abstract_surface, cairo_image_surface_t *image) { + CAIRO_TRACE_BEGIN (__func__); cairo_int_status_t status; status = _cairo_gl_surface_draw_image (abstract_surface, image, @@ -1708,6 +1814,7 @@ _cairo_gl_surface_unmap_image (void *abstract_surface, cairo_surface_finish (&image->base); cairo_surface_destroy (&image->base); + CAIRO_TRACE_END (__func__); return status; } @@ -1728,16 +1835,21 @@ _cairo_gl_surface_get_extents (void *abstract_surface, static cairo_status_t _cairo_gl_surface_flush (void *abstract_surface, unsigned flags) { + CAIRO_TRACE_BEGIN (__func__); cairo_gl_surface_t *surface = abstract_surface; cairo_status_t status; cairo_gl_context_t *ctx; - if (flags) + if (flags) { + CAIRO_TRACE_END (__func__); return CAIRO_STATUS_SUCCESS; + } status = _cairo_gl_context_acquire (surface->base.device, &ctx); - if (unlikely (status)) + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); return status; + } if (((ctx->operands[CAIRO_GL_TEX_SOURCE].type == CAIRO_GL_OPERAND_TEXTURE || ctx->operands[CAIRO_GL_TEX_SOURCE].type == CAIRO_GL_OPERAND_GAUSSIAN) && @@ -1754,6 +1866,7 @@ _cairo_gl_surface_flush (void *abstract_surface, unsigned flags) ctx->dispatch.Flush (); #endif + CAIRO_TRACE_END (__func__); return _cairo_gl_context_release (ctx, status); } @@ -1803,19 +1916,23 @@ _cairo_gl_surface_paint (void *surface, const cairo_pattern_t *source, const cairo_clip_t *clip) { + CAIRO_TRACE_BEGIN (__func__); cairo_int_status_t status; cairo_gl_surface_t *dst = (cairo_gl_surface_t *)surface; cairo_gl_context_t *ctx = (cairo_gl_context_t *)dst->base.device; status = cairo_device_acquire (dst->base.device); - if (unlikely (status)) + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); return status; + } status = _cairo_surface_shadow_paint (surface, op, source, clip, &source->shadow); ctx->source_scratch_in_use = FALSE; if (unlikely (status)) { - cairo_device_release (dst->base.device); + cairo_device_release (dst->base.device); + CAIRO_TRACE_END (__func__); return status; } @@ -1824,9 +1941,10 @@ _cairo_gl_surface_paint (void *surface, dst->content_changed = TRUE; dst->content_synced = FALSE; } - + ctx->source_scratch_in_use = FALSE; cairo_device_release (dst->base.device); + CAIRO_TRACE_END (__func__); return status; } @@ -1835,6 +1953,7 @@ _cairo_gl_surface_paint (void *surface, if (op == CAIRO_OPERATOR_CLEAR) { status = _cairo_gl_surface_clear (surface, CAIRO_COLOR_TRANSPARENT); cairo_device_release (dst->base.device); + CAIRO_TRACE_END (__func__); return status; } else if (source->type == CAIRO_PATTERN_TYPE_SOLID && @@ -1842,7 +1961,8 @@ _cairo_gl_surface_paint (void *surface, (op == CAIRO_OPERATOR_OVER && _cairo_pattern_is_opaque_solid (source)))) { status = _cairo_gl_surface_clear (surface, &((cairo_solid_pattern_t *) source)->color); - cairo_device_release (dst->base.device); + cairo_device_release (dst->base.device); + CAIRO_TRACE_END (__func__); return status; } } @@ -1853,9 +1973,10 @@ _cairo_gl_surface_paint (void *surface, dst->content_changed = TRUE; dst->content_synced = FALSE; } - + ctx->source_scratch_in_use = FALSE; cairo_device_release (dst->base.device); + CAIRO_TRACE_END (__func__); return status; } @@ -1866,19 +1987,23 @@ _cairo_gl_surface_mask (void *surface, const cairo_pattern_t *mask, const cairo_clip_t *clip) { + CAIRO_TRACE_BEGIN (__func__); cairo_int_status_t status; cairo_gl_surface_t *dst = (cairo_gl_surface_t *) surface; cairo_gl_context_t *ctx = (cairo_gl_context_t *)dst->base.device; status = cairo_device_acquire (dst->base.device); - if (unlikely (status)) + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); return status; + } status = _cairo_surface_shadow_mask (surface, op, source, mask, clip, &source->shadow); ctx->source_scratch_in_use = FALSE; if (unlikely (status)) { - cairo_device_release (dst->base.device); + cairo_device_release (dst->base.device); + CAIRO_TRACE_END (__func__); return status; } @@ -1886,10 +2011,11 @@ _cairo_gl_surface_mask (void *surface, if (status == CAIRO_INT_STATUS_SUCCESS) { dst->content_changed = TRUE; dst->content_synced = FALSE; - } - + } + ctx->source_scratch_in_use = FALSE; cairo_device_release (dst->base.device); + CAIRO_TRACE_END (__func__); return status; } @@ -1898,9 +2024,10 @@ _cairo_gl_surface_mask (void *surface, if (status == CAIRO_INT_STATUS_SUCCESS) { dst->content_changed = TRUE; dst->content_synced = FALSE; - + ctx->source_scratch_in_use = FALSE; cairo_device_release (dst->base.device); + CAIRO_TRACE_END (__func__); return status; } @@ -1913,6 +2040,7 @@ _cairo_gl_surface_mask (void *surface, ctx->source_scratch_in_use = FALSE; cairo_device_release (dst->base.device); + CAIRO_TRACE_END (__func__); return status; } @@ -1928,14 +2056,17 @@ _cairo_gl_surface_stroke (void *surface, cairo_antialias_t antialias, const cairo_clip_t *clip) { + CAIRO_TRACE_BEGIN (__func__); cairo_int_status_t status; cairo_gl_surface_t *dst = (cairo_gl_surface_t *)surface; cairo_gl_context_t *ctx = (cairo_gl_context_t *)dst->base.device; cairo_shadow_type_t shadow_type = source->shadow.type; status = cairo_device_acquire (dst->base.device); - if (unlikely (status)) + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); return status; + } if (shadow_type != CAIRO_SHADOW_INSET) status = _cairo_surface_shadow_stroke (surface, op, source, path, @@ -1946,6 +2077,7 @@ _cairo_gl_surface_stroke (void *surface, ctx->source_scratch_in_use = FALSE; if (unlikely (status)) { cairo_device_release (dst->base.device); + CAIRO_TRACE_END (__func__); return status; } @@ -1956,6 +2088,7 @@ _cairo_gl_surface_stroke (void *surface, source->shadow.draw_shadow_only) { ctx->source_scratch_in_use = FALSE; cairo_device_release (dst->base.device); + CAIRO_TRACE_END (__func__); return status; } @@ -1969,6 +2102,7 @@ _cairo_gl_surface_stroke (void *surface, if (unlikely (status)) { ctx->source_scratch_in_use = FALSE; cairo_device_release (dst->base.device); + CAIRO_TRACE_END (__func__); return status; } @@ -1982,6 +2116,7 @@ _cairo_gl_surface_stroke (void *surface, ctx->source_scratch_in_use = FALSE; cairo_device_release (dst->base.device); + CAIRO_TRACE_END (__func__); return status; } @@ -1995,14 +2130,17 @@ _cairo_gl_surface_fill (void *surface, cairo_antialias_t antialias, const cairo_clip_t *clip) { + CAIRO_TRACE_BEGIN (__func__); cairo_status_t status; cairo_gl_surface_t *dst = (cairo_gl_surface_t *)surface; cairo_gl_context_t *ctx = (cairo_gl_context_t *)dst->base.device; cairo_shadow_type_t shadow_type = source->shadow.type; status = cairo_device_acquire (dst->base.device); - if (unlikely (status)) + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); return status; + } if (shadow_type != CAIRO_SHADOW_INSET) status = _cairo_surface_shadow_fill (surface, op, source, path, @@ -2012,6 +2150,7 @@ _cairo_gl_surface_fill (void *surface, ctx->source_scratch_in_use = FALSE; if (unlikely (status)) { cairo_device_release (dst->base.device); + CAIRO_TRACE_END (__func__); return status; } @@ -2022,6 +2161,7 @@ _cairo_gl_surface_fill (void *surface, source->shadow.draw_shadow_only) { ctx->source_scratch_in_use = FALSE; cairo_device_release (dst->base.device); + CAIRO_TRACE_END (__func__); return status; } @@ -2045,6 +2185,7 @@ _cairo_gl_surface_fill (void *surface, if (unlikely (status)) { ctx->source_scratch_in_use = FALSE; cairo_device_release (dst->base.device); + CAIRO_TRACE_END (__func__); return status; } @@ -2057,6 +2198,8 @@ _cairo_gl_surface_fill (void *surface, ctx->source_scratch_in_use = FALSE; cairo_device_release (dst->base.device); + + CAIRO_TRACE_END (__func__); return status; } @@ -2069,14 +2212,17 @@ _cairo_gl_surface_glyphs (void *surface, cairo_scaled_font_t *font, const cairo_clip_t *clip) { + CAIRO_TRACE_BEGIN (__func__); cairo_int_status_t status; cairo_gl_surface_t *dst = (cairo_gl_surface_t *)surface; cairo_gl_context_t *ctx = (cairo_gl_context_t *)dst->base.device; cairo_shadow_type_t shadow_type = source->shadow.type; status = cairo_device_acquire (dst->base.device); - if (unlikely (status)) + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); return status; + } if (shadow_type != CAIRO_SHADOW_INSET) status = _cairo_surface_shadow_glyphs (surface, op, source, @@ -2087,6 +2233,7 @@ _cairo_gl_surface_glyphs (void *surface, ctx->source_scratch_in_use = FALSE; if (unlikely (status)) { cairo_device_release (dst->base.device); + CAIRO_TRACE_END (__func__); return status; } @@ -2097,6 +2244,7 @@ _cairo_gl_surface_glyphs (void *surface, source->shadow.draw_shadow_only) { ctx->source_scratch_in_use = FALSE; cairo_device_release (dst->base.device); + CAIRO_TRACE_END (__func__); return status; } @@ -2110,6 +2258,7 @@ _cairo_gl_surface_glyphs (void *surface, if (unlikely (status)) { ctx->source_scratch_in_use = FALSE; cairo_device_release (dst->base.device); + CAIRO_TRACE_END (__func__); return status; } @@ -2123,6 +2272,7 @@ _cairo_gl_surface_glyphs (void *surface, ctx->source_scratch_in_use = FALSE; cairo_device_release (dst->base.device); + CAIRO_TRACE_END (__func__); return status; } diff --git a/src/cairo-gstate.c b/src/cairo-gstate.c index c747b3f..cb64445 100644 --- a/src/cairo-gstate.c +++ b/src/cairo-gstate.c @@ -44,6 +44,7 @@ #include "cairo-gstate-private.h" #include "cairo-pattern-private.h" #include "cairo-traps-private.h" +#include "cairo-ttrace.h" #if _XOPEN_SOURCE >= 600 || defined (_ISOC99_SOURCE) #define ISFINITE(x) isfinite (x) @@ -105,6 +106,7 @@ cairo_status_t _cairo_gstate_init (cairo_gstate_t *gstate, cairo_surface_t *target) { + CAIRO_TRACE_BEGIN (__func__); VG (VALGRIND_MAKE_MEM_UNDEFINED (gstate, sizeof (cairo_gstate_t))); gstate->next = NULL; @@ -151,6 +153,7 @@ _cairo_gstate_init (cairo_gstate_t *gstate, /* Now that the gstate is fully initialized and ready for the eventual * _cairo_gstate_fini(), we can check for errors (and not worry about * the resource deallocation). */ + CAIRO_TRACE_END (__func__); return target->status; } @@ -217,6 +220,7 @@ _cairo_gstate_init_copy (cairo_gstate_t *gstate, cairo_gstate_t *other) void _cairo_gstate_fini (cairo_gstate_t *gstate) { + CAIRO_TRACE_BEGIN (__func__); _cairo_stroke_style_fini (&gstate->stroke_style); cairo_font_face_destroy (gstate->font_face); @@ -246,6 +250,7 @@ _cairo_gstate_fini (cairo_gstate_t *gstate) memset (&gstate->shadow, 0, sizeof (cairo_shadow_t)); + CAIRO_TRACE_END (__func__); VG (VALGRIND_MAKE_MEM_NOACCESS (gstate, sizeof (cairo_gstate_t))); } @@ -416,14 +421,18 @@ cairo_status_t _cairo_gstate_set_source (cairo_gstate_t *gstate, cairo_pattern_t *source) { - if (source->status) + CAIRO_TRACE_BEGIN (__func__); + if (source->status) { + CAIRO_TRACE_END (__func__); return source->status; + } source = cairo_pattern_reference (source); cairo_pattern_destroy (gstate->source); gstate->source = source; gstate->source_ctm_inverse = gstate->ctm_inverse; + CAIRO_TRACE_END (__func__); return CAIRO_STATUS_SUCCESS; } @@ -1065,6 +1074,7 @@ _cairo_gstate_get_pattern_status (const cairo_pattern_t *pattern) cairo_status_t _cairo_gstate_paint (cairo_gstate_t *gstate) { + CAIRO_TRACE_BEGIN (__func__); cairo_pattern_union_t source_pattern; const cairo_pattern_t *pattern; cairo_status_t status; @@ -1072,14 +1082,20 @@ _cairo_gstate_paint (cairo_gstate_t *gstate) cairo_bool_t destroy_pattern = FALSE; status = _cairo_gstate_get_pattern_status (gstate->source); - if (unlikely (status)) + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); return status; + } - if (gstate->op == CAIRO_OPERATOR_DEST) + if (gstate->op == CAIRO_OPERATOR_DEST) { + CAIRO_TRACE_END (__func__); return CAIRO_STATUS_SUCCESS; + } - if (_cairo_clip_is_all_clipped (gstate->clip)) + if (_cairo_clip_is_all_clipped (gstate->clip)) { + CAIRO_TRACE_END (__func__); return CAIRO_STATUS_SUCCESS; + } if (gstate->source->filter == CAIRO_FILTER_GAUSSIAN) status = _cairo_pattern_create_gaussian_matrix (gstate->source, 1024); @@ -1087,7 +1103,7 @@ _cairo_gstate_paint (cairo_gstate_t *gstate) op = _reduce_op (gstate); /* do not use static pattern */ if (op == CAIRO_OPERATOR_CLEAR) { - if (! _cairo_gstate_has_shadow (gstate)) + if (! _cairo_gstate_has_shadow (gstate)) pattern = &_cairo_pattern_clear.base; else { pattern = cairo_pattern_create_rgba (0, 0, 0, 0); @@ -1107,7 +1123,7 @@ _cairo_gstate_paint (cairo_gstate_t *gstate) gstate->clip); if (destroy_pattern) cairo_pattern_destroy ((cairo_pattern_t *)pattern); - + CAIRO_TRACE_END (__func__); return status; } @@ -1115,6 +1131,7 @@ cairo_status_t _cairo_gstate_mask (cairo_gstate_t *gstate, cairo_pattern_t *mask) { + CAIRO_TRACE_BEGIN (__func__); cairo_pattern_union_t source_pattern, mask_pattern; const cairo_pattern_t *source; cairo_operator_t op; @@ -1122,12 +1139,16 @@ _cairo_gstate_mask (cairo_gstate_t *gstate, cairo_bool_t destroy_pattern = FALSE; status = _cairo_gstate_get_pattern_status (mask); - if (unlikely (status)) + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); return status; + } status = _cairo_gstate_get_pattern_status (gstate->source); - if (unlikely (status)) + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); return status; + } if (gstate->source->filter == CAIRO_FILTER_GAUSSIAN) status = _cairo_pattern_create_gaussian_matrix (gstate->source, 1024); @@ -1135,20 +1156,27 @@ _cairo_gstate_mask (cairo_gstate_t *gstate, if (mask->filter == CAIRO_FILTER_GAUSSIAN) status = _cairo_pattern_create_gaussian_matrix (mask, 1024); - if (gstate->op == CAIRO_OPERATOR_DEST) + if (gstate->op == CAIRO_OPERATOR_DEST) { + CAIRO_TRACE_END (__func__); return CAIRO_STATUS_SUCCESS; + } - if (_cairo_clip_is_all_clipped (gstate->clip)) + if (_cairo_clip_is_all_clipped (gstate->clip)) { + CAIRO_TRACE_END (__func__); return CAIRO_STATUS_SUCCESS; + } assert (gstate->opacity == 1.0); - if (_cairo_pattern_is_opaque (mask, NULL)) + if (_cairo_pattern_is_opaque (mask, NULL)) { + CAIRO_TRACE_END (__func__); return _cairo_gstate_paint (gstate); + } if (_cairo_pattern_is_clear (mask) && _cairo_operator_bounded_by_mask (gstate->op)) { + CAIRO_TRACE_END (__func__); return CAIRO_STATUS_SUCCESS; } @@ -1209,12 +1237,14 @@ _cairo_gstate_mask (cairo_gstate_t *gstate, if (destroy_pattern) cairo_pattern_destroy ((cairo_pattern_t *)source); + CAIRO_TRACE_END (__func__); return status; } cairo_status_t _cairo_gstate_stroke (cairo_gstate_t *gstate, cairo_path_fixed_t *path) { + CAIRO_TRACE_BEGIN (__func__); cairo_pattern_union_t source_pattern; cairo_stroke_style_t style; double dash[2]; @@ -1223,21 +1253,29 @@ _cairo_gstate_stroke (cairo_gstate_t *gstate, cairo_path_fixed_t *path) cairo_matrix_t aggregate_transform_inverse; status = _cairo_gstate_get_pattern_status (gstate->source); - if (unlikely (status)) + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); return status; + } if (gstate->source->filter == CAIRO_FILTER_GAUSSIAN) status = _cairo_pattern_create_gaussian_matrix (gstate->source, gstate->stroke_style.line_width); - if (gstate->op == CAIRO_OPERATOR_DEST) + if (gstate->op == CAIRO_OPERATOR_DEST) { + CAIRO_TRACE_END (__func__); return CAIRO_STATUS_SUCCESS; + } - if (gstate->stroke_style.line_width <= 0.0) + if (gstate->stroke_style.line_width <= 0.0) { + CAIRO_TRACE_END (__func__); return CAIRO_STATUS_SUCCESS; + } - if (_cairo_clip_is_all_clipped (gstate->clip)) + if (_cairo_clip_is_all_clipped (gstate->clip)) { + CAIRO_TRACE_END (__func__); return CAIRO_STATUS_SUCCESS; + } assert (gstate->opacity == 1.0); @@ -1263,7 +1301,7 @@ _cairo_gstate_stroke (cairo_gstate_t *gstate, cairo_path_fixed_t *path) if (_cairo_gstate_has_shadow (gstate)) source_pattern.base.shadow = gstate->shadow; - return _cairo_surface_stroke (gstate->target, + status = _cairo_surface_stroke (gstate->target, gstate->op, &source_pattern.base, path, @@ -1273,6 +1311,8 @@ _cairo_gstate_stroke (cairo_gstate_t *gstate, cairo_path_fixed_t *path) gstate->tolerance, gstate->antialias, gstate->clip); + CAIRO_TRACE_END (__func__); + return status; } cairo_status_t @@ -1282,6 +1322,7 @@ _cairo_gstate_in_stroke (cairo_gstate_t *gstate, double y, cairo_bool_t *inside_ret) { + CAIRO_TRACE_BEGIN (__func__); cairo_status_t status; cairo_rectangle_int_t extents; cairo_box_t limit; @@ -1289,6 +1330,7 @@ _cairo_gstate_in_stroke (cairo_gstate_t *gstate, if (gstate->stroke_style.line_width <= 0.0) { *inside_ret = FALSE; + CAIRO_TRACE_END (__func__); return CAIRO_STATUS_SUCCESS; } @@ -1305,6 +1347,7 @@ _cairo_gstate_in_stroke (cairo_gstate_t *gstate, y < extents.y || y > extents.y + extents.height) { *inside_ret = FALSE; + CAIRO_TRACE_END (__func__); return CAIRO_STATUS_SUCCESS; } @@ -1330,34 +1373,44 @@ _cairo_gstate_in_stroke (cairo_gstate_t *gstate, BAIL: _cairo_traps_fini (&traps); + CAIRO_TRACE_END (__func__); return status; } cairo_status_t _cairo_gstate_fill (cairo_gstate_t *gstate, cairo_path_fixed_t *path) { + CAIRO_TRACE_BEGIN (__func__); cairo_status_t status; const cairo_pattern_t *pattern; cairo_bool_t destroy_pattern = FALSE; status = _cairo_gstate_get_pattern_status (gstate->source); - if (unlikely (status)) + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); return status; + } if (gstate->source->filter == CAIRO_FILTER_GAUSSIAN) status = _cairo_pattern_create_gaussian_matrix (gstate->source, 1024); - if (gstate->op == CAIRO_OPERATOR_DEST) + if (gstate->op == CAIRO_OPERATOR_DEST) { + CAIRO_TRACE_END (__func__); return CAIRO_STATUS_SUCCESS; + } - if (_cairo_clip_is_all_clipped (gstate->clip)) + if (_cairo_clip_is_all_clipped (gstate->clip)) { + CAIRO_TRACE_END (__func__); return CAIRO_STATUS_SUCCESS; + } assert (gstate->opacity == 1.0); if (_cairo_path_fixed_fill_is_empty (path)) { - if (_cairo_operator_bounded_by_mask (gstate->op)) + if (_cairo_operator_bounded_by_mask (gstate->op)) { + CAIRO_TRACE_END (__func__); return CAIRO_STATUS_SUCCESS; + } pattern = &_cairo_pattern_clear.base; status = _cairo_surface_paint (gstate->target, @@ -1373,7 +1426,7 @@ _cairo_gstate_fill (cairo_gstate_t *gstate, cairo_path_fixed_t *path) op = _reduce_op (gstate); /* FIXME: I don't like this */ if (op == CAIRO_OPERATOR_CLEAR) { - if (_cairo_gstate_has_shadow (gstate)) + if (_cairo_gstate_has_shadow (gstate)) pattern = &_cairo_pattern_clear.base; else { pattern = cairo_pattern_create_rgba (0, 0, 0, 0); @@ -1414,6 +1467,7 @@ _cairo_gstate_fill (cairo_gstate_t *gstate, cairo_path_fixed_t *path) if (destroy_pattern) cairo_pattern_destroy ((cairo_pattern_t *)pattern); + CAIRO_TRACE_END (__func__); return status; } diff --git a/src/cairo-image-surface.c b/src/cairo-image-surface.c index 1948a1a..a399a81 100644 --- a/src/cairo-image-surface.c +++ b/src/cairo-image-surface.c @@ -56,6 +56,7 @@ #include "cairo-surface-subsurface-private.h" #include "cairo-surface-shadow-private.h" #include "cairo-list-inline.h" +#include "cairo-ttrace.h" /* Limit on the width / height of an image surface in pixels. This is * mainly determined by coordinates of things sent to pixman at the @@ -124,7 +125,7 @@ _cairo_image_shadow_caches_destroy (void) cairo_surface_destroy (shadow->surface); free (shadow); } - shadow_caches_size = 0; + shadow_caches_size = 0; } } @@ -274,6 +275,7 @@ _cairo_image_surface_init (cairo_image_surface_t *surface, pixman_image_t *pixman_image, pixman_format_code_t pixman_format) { + CAIRO_TRACE_BEGIN (__func__); surface->parent = NULL; surface->pixman_image = pixman_image; @@ -294,17 +296,21 @@ _cairo_image_surface_init (cairo_image_surface_t *surface, surface->compositor = _cairo_image_spans_compositor_get (); _cairo_image_shadow_caches_init (); + CAIRO_TRACE_END (__func__); } cairo_surface_t * _cairo_image_surface_create_for_pixman_image (pixman_image_t *pixman_image, pixman_format_code_t pixman_format) { + CAIRO_TRACE_BEGIN (__func__); cairo_image_surface_t *surface; surface = malloc (sizeof (cairo_image_surface_t)); - if (unlikely (surface == NULL)) + if (unlikely (surface == NULL)) { + CAIRO_TRACE_END (__func__); return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY)); + } _cairo_surface_init (&surface->base, &_cairo_image_surface_backend, @@ -313,6 +319,7 @@ _cairo_image_surface_create_for_pixman_image (pixman_image_t *pixman_image, _cairo_image_surface_init (surface, pixman_image, pixman_format); + CAIRO_TRACE_END (__func__); return &surface->base; } @@ -457,29 +464,35 @@ _cairo_image_surface_create_with_pixman_format (unsigned char *data, int height, int stride) { + CAIRO_TRACE_BEGIN (__func__); cairo_surface_t *surface; pixman_image_t *pixman_image; if (! _cairo_image_surface_is_size_valid (width, height)) { + CAIRO_TRACE_END (__func__); return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_SIZE)); } pixman_image = pixman_image_create_bits (pixman_format, width, height, (uint32_t *) data, stride); - if (unlikely (pixman_image == NULL)) + if (unlikely (pixman_image == NULL)) { + CAIRO_TRACE_END (__func__); return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY)); + } surface = _cairo_image_surface_create_for_pixman_image (pixman_image, pixman_format); if (unlikely (surface->status)) { pixman_image_unref (pixman_image); + CAIRO_TRACE_END (__func__); return surface; } /* we can not make any assumptions about the initial state of user data */ surface->is_clear = data == NULL; + CAIRO_TRACE_END (__func__); return surface; } @@ -510,15 +523,21 @@ cairo_image_surface_create (cairo_format_t format, int width, int height) { + CAIRO_TRACE_BEGIN (__func__); pixman_format_code_t pixman_format; + cairo_surface_t *image_surface = NULL; - if (! CAIRO_FORMAT_VALID (format)) + if (! CAIRO_FORMAT_VALID (format)) { + CAIRO_TRACE_END (__func__); return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_FORMAT)); + } pixman_format = _cairo_format_to_pixman_format_code (format); - return _cairo_image_surface_create_with_pixman_format (NULL, pixman_format, + image_surface = _cairo_image_surface_create_with_pixman_format (NULL, pixman_format, width, height, -1); + CAIRO_TRACE_END (__func__); + return image_surface; } slim_hidden_def (cairo_image_surface_create); @@ -879,6 +898,7 @@ _cairo_image_surface_create_similar (void *abstract_other, cairo_surface_t * _cairo_image_surface_snapshot (void *abstract_surface) { + CAIRO_TRACE_BEGIN (__func__); cairo_image_surface_t *image = abstract_surface; cairo_image_surface_t *clone; @@ -887,8 +907,10 @@ _cairo_image_surface_snapshot (void *abstract_surface) clone = (cairo_image_surface_t *) _cairo_image_surface_create_for_pixman_image (image->pixman_image, image->pixman_format); - if (unlikely (clone->base.status)) + if (unlikely (clone->base.status)) { + CAIRO_TRACE_END (__func__); return &clone->base; + } image->pixman_image = NULL; image->owns_data = FALSE; @@ -897,6 +919,7 @@ _cairo_image_surface_snapshot (void *abstract_surface) clone->color = image->color; clone->owns_data = TRUE; + CAIRO_TRACE_END (__func__); return &clone->base; } @@ -906,8 +929,10 @@ _cairo_image_surface_snapshot (void *abstract_surface) image->width, image->height, 0); - if (unlikely (clone->base.status)) + if (unlikely (clone->base.status)) { + CAIRO_TRACE_END (__func__); return &clone->base; + } if (clone->stride == image->stride) { memcpy (clone->data, image->data, clone->stride * clone->height); @@ -920,6 +945,7 @@ _cairo_image_surface_snapshot (void *abstract_surface) image->width, image->height); } clone->base.is_clear = FALSE; + CAIRO_TRACE_END (__func__); return &clone->base; } @@ -927,6 +953,7 @@ cairo_image_surface_t * _cairo_image_surface_map_to_image (void *abstract_other, const cairo_rectangle_int_t *extents) { + CAIRO_TRACE_BEGIN (__func__); cairo_image_surface_t *other = abstract_other; cairo_surface_t *surface; uint8_t *data; @@ -943,6 +970,7 @@ _cairo_image_surface_map_to_image (void *abstract_other, other->stride); cairo_surface_set_device_offset (surface, -extents->x, -extents->y); + CAIRO_TRACE_END (__func__); return (cairo_image_surface_t *) surface; } @@ -959,6 +987,7 @@ _cairo_image_surface_unmap_image (void *abstract_surface, cairo_status_t _cairo_image_surface_finish (void *abstract_surface) { + CAIRO_TRACE_BEGIN (__func__); cairo_image_surface_t *surface = abstract_surface; if (surface->pixman_image) { @@ -979,6 +1008,7 @@ _cairo_image_surface_finish (void *abstract_surface) _cairo_image_shadow_caches_destroy (); + CAIRO_TRACE_END (__func__); return CAIRO_STATUS_SUCCESS; } @@ -1042,32 +1072,38 @@ _cairo_image_surface_paint (void *abstract_surface, const cairo_pattern_t *source, const cairo_clip_t *clip) { + CAIRO_TRACE_BEGIN (__func__); cairo_image_surface_t *surface = abstract_surface; - cairo_int_status_t status; + cairo_int_status_t status; TRACE ((stderr, "%s (surface=%d)\n", __FUNCTION__, surface->base.unique_id)); status = cairo_device_acquire (surface->base.device); - if (unlikely (status)) + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); return status; + } status = _cairo_surface_shadow_paint (abstract_surface, op, source, clip, &source->shadow); if (unlikely (status)) { cairo_device_release (surface->base.device); + CAIRO_TRACE_END (__func__); return status; } if (source->shadow.draw_shadow_only) { cairo_device_release (surface->base.device); + CAIRO_TRACE_END (__func__); return status; } status = _cairo_compositor_paint (surface->compositor, &surface->base, op, source, clip); cairo_device_release (surface->base.device); + CAIRO_TRACE_END (__func__); return status; } @@ -1078,6 +1114,7 @@ _cairo_image_surface_mask (void *abstract_surface, const cairo_pattern_t *mask, const cairo_clip_t *clip) { + CAIRO_TRACE_BEGIN (__func__); cairo_image_surface_t *surface = abstract_surface; cairo_int_status_t status; @@ -1085,25 +1122,30 @@ _cairo_image_surface_mask (void *abstract_surface, __FUNCTION__, surface->base.unique_id)); status = cairo_device_acquire (surface->base.device); - if (unlikely (status)) + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); return status; + } status = _cairo_surface_shadow_mask (abstract_surface, op, source, mask, clip, &source->shadow); if (unlikely (status)) { cairo_device_release (surface->base.device); + CAIRO_TRACE_END (__func__); return status; } if (source->shadow.draw_shadow_only) { cairo_device_release (surface->base.device); + CAIRO_TRACE_END (__func__); return status; } status = _cairo_compositor_mask (surface->compositor, &surface->base, op, source, mask, clip); cairo_device_release (surface->base.device); + CAIRO_TRACE_END (__func__); return status; } @@ -1119,6 +1161,7 @@ _cairo_image_surface_stroke (void *abstract_surface, cairo_antialias_t antialias, const cairo_clip_t *clip) { + CAIRO_TRACE_BEGIN (__func__); cairo_int_status_t status; cairo_image_surface_t *surface = abstract_surface; cairo_shadow_type_t shadow_type = source->shadow.type; @@ -1127,8 +1170,10 @@ _cairo_image_surface_stroke (void *abstract_surface, __FUNCTION__, surface->base.unique_id)); status = cairo_device_acquire (surface->base.device); - if (unlikely (status)) + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); return status; + } if (shadow_type != CAIRO_SHADOW_INSET) status = _cairo_surface_shadow_stroke (abstract_surface, op, source, @@ -1138,12 +1183,14 @@ _cairo_image_surface_stroke (void *abstract_surface, if (unlikely (status)) { cairo_device_release (surface->base.device); + CAIRO_TRACE_END (__func__); return status; } if (shadow_type == CAIRO_SHADOW_DROP && source->shadow.draw_shadow_only) { cairo_device_release (surface->base.device); + CAIRO_TRACE_END (__func__); return status; } @@ -1155,6 +1202,7 @@ _cairo_image_surface_stroke (void *abstract_surface, if (unlikely (status)) { cairo_device_release (surface->base.device); + CAIRO_TRACE_END (__func__); return status; } @@ -1165,6 +1213,7 @@ _cairo_image_surface_stroke (void *abstract_surface, &source->shadow); cairo_device_release (surface->base.device); + CAIRO_TRACE_END (__func__); return status; } @@ -1178,6 +1227,7 @@ _cairo_image_surface_fill (void *abstract_surface, cairo_antialias_t antialias, const cairo_clip_t *clip) { + CAIRO_TRACE_BEGIN (__func__); cairo_int_status_t status; cairo_image_surface_t *surface = abstract_surface; cairo_shadow_type_t shadow_type = source->shadow.type; @@ -1186,8 +1236,10 @@ _cairo_image_surface_fill (void *abstract_surface, __FUNCTION__, surface->base.unique_id)); status = cairo_device_acquire (surface->base.device); - if (unlikely (status)) + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); return status; + } if (shadow_type != CAIRO_SHADOW_INSET) status = _cairo_surface_shadow_fill (abstract_surface, op, source, @@ -1197,12 +1249,14 @@ _cairo_image_surface_fill (void *abstract_surface, if (unlikely (status)) { cairo_device_release (surface->base.device); + CAIRO_TRACE_END (__func__); return status; } if (shadow_type == CAIRO_SHADOW_DROP && source->shadow.draw_shadow_only) { cairo_device_release (surface->base.device); + CAIRO_TRACE_END (__func__); return status; } @@ -1223,6 +1277,7 @@ _cairo_image_surface_fill (void *abstract_surface, if (unlikely (status)) { cairo_device_release (surface->base.device); + CAIRO_TRACE_END (__func__); return status; } @@ -1233,6 +1288,7 @@ _cairo_image_surface_fill (void *abstract_surface, &source->shadow); cairo_device_release (surface->base.device); + CAIRO_TRACE_END (__func__); return status; } @@ -1245,6 +1301,7 @@ _cairo_image_surface_glyphs (void *abstract_surface, cairo_scaled_font_t *scaled_font, const cairo_clip_t *clip) { + CAIRO_TRACE_BEGIN (__func__); cairo_int_status_t status; cairo_image_surface_t *surface = abstract_surface; cairo_shadow_type_t shadow_type = source->shadow.type; @@ -1253,8 +1310,10 @@ _cairo_image_surface_glyphs (void *abstract_surface, __FUNCTION__, surface->base.unique_id)); status = cairo_device_acquire (surface->base.device); - if (unlikely (status)) + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); return status; + } if (shadow_type != CAIRO_SHADOW_INSET) status = _cairo_surface_shadow_glyphs (abstract_surface, op, source, @@ -1265,12 +1324,14 @@ _cairo_image_surface_glyphs (void *abstract_surface, if (unlikely (status)) { cairo_device_release (surface->base.device); + CAIRO_TRACE_END (__func__); return status; } if (shadow_type == CAIRO_SHADOW_DROP && source->shadow.draw_shadow_only) { cairo_device_release (surface->base.device); + CAIRO_TRACE_END (__func__); return status; } @@ -1282,6 +1343,7 @@ _cairo_image_surface_glyphs (void *abstract_surface, if (unlikely (status)) { cairo_device_release (surface->base.device); + CAIRO_TRACE_END (__func__); return status; } @@ -1293,6 +1355,7 @@ _cairo_image_surface_glyphs (void *abstract_surface, &source->shadow); cairo_device_release (surface->base.device); + CAIRO_TRACE_END (__func__); return status; } @@ -1312,6 +1375,7 @@ _cairo_image_surface_shadow_surface (void *surface, int width, int height, int *width_out, int *height_out) { + CAIRO_TRACE_BEGIN (__func__); int shadow_width, shadow_height; cairo_image_surface_t *shadow_surface = NULL; @@ -1331,7 +1395,7 @@ _cairo_image_surface_shadow_surface (void *surface, else shadow_width = width; } - + if (height < MIN_IMAGE_SHADOW_SIZE) shadow_height = height; else if (has_blur) { @@ -1355,12 +1419,14 @@ _cairo_image_surface_shadow_surface (void *surface, shadow_height); if (unlikely (shadow_surface->base.status)) { cairo_surface_destroy (&shadow_surface->base); + CAIRO_TRACE_END (__func__); return NULL; } *width_out = shadow_width; *height_out = shadow_height; + CAIRO_TRACE_END (__func__); return &shadow_surface->base; } @@ -1461,6 +1527,7 @@ _cairo_image_surface_create_from_image (cairo_image_surface_t *other, int x, int y, int width, int height, int stride) { + CAIRO_TRACE_BEGIN (__func__); cairo_image_surface_t *surface = NULL; cairo_status_t status; pixman_image_t *image; @@ -1500,6 +1567,7 @@ _cairo_image_surface_create_from_image (cairo_image_surface_t *other, surface->base.is_clear = FALSE; surface->owns_data = mem != NULL; + CAIRO_TRACE_END (__func__); return surface; cleanup_image: @@ -1508,6 +1576,7 @@ cleanup_mem: free (mem); cleanup: cairo_surface_destroy (&surface->base); + CAIRO_TRACE_END (__func__); return (cairo_image_surface_t *) _cairo_surface_create_in_error (status); } @@ -1633,6 +1702,7 @@ cairo_image_surface_t * _cairo_image_surface_clone_subimage (cairo_surface_t *surface, const cairo_rectangle_int_t *extents) { + CAIRO_TRACE_BEGIN (__func__); cairo_surface_t *image; cairo_surface_pattern_t pattern; cairo_status_t status; @@ -1641,8 +1711,10 @@ _cairo_image_surface_clone_subimage (cairo_surface_t *surface, _cairo_format_from_content (surface->content), extents->width, extents->height); - if (image->status) + if (image->status) { + CAIRO_TRACE_END (__func__); return to_image_surface (image); + } /* TODO: check me with non-identity device_transform. Should we * clone the scaling, too? */ @@ -1672,9 +1744,11 @@ _cairo_image_surface_clone_subimage (cairo_surface_t *surface, _cairo_image_surface_set_parent (to_image_surface (image), cairo_surface_reference (surface)); + CAIRO_TRACE_END (__func__); return to_image_surface (image); error: cairo_surface_destroy (image); + CAIRO_TRACE_END (__func__); return to_image_surface (_cairo_surface_create_in_error (status)); } diff --git a/src/cairo-png.c b/src/cairo-png.c index 068617d..9d7c5cc 100644 --- a/src/cairo-png.c +++ b/src/cairo-png.c @@ -41,6 +41,7 @@ #include "cairo-error-private.h" #include "cairo-image-surface-private.h" #include "cairo-output-stream-private.h" +#include "cairo-ttrace.h" #include #include @@ -171,6 +172,7 @@ write_png (cairo_surface_t *surface, png_rw_ptr write_func, void *closure) { + CAIRO_TRACE_BEGIN (__func__); int i; cairo_int_status_t status; cairo_image_surface_t *image; @@ -187,10 +189,14 @@ write_png (cairo_surface_t *surface, &image, &image_extra); - if (status == CAIRO_INT_STATUS_UNSUPPORTED) + if (status == CAIRO_INT_STATUS_UNSUPPORTED) { + CAIRO_TRACE_END (__func__); return _cairo_error (CAIRO_STATUS_SURFACE_TYPE_MISMATCH); - else if (unlikely (status)) - return status; + } + else if (unlikely (status)) { + CAIRO_TRACE_END (__func__); + return status; + } /* PNG complains about "Image width or height is zero in IHDR" */ if (image->width == 0 || image->height == 0) { @@ -314,6 +320,7 @@ BAIL2: BAIL1: _cairo_surface_release_source_image (surface, image, image_extra); + CAIRO_TRACE_END (__func__); return status; } @@ -426,17 +433,23 @@ cairo_surface_write_to_png_stream (cairo_surface_t *surface, cairo_write_func_t write_func, void *closure) { + CAIRO_TRACE_BEGIN (__func__); struct png_write_closure_t png_closure; - if (surface->status) + if (surface->status) { + CAIRO_TRACE_END (__func__); return surface->status; + } - if (surface->finished) + if (surface->finished) { + CAIRO_TRACE_END (__func__); return _cairo_error (CAIRO_STATUS_SURFACE_FINISHED); + } png_closure.write_func = write_func; png_closure.closure = closure; + CAIRO_TRACE_END (__func__); return write_png (surface, stream_write_func, &png_closure); } slim_hidden_def (cairo_surface_write_to_png_stream); diff --git a/src/cairo-region.c b/src/cairo-region.c index ccfb220..f202c96 100644 --- a/src/cairo-region.c +++ b/src/cairo-region.c @@ -40,6 +40,7 @@ #include "cairo-error-private.h" #include "cairo-region-private.h" +#include "cairo-ttrace.h" /* XXX need to update pixman headers to be const as appropriate */ #define CONST_CAST (pixman_region32_t *) @@ -194,16 +195,20 @@ _cairo_region_fini (cairo_region_t *region) cairo_region_t * cairo_region_create (void) { + CAIRO_TRACE_BEGIN (__func__); cairo_region_t *region; region = _cairo_malloc (sizeof (cairo_region_t)); - if (region == NULL) + if (region == NULL) { + CAIRO_TRACE_END (__func__); return (cairo_region_t *) &_cairo_region_nil; + } region->status = CAIRO_STATUS_SUCCESS; CAIRO_REFERENCE_COUNT_INIT (®ion->ref_count, 1); pixman_region32_init (®ion->rgn); + CAIRO_TRACE_END (__func__); return region; } @@ -418,16 +423,22 @@ slim_hidden_def (cairo_region_reference); void cairo_region_destroy (cairo_region_t *region) { - if (region == NULL || CAIRO_REFERENCE_COUNT_IS_INVALID (®ion->ref_count)) + CAIRO_TRACE_BEGIN (__func__); + if (region == NULL || CAIRO_REFERENCE_COUNT_IS_INVALID (®ion->ref_count)) { + CAIRO_TRACE_END (__func__); return; + } assert (CAIRO_REFERENCE_COUNT_HAS_REFERENCE (®ion->ref_count)); - if (! _cairo_reference_count_dec_and_test (®ion->ref_count)) + if (! _cairo_reference_count_dec_and_test (®ion->ref_count)) { + CAIRO_TRACE_END (__func__); return; + } _cairo_region_fini (region); free (region); + CAIRO_TRACE_END (__func__); } slim_hidden_def (cairo_region_destroy); @@ -701,11 +712,14 @@ cairo_status_t cairo_region_union_rectangle (cairo_region_t *dst, const cairo_rectangle_int_t *rectangle) { + CAIRO_TRACE_BEGIN (__func__); cairo_status_t status = CAIRO_STATUS_SUCCESS; pixman_region32_t region; - if (dst->status) + if (dst->status) { + CAIRO_TRACE_END (__func__); return dst->status; + } pixman_region32_init_rect (®ion, rectangle->x, rectangle->y, @@ -715,6 +729,7 @@ cairo_region_union_rectangle (cairo_region_t *dst, status = _cairo_region_set_error (dst, CAIRO_STATUS_NO_MEMORY); pixman_region32_fini (®ion); + CAIRO_TRACE_END (__func__); return status; } diff --git a/src/cairo-surface.c b/src/cairo-surface.c index 24ad249..2c5bcf7 100644 --- a/src/cairo-surface.c +++ b/src/cairo-surface.c @@ -50,6 +50,7 @@ #include "cairo-region-private.h" #include "cairo-surface-inline.h" #include "cairo-tee-surface-private.h" +#include "cairo-ttrace.h" /** * SECTION:cairo-surface @@ -490,22 +491,32 @@ cairo_surface_create_similar (cairo_surface_t *other, int width, int height) { + CAIRO_TRACE_BEGIN (__func__); cairo_surface_t *surface; cairo_status_t status; cairo_solid_pattern_t pattern; - if (unlikely (other->status)) + if (unlikely (other->status)) { + CAIRO_TRACE_END (__func__); return _cairo_surface_create_in_error (other->status); - if (unlikely (other->finished)) + } + if (unlikely (other->finished)) { + CAIRO_TRACE_END (__func__); return _cairo_surface_create_in_error (CAIRO_STATUS_SURFACE_FINISHED); - if (unlikely (width < 0 || height < 0)) + } + if (unlikely (width < 0 || height < 0)) { + CAIRO_TRACE_END (__func__); return _cairo_surface_create_in_error (CAIRO_STATUS_INVALID_SIZE); + } - if (unlikely (! CAIRO_CONTENT_VALID (content))) + if (unlikely (! CAIRO_CONTENT_VALID (content))) { + CAIRO_TRACE_END (__func__); return _cairo_surface_create_in_error (CAIRO_STATUS_INVALID_CONTENT); - - if (unlikely (other->status)) + } + if (unlikely (other->status)) { + CAIRO_TRACE_END (__func__); return _cairo_surface_create_in_error (other->status); + } /* We inherit the device scale, so create a larger surface */ width = width * other->device_transform.xx; @@ -519,16 +530,20 @@ cairo_surface_create_similar (cairo_surface_t *other, _cairo_format_from_content (content), width, height); - if (unlikely (surface->status)) + if (unlikely (surface->status)) { + CAIRO_TRACE_END (__func__); return surface; + } _cairo_surface_copy_similar_properties (surface, other); cairo_surface_set_device_scale (surface, other->device_transform.xx, other->device_transform.yy); - if (unlikely (surface->status)) + if (unlikely (surface->status)){ + CAIRO_TRACE_END (__func__); return surface; + } _cairo_pattern_init_solid (&pattern, CAIRO_COLOR_TRANSPARENT); status = _cairo_surface_paint (surface, @@ -541,6 +556,7 @@ cairo_surface_create_similar (cairo_surface_t *other, assert (surface->is_clear); + CAIRO_TRACE_END (__func__); return surface; } @@ -576,17 +592,26 @@ cairo_surface_create_similar_image (cairo_surface_t *other, int width, int height) { + CAIRO_TRACE_BEGIN (__func__); cairo_surface_t *image; - if (unlikely (other->status)) + if (unlikely (other->status)) { + CAIRO_TRACE_END (__func__); return _cairo_surface_create_in_error (other->status); - if (unlikely (other->finished)) + } + if (unlikely (other->finished)) { + CAIRO_TRACE_END (__func__); return _cairo_surface_create_in_error (CAIRO_STATUS_SURFACE_FINISHED); + } - if (unlikely (width < 0 || height < 0)) + if (unlikely (width < 0 || height < 0)) { + CAIRO_TRACE_END (__func__); return _cairo_surface_create_in_error (CAIRO_STATUS_INVALID_SIZE); - if (unlikely (! CAIRO_FORMAT_VALID (format))) + } + if (unlikely (! CAIRO_FORMAT_VALID (format))) { + CAIRO_TRACE_END (__func__); return _cairo_surface_create_in_error (CAIRO_STATUS_INVALID_FORMAT); + } image = NULL; if (other->backend->create_similar_image) @@ -597,6 +622,7 @@ cairo_surface_create_similar_image (cairo_surface_t *other, assert (image->is_clear); + CAIRO_TRACE_END (__func__); return image; } slim_hidden_def (cairo_surface_create_similar_image); @@ -635,6 +661,7 @@ cairo_image_surface_t * _cairo_surface_map_to_image (cairo_surface_t *surface, const cairo_rectangle_int_t *extents) { + CAIRO_TRACE_BEGIN (__func__); cairo_image_surface_t *image = NULL; assert (extents != NULL); @@ -646,6 +673,7 @@ _cairo_surface_map_to_image (cairo_surface_t *surface, if (image == NULL) image = _cairo_image_surface_clone_subimage (surface, extents); + CAIRO_TRACE_END (__func__); return image; } @@ -674,6 +702,7 @@ cairo_int_status_t _cairo_surface_unmap_image (cairo_surface_t *surface, cairo_image_surface_t *image) { + CAIRO_TRACE_BEGIN (__func__); cairo_surface_pattern_t pattern; cairo_rectangle_int_t extents; cairo_clip_t *clip; @@ -696,8 +725,10 @@ _cairo_surface_unmap_image (cairo_surface_t *surface, ! _cairo_image_surface_is_clone (image)) { status = surface->backend->unmap_image (surface, image); - if (status != CAIRO_INT_STATUS_UNSUPPORTED) + if (status != CAIRO_INT_STATUS_UNSUPPORTED) { + CAIRO_TRACE_END (__func__); return status; + } } _cairo_pattern_init_for_surface (&pattern, &image->base); @@ -727,6 +758,7 @@ destroy: cairo_surface_finish (&image->base); cairo_surface_destroy (&image->base); + CAIRO_TRACE_END (__func__); return status; } @@ -762,19 +794,25 @@ cairo_surface_t * cairo_surface_map_to_image (cairo_surface_t *surface, const cairo_rectangle_int_t *extents) { + CAIRO_TRACE_BEGIN (__func__); cairo_rectangle_int_t rect; cairo_image_surface_t *image; cairo_status_t status; - if (unlikely (surface->status)) + if (unlikely (surface->status)) { + CAIRO_TRACE_END (__func__); return _cairo_surface_create_in_error (surface->status); - if (unlikely (surface->finished)) + } + if (unlikely (surface->finished)) { + CAIRO_TRACE_END (__func__); return _cairo_surface_create_in_error (CAIRO_STATUS_SURFACE_FINISHED); + } if (extents == NULL) { - if (unlikely (! surface->backend->get_extents (surface, &rect))) + if (unlikely (! surface->backend->get_extents (surface, &rect))) { + CAIRO_TRACE_END (__func__); return _cairo_surface_create_in_error (CAIRO_STATUS_INVALID_SIZE); - + } extents = ▭ } else { cairo_rectangle_int_t surface_extents; @@ -782,8 +820,10 @@ cairo_surface_map_to_image (cairo_surface_t *surface, /* If this surface is bounded, we can't map parts * that are outside of it. */ if (likely (surface->backend->get_extents (surface, &surface_extents))) { - if (unlikely (! _cairo_rectangle_contains_rectangle (&surface_extents, extents))) + if (unlikely (! _cairo_rectangle_contains_rectangle (&surface_extents, extents))) { + CAIRO_TRACE_END (__func__); return _cairo_surface_create_in_error (CAIRO_STATUS_INVALID_SIZE); + } } } @@ -792,6 +832,7 @@ cairo_surface_map_to_image (cairo_surface_t *surface, status = image->base.status; if (unlikely (status)) { cairo_surface_destroy (&image->base); + CAIRO_TRACE_END (__func__); return _cairo_surface_create_in_error (status); } @@ -800,6 +841,7 @@ cairo_surface_map_to_image (cairo_surface_t *surface, image = _cairo_image_surface_clone_subimage (surface, extents); } + CAIRO_TRACE_END (__func__); return &image->base; } @@ -822,6 +864,7 @@ void cairo_surface_unmap_image (cairo_surface_t *surface, cairo_surface_t *image) { + CAIRO_TRACE_BEGIN (__func__); cairo_int_status_t status = CAIRO_STATUS_SUCCESS; if (unlikely (surface->status)) { @@ -850,12 +893,14 @@ cairo_surface_unmap_image (cairo_surface_t *surface, if (unlikely (status)) _cairo_surface_set_error (surface, status); + CAIRO_TRACE_END (__func__); return; error: _cairo_surface_set_error (surface, status); cairo_surface_finish (image); cairo_surface_destroy (image); + CAIRO_TRACE_END (__func__); } cairo_surface_t * @@ -865,12 +910,15 @@ _cairo_surface_create_scratch (cairo_surface_t *other, int height, const cairo_color_t *color) { + CAIRO_TRACE_BEGIN (__func__); cairo_surface_t *surface; cairo_status_t status; cairo_solid_pattern_t pattern; - if (unlikely (other->status)) + if (unlikely (other->status)) { + CAIRO_TRACE_END (__func__); return _cairo_surface_create_in_error (other->status); + } surface = NULL; if (other->backend->create_similar) @@ -880,13 +928,17 @@ _cairo_surface_create_scratch (cairo_surface_t *other, _cairo_format_from_content (content), width, height); - if (unlikely (surface->status)) + if (unlikely (surface->status)) { + CAIRO_TRACE_END (__func__); return surface; + } _cairo_surface_copy_similar_properties (surface, other); - if (unlikely (surface->status)) + if (unlikely (surface->status)){ + CAIRO_TRACE_END (__func__); return surface; + } if (color) { _cairo_pattern_init_solid (&pattern, color); @@ -900,6 +952,7 @@ _cairo_surface_create_scratch (cairo_surface_t *other, } } + CAIRO_TRACE_END (__func__); return surface; } @@ -974,14 +1027,19 @@ slim_hidden_def (cairo_surface_reference); void cairo_surface_destroy (cairo_surface_t *surface) { + CAIRO_TRACE_BEGIN (__func__); if (surface == NULL || - CAIRO_REFERENCE_COUNT_IS_INVALID (&surface->ref_count)) + CAIRO_REFERENCE_COUNT_IS_INVALID (&surface->ref_count)) { + CAIRO_TRACE_END (__func__); return; + } assert (CAIRO_REFERENCE_COUNT_HAS_REFERENCE (&surface->ref_count)); - if (! _cairo_reference_count_dec_and_test (&surface->ref_count)) + if (! _cairo_reference_count_dec_and_test (&surface->ref_count)) { + CAIRO_TRACE_END (__func__); return; + } assert (surface->snapshot_of == NULL); @@ -990,8 +1048,10 @@ cairo_surface_destroy (cairo_surface_t *surface) /* We may have been referenced by a snapshot prior to have * detaching it with the copy-on-write. */ - if (CAIRO_REFERENCE_COUNT_GET_VALUE (&surface->ref_count)) + if (CAIRO_REFERENCE_COUNT_GET_VALUE (&surface->ref_count)) { + CAIRO_TRACE_END (__func__); return; + } _cairo_surface_finish (surface); } @@ -1011,6 +1071,7 @@ cairo_surface_destroy (cairo_surface_t *surface) assert (! CAIRO_REFERENCE_COUNT_HAS_REFERENCE (&surface->ref_count)); free (surface); + CAIRO_TRACE_END (__func__); } slim_hidden_def(cairo_surface_destroy); @@ -1088,14 +1149,21 @@ _cairo_surface_finish (cairo_surface_t *surface) void cairo_surface_finish (cairo_surface_t *surface) { - if (surface == NULL) + CAIRO_TRACE_BEGIN (__func__); + if (surface == NULL) { + CAIRO_TRACE_END (__func__); return; + } - if (CAIRO_REFERENCE_COUNT_IS_INVALID (&surface->ref_count)) + if (CAIRO_REFERENCE_COUNT_IS_INVALID (&surface->ref_count)) { + CAIRO_TRACE_END (__func__); return; + } - if (surface->finished) + if (surface->finished) { + CAIRO_TRACE_END (__func__); return; + } /* We have to be careful when decoupling potential reference cycles */ cairo_surface_reference (surface); @@ -1105,6 +1173,7 @@ cairo_surface_finish (cairo_surface_t *surface) _cairo_surface_finish (surface); cairo_surface_destroy (surface); + CAIRO_TRACE_END (__func__); } slim_hidden_def (cairo_surface_finish); @@ -1207,6 +1276,7 @@ cairo_surface_get_mime_data (cairo_surface_t *surface, const unsigned char **data, unsigned long *length) { + CAIRO_TRACE_BEGIN (__func__); cairo_user_data_slot_t *slots; int i, num_slots; @@ -1214,8 +1284,10 @@ cairo_surface_get_mime_data (cairo_surface_t *surface, *length = 0; /* Prevent reads of the array during teardown */ - if (! CAIRO_REFERENCE_COUNT_HAS_REFERENCE (&surface->ref_count)) + if (! CAIRO_REFERENCE_COUNT_HAS_REFERENCE (&surface->ref_count)) { + CAIRO_TRACE_END (__func__); return; + } /* The number of mime-types attached to a surface is usually small, * typically zero. Therefore it is quicker to do a strcmp() against @@ -1230,9 +1302,11 @@ cairo_surface_get_mime_data (cairo_surface_t *surface, *data = mime_data->data; *length = mime_data->length; + CAIRO_TRACE_END (__func__); return; } } + CAIRO_TRACE_END (__func__); } slim_hidden_def (cairo_surface_get_mime_data); @@ -1370,28 +1444,41 @@ cairo_surface_set_mime_data (cairo_surface_t *surface, cairo_destroy_func_t destroy, void *closure) { + CAIRO_TRACE_BEGIN (__func__); cairo_status_t status; cairo_mime_data_t *mime_data; - if (CAIRO_REFERENCE_COUNT_IS_INVALID (&surface->ref_count)) + if (CAIRO_REFERENCE_COUNT_IS_INVALID (&surface->ref_count)) { + CAIRO_TRACE_END (__func__); return surface->status; + } - if (! CAIRO_REFERENCE_COUNT_HAS_REFERENCE (&surface->ref_count)) + if (! CAIRO_REFERENCE_COUNT_HAS_REFERENCE (&surface->ref_count)) { + CAIRO_TRACE_END (__func__); return _cairo_error (CAIRO_STATUS_SURFACE_FINISHED); + } - if (unlikely (surface->status)) + if (unlikely (surface->status)) { + CAIRO_TRACE_END (__func__); return surface->status; - if (unlikely (surface->finished)) + } + if (unlikely (surface->finished)) { + CAIRO_TRACE_END (__func__); return _cairo_surface_set_error (surface, _cairo_error (CAIRO_STATUS_SURFACE_FINISHED)); + } status = _cairo_intern_string (&mime_type, -1); - if (unlikely (status)) + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); return _cairo_surface_set_error (surface, status); + } if (data != NULL) { mime_data = malloc (sizeof (cairo_mime_data_t)); - if (unlikely (mime_data == NULL)) + if (unlikely (mime_data == NULL)) { + CAIRO_TRACE_END (__func__); return _cairo_surface_set_error (surface, _cairo_error (CAIRO_STATUS_NO_MEMORY)); + } CAIRO_REFERENCE_COUNT_INIT (&mime_data->ref_count, 1); @@ -1408,10 +1495,10 @@ cairo_surface_set_mime_data (cairo_surface_t *surface, _cairo_mime_data_destroy); if (unlikely (status)) { free (mime_data); - + CAIRO_TRACE_END (__func__); return _cairo_surface_set_error (surface, status); } - + CAIRO_TRACE_END (__func__); return CAIRO_STATUS_SUCCESS; } slim_hidden_def (cairo_surface_set_mime_data); @@ -1468,24 +1555,32 @@ cairo_status_t _cairo_surface_copy_mime_data (cairo_surface_t *dst, cairo_surface_t *src) { + CAIRO_TRACE_BEGIN (__func__); cairo_status_t status; - if (dst->status) + if (dst->status) { + CAIRO_TRACE_END (__func__); return dst->status; + } - if (src->status) + if (src->status) { + CAIRO_TRACE_END (__func__); return _cairo_surface_set_error (dst, src->status); + } /* first copy the mime-data, discarding any already set on dst */ status = _cairo_user_data_array_copy (&dst->mime_data, &src->mime_data); - if (unlikely (status)) + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); return _cairo_surface_set_error (dst, status); + } /* now increment the reference counters for the copies */ _cairo_user_data_array_foreach (&dst->mime_data, _cairo_mime_data_reference, NULL); + CAIRO_TRACE_END (__func__); return CAIRO_STATUS_SUCCESS; } @@ -1594,17 +1689,23 @@ _cairo_surface_flush (cairo_surface_t *surface, unsigned flags) void cairo_surface_flush (cairo_surface_t *surface) { + CAIRO_TRACE_BEGIN (__func__); cairo_status_t status; - if (surface->status) + if (surface->status) { + CAIRO_TRACE_END (__func__); return; + } - if (surface->finished) + if (surface->finished) { + CAIRO_TRACE_END (__func__); return; + } status = _cairo_surface_flush (surface, 0); if (unlikely (status)) _cairo_surface_set_error (surface, status); + CAIRO_TRACE_END (__func__); } slim_hidden_def (cairo_surface_flush); @@ -1988,23 +2089,31 @@ _cairo_surface_acquire_source_image (cairo_surface_t *surface, cairo_image_surface_t **image_out, void **image_extra) { + CAIRO_TRACE_BEGIN (__func__); cairo_status_t status; - if (unlikely (surface->status)) + if (unlikely (surface->status)) { + CAIRO_TRACE_END (__func__); return surface->status; + } assert (!surface->finished); - if (surface->backend->acquire_source_image == NULL) + if (surface->backend->acquire_source_image == NULL) { + CAIRO_TRACE_END (__func__); return CAIRO_INT_STATUS_UNSUPPORTED; + } status = surface->backend->acquire_source_image (surface, image_out, image_extra); - if (unlikely (status)) + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); return _cairo_surface_set_error (surface, status); + } _cairo_debug_check_image_surface_is_defined (&(*image_out)->base); + CAIRO_TRACE_END (__func__); return CAIRO_STATUS_SUCCESS; } @@ -2013,14 +2122,18 @@ _cairo_surface_default_acquire_source_image (void *_surface, cairo_image_surface_t **image_out, void **image_extra) { + CAIRO_TRACE_BEGIN (__func__); cairo_surface_t *surface = _surface; cairo_rectangle_int_t extents; - if (unlikely (! surface->backend->get_extents (surface, &extents))) + if (unlikely (! surface->backend->get_extents (surface, &extents))) { + CAIRO_TRACE_END (__func__); return _cairo_error (CAIRO_STATUS_INVALID_SIZE); + } *image_out = _cairo_surface_map_to_image (surface, &extents); *image_extra = NULL; + CAIRO_TRACE_END (__func__); return (*image_out)->base.status; } @@ -2120,27 +2233,40 @@ _cairo_surface_paint (cairo_surface_t *surface, const cairo_pattern_t *source, const cairo_clip_t *clip) { + CAIRO_TRACE_BEGIN (__func__); cairo_int_status_t status; TRACE ((stderr, "%s\n", __FUNCTION__)); - if (unlikely (surface->status)) + if (unlikely (surface->status)) { + CAIRO_TRACE_END (__func__); return surface->status; - if (unlikely (surface->finished)) + } + if (unlikely (surface->finished)) { + CAIRO_TRACE_END (__func__); return _cairo_surface_set_error (surface, _cairo_error (CAIRO_STATUS_SURFACE_FINISHED)); + } - if (_cairo_clip_is_all_clipped (clip)) + if (_cairo_clip_is_all_clipped (clip)) { + CAIRO_TRACE_END (__func__); return CAIRO_STATUS_SUCCESS; + } status = _pattern_has_error (source); - if (unlikely (status)) + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); return status; + } - if (nothing_to_do (surface, op, source)) + if (nothing_to_do (surface, op, source)) { + CAIRO_TRACE_END (__func__); return CAIRO_STATUS_SUCCESS; + } status = _cairo_surface_begin_modification (surface); - if (unlikely (status)) + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); return status; + } status = surface->backend->paint (surface, op, source, clip); if (status != CAIRO_INT_STATUS_NOTHING_TO_DO) { @@ -2148,6 +2274,7 @@ _cairo_surface_paint (cairo_surface_t *surface, surface->serial++; } + CAIRO_TRACE_END (__func__); return _cairo_surface_set_error (surface, status); } @@ -2158,38 +2285,54 @@ _cairo_surface_mask (cairo_surface_t *surface, const cairo_pattern_t *mask, const cairo_clip_t *clip) { + CAIRO_TRACE_BEGIN (__func__); cairo_int_status_t status; TRACE ((stderr, "%s\n", __FUNCTION__)); - if (unlikely (surface->status)) + if (unlikely (surface->status)) { + CAIRO_TRACE_END (__func__); return surface->status; - if (unlikely (surface->finished)) + } + if (unlikely (surface->finished)) { + CAIRO_TRACE_END (__func__); return _cairo_surface_set_error (surface, _cairo_error (CAIRO_STATUS_SURFACE_FINISHED)); + } - if (_cairo_clip_is_all_clipped (clip)) + if (_cairo_clip_is_all_clipped (clip)) { + CAIRO_TRACE_END (__func__); return CAIRO_STATUS_SUCCESS; + } /* If the mask is blank, this is just an expensive no-op */ if (_cairo_pattern_is_clear (mask) && _cairo_operator_bounded_by_mask (op)) { + CAIRO_TRACE_END (__func__); return CAIRO_STATUS_SUCCESS; } status = _pattern_has_error (source); - if (unlikely (status)) + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); return status; + } status = _pattern_has_error (mask); - if (unlikely (status)) + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); return status; + } - if (nothing_to_do (surface, op, source)) + if (nothing_to_do (surface, op, source)) { + CAIRO_TRACE_END (__func__); return CAIRO_STATUS_SUCCESS; + } status = _cairo_surface_begin_modification (surface); - if (unlikely (status)) + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); return status; + } status = surface->backend->mask (surface, op, source, mask, clip); if (status != CAIRO_INT_STATUS_NOTHING_TO_DO) { @@ -2197,6 +2340,7 @@ _cairo_surface_mask (cairo_surface_t *surface, surface->serial++; } + CAIRO_TRACE_END (__func__); return _cairo_surface_set_error (surface, status); } @@ -2217,35 +2361,50 @@ _cairo_surface_fill_stroke (cairo_surface_t *surface, cairo_antialias_t stroke_antialias, const cairo_clip_t *clip) { + CAIRO_TRACE_BEGIN (__func__); cairo_int_status_t status; TRACE ((stderr, "%s\n", __FUNCTION__)); - if (unlikely (surface->status)) + if (unlikely (surface->status)) { + CAIRO_TRACE_END (__func__); return surface->status; - if (unlikely (surface->finished)) - return _cairo_surface_set_error (surface, _cairo_error (CAIRO_STATUS_SURFACE_FINISHED)); - - if (_cairo_clip_is_all_clipped (clip)) - return CAIRO_STATUS_SUCCESS; + } - if (surface->is_clear && - fill_op == CAIRO_OPERATOR_CLEAR && - stroke_op == CAIRO_OPERATOR_CLEAR) - { - return CAIRO_STATUS_SUCCESS; - } + if (unlikely (surface->finished)) { + if (unlikely (surface->status)) { + CAIRO_TRACE_END (__func__); + return _cairo_surface_set_error (surface, _cairo_error (CAIRO_STATUS_SURFACE_FINISHED)); + } + if (_cairo_clip_is_all_clipped (clip)) { + CAIRO_TRACE_END (__func__); + return CAIRO_STATUS_SUCCESS; + } + + if (surface->is_clear && + fill_op == CAIRO_OPERATOR_CLEAR && + stroke_op == CAIRO_OPERATOR_CLEAR) { + CAIRO_TRACE_END (__func__); + return CAIRO_STATUS_SUCCESS; + } + } - status = _pattern_has_error (fill_source); - if (unlikely (status)) + status = _pattern_has_error (fill_source); + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); return status; + } status = _pattern_has_error (stroke_source); - if (unlikely (status)) + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); return status; + } status = _cairo_surface_begin_modification (surface); - if (unlikely (status)) + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); return status; + } if (surface->backend->fill_stroke) { cairo_matrix_t dev_ctm = *stroke_ctm; @@ -2284,6 +2443,7 @@ _cairo_surface_fill_stroke (cairo_surface_t *surface, surface->serial++; } + CAIRO_TRACE_END (__func__); return _cairo_surface_set_error (surface, status); } @@ -2299,27 +2459,40 @@ _cairo_surface_stroke (cairo_surface_t *surface, cairo_antialias_t antialias, const cairo_clip_t *clip) { + CAIRO_TRACE_BEGIN (__func__); cairo_int_status_t status; TRACE ((stderr, "%s\n", __FUNCTION__)); - if (unlikely (surface->status)) + if (unlikely (surface->status)) { + CAIRO_TRACE_END (__func__); return surface->status; - if (unlikely (surface->finished)) + } + if (unlikely (surface->finished)) { + CAIRO_TRACE_END (__func__); return _cairo_surface_set_error (surface, _cairo_error (CAIRO_STATUS_SURFACE_FINISHED)); + } - if (_cairo_clip_is_all_clipped (clip)) + if (_cairo_clip_is_all_clipped (clip)) { + CAIRO_TRACE_END (__func__); return CAIRO_STATUS_SUCCESS; + } status = _pattern_has_error (source); - if (unlikely (status)) + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); return status; + } - if (nothing_to_do (surface, op, source)) + if (nothing_to_do (surface, op, source)) { + CAIRO_TRACE_END (__func__); return CAIRO_STATUS_SUCCESS; + } status = _cairo_surface_begin_modification (surface); - if (unlikely (status)) + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); return status; + } status = surface->backend->stroke (surface, op, source, path, stroke_style, @@ -2331,6 +2504,7 @@ _cairo_surface_stroke (cairo_surface_t *surface, surface->serial++; } + CAIRO_TRACE_END (__func__); return _cairo_surface_set_error (surface, status); } @@ -2344,27 +2518,39 @@ _cairo_surface_fill (cairo_surface_t *surface, cairo_antialias_t antialias, const cairo_clip_t *clip) { + CAIRO_TRACE_BEGIN (__func__); cairo_int_status_t status; TRACE ((stderr, "%s\n", __FUNCTION__)); - if (unlikely (surface->status)) + if (unlikely (surface->status)) { + CAIRO_TRACE_END (__func__); return surface->status; - if (unlikely (surface->finished)) + } + if (unlikely (surface->finished)) { + CAIRO_TRACE_END (__func__); return _cairo_surface_set_error (surface, _cairo_error (CAIRO_STATUS_SURFACE_FINISHED)); - - if (_cairo_clip_is_all_clipped (clip)) + } + if (_cairo_clip_is_all_clipped (clip)) { + CAIRO_TRACE_END (__func__); return CAIRO_STATUS_SUCCESS; + } status = _pattern_has_error (source); - if (unlikely (status)) + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); return status; + } - if (nothing_to_do (surface, op, source)) + if (nothing_to_do (surface, op, source)) { + CAIRO_TRACE_END (__func__); return CAIRO_STATUS_SUCCESS; + } status = _cairo_surface_begin_modification (surface); - if (unlikely (status)) + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); return status; + } status = surface->backend->fill (surface, op, source, path, fill_rule, @@ -2375,6 +2561,7 @@ _cairo_surface_fill (cairo_surface_t *surface, surface->serial++; } + CAIRO_TRACE_END (__func__); return _cairo_surface_set_error (surface, status); } @@ -2395,20 +2582,27 @@ _cairo_surface_fill (cairo_surface_t *surface, void cairo_surface_copy_page (cairo_surface_t *surface) { - if (unlikely (surface->status)) + CAIRO_TRACE_BEGIN (__func__); + if (unlikely (surface->status)) { + CAIRO_TRACE_END (__func__); return; + } assert (surface->snapshot_of == NULL); if (unlikely (surface->finished)) { _cairo_surface_set_error (surface, CAIRO_STATUS_SURFACE_FINISHED); + CAIRO_TRACE_END (__func__); return; } /* It's fine if some backends don't implement copy_page */ - if (surface->backend->copy_page == NULL) + if (surface->backend->copy_page == NULL) { + CAIRO_TRACE_END (__func__); return; + } + CAIRO_TRACE_END (__func__); _cairo_surface_set_error (surface, surface->backend->copy_page (surface)); } slim_hidden_def (cairo_surface_copy_page); @@ -2428,26 +2622,34 @@ slim_hidden_def (cairo_surface_copy_page); void cairo_surface_show_page (cairo_surface_t *surface) { + CAIRO_TRACE_BEGIN (__func__); cairo_status_t status; - if (unlikely (surface->status)) + if (unlikely (surface->status)) { + CAIRO_TRACE_END (__func__); return; + } if (unlikely (surface->finished)) { _cairo_surface_set_error (surface, CAIRO_STATUS_SURFACE_FINISHED); + CAIRO_TRACE_END (__func__); return; } status = _cairo_surface_begin_modification (surface); if (unlikely (status)) { _cairo_surface_set_error (surface, status); + CAIRO_TRACE_END (__func__); return; } /* It's fine if some backends don't implement show_page */ - if (surface->backend->show_page == NULL) + if (surface->backend->show_page == NULL) { + CAIRO_TRACE_END (__func__); return; + } + CAIRO_TRACE_END (__func__); _cairo_surface_set_error (surface, surface->backend->show_page (surface)); } slim_hidden_def (cairo_surface_show_page); diff --git a/src/cairo-traps-compositor.c b/src/cairo-traps-compositor.c index c26a5df..8c13ca2 100644 --- a/src/cairo-traps-compositor.c +++ b/src/cairo-traps-compositor.c @@ -59,6 +59,7 @@ #include "cairo-spans-private.h" #include "cairo-traps-private.h" #include "cairo-tristrip-private.h" +#include "cairo-ttrace.h" typedef cairo_int_status_t (*draw_func_t) (const cairo_traps_compositor_t *compositor, @@ -2110,6 +2111,7 @@ static cairo_int_status_t _cairo_traps_compositor_paint (const cairo_compositor_t *_compositor, cairo_composite_rectangles_t *extents) { + CAIRO_TRACE_BEGIN (__func__); cairo_traps_compositor_t *compositor = (cairo_traps_compositor_t*)_compositor; cairo_boxes_t boxes; cairo_int_status_t status; @@ -2117,13 +2119,16 @@ _cairo_traps_compositor_paint (const cairo_compositor_t *_compositor, TRACE ((stderr, "%s\n", __FUNCTION__)); status = compositor->check_composite (extents); - if (unlikely (status)) + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); return status; + } _cairo_clip_steal_boxes (extents->clip, &boxes); status = clip_and_composite_boxes (compositor, extents, &boxes); _cairo_clip_unsteal_boxes (extents->clip, &boxes); + CAIRO_TRACE_END (__func__); return status; } @@ -2131,14 +2136,17 @@ static cairo_int_status_t _cairo_traps_compositor_mask (const cairo_compositor_t *_compositor, cairo_composite_rectangles_t *extents) { + CAIRO_TRACE_BEGIN (__func__); const cairo_traps_compositor_t *compositor = (cairo_traps_compositor_t*)_compositor; cairo_int_status_t status; TRACE ((stderr, "%s\n", __FUNCTION__)); status = compositor->check_composite (extents); - if (unlikely (status)) + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); return status; + } if (extents->mask_pattern.base.type == CAIRO_PATTERN_TYPE_SOLID && extents->clip->path == NULL) { @@ -2157,8 +2165,10 @@ _cairo_traps_compositor_mask (const cairo_compositor_t *_compositor, &extents->mask_sample_area, &data.mask_x, &data.mask_y); - if (unlikely (data.mask->status)) + if (unlikely (data.mask->status)) { + CAIRO_TRACE_END (__func__); return data.mask->status; + } status = clip_and_composite (compositor, extents, composite_mask, @@ -2168,6 +2178,7 @@ _cairo_traps_compositor_mask (const cairo_compositor_t *_compositor, cairo_surface_destroy (data.mask); } + CAIRO_TRACE_END (__func__); return status; } @@ -2181,14 +2192,17 @@ _cairo_traps_compositor_stroke (const cairo_compositor_t *_compositor, double tolerance, cairo_antialias_t antialias) { + CAIRO_TRACE_BEGIN (__func__); const cairo_traps_compositor_t *compositor = (cairo_traps_compositor_t *)_compositor; cairo_int_status_t status; TRACE ((stderr, "%s\n", __FUNCTION__)); status = compositor->check_composite (extents); - if (unlikely (status)) + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); return status; + } status = CAIRO_INT_STATUS_UNSUPPORTED; if (_cairo_path_fixed_stroke_is_rectilinear (path)) { @@ -2265,6 +2279,7 @@ _cairo_traps_compositor_stroke (const cairo_compositor_t *_compositor, _cairo_traps_fini (&info.traps); } + CAIRO_TRACE_END (__func__); return status; } @@ -2276,14 +2291,17 @@ _cairo_traps_compositor_fill (const cairo_compositor_t *_compositor, double tolerance, cairo_antialias_t antialias) { + CAIRO_TRACE_BEGIN (__func__); const cairo_traps_compositor_t *compositor = (cairo_traps_compositor_t *)_compositor; cairo_int_status_t status; TRACE ((stderr, "%s\n", __FUNCTION__)); status = compositor->check_composite (extents); - if (unlikely (status)) + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); return status; + } status = CAIRO_INT_STATUS_UNSUPPORTED; if (_cairo_path_fixed_fill_is_rectilinear (path)) { @@ -2332,6 +2350,7 @@ _cairo_traps_compositor_fill (const cairo_compositor_t *_compositor, _cairo_polygon_fini (&polygon); } + CAIRO_TRACE_END (__func__); return status; } @@ -2367,14 +2386,17 @@ _cairo_traps_compositor_glyphs (const cairo_compositor_t *_compositor, int num_glyphs, cairo_bool_t overlap) { + CAIRO_TRACE_BEGIN (__func__); const cairo_traps_compositor_t *compositor = (cairo_traps_compositor_t *)_compositor; cairo_int_status_t status; TRACE ((stderr, "%s\n", __FUNCTION__)); status = compositor->check_composite (extents); - if (unlikely (status)) + if (unlikely (status)) { + CAIRO_TRACE_END (__func__); return status; + } _cairo_scaled_font_freeze_cache (scaled_font); status = compositor->check_composite_glyphs (extents, @@ -2395,6 +2417,7 @@ _cairo_traps_compositor_glyphs (const cairo_compositor_t *_compositor, } _cairo_scaled_font_thaw_cache (scaled_font); + CAIRO_TRACE_END (__func__); return status; } diff --git a/src/cairo-ttrace.h b/src/cairo-ttrace.h new file mode 100644 index 0000000..0733ba4 --- /dev/null +++ b/src/cairo-ttrace.h @@ -0,0 +1,47 @@ +/* Cairo - a vector graphics library with display and print output + * + * Copyright © 2009 Chris Wilson + * Copyright © 2014 Samsung Electronics + * + * This library is free software; you can redistribute it and/or + * modify it either under the terms of the GNU Lesser General Public + * License version 2.1 as published by the Free Software Foundation + * (the "LGPL") or, at your option, under the terms of the Mozilla + * Public License Version 1.1 (the "MPL"). If you do not alter this + * notice, a recipient may use your version of this file under either + * the MPL or the LGPL. + * + * You should have received a copy of the LGPL along with this library + * in the file COPYING-LGPL-2.1; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA + * You should have received a copy of the MPL along with this library + * in the file COPYING-MPL-1.1 + * + * The contents of this file are subject to the Mozilla Public License + * Version 1.1 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY + * OF ANY KIND, either express or implied. See the LGPL or the MPL for + * the specific language governing rights and limitations. + * + * The Original Code is the cairo graphics library. + * + */ + + +#ifdef CAIRO_HAS_TTRACE +#include +//#define CAIRO_TRACE_BEGIN(NAME) traceBegin(TTRACE_TAG_GRAPHICS, NAME) +//#define CAIRO_TRACE_END() traceEnd(TTRACE_TAG_GRAPHICS) +#define CAIRO_TRACE_BEGIN(NAME) traceAsyncBegin (TTRACE_TAG_GRAPHICS, 0, NAME); +#define CAIRO_TRACE_END(NAME) traceAsyncEnd(TTRACE_TAG_GRAPHICS, 0, NAME); +#else +#define CAIRO_TRACE_BEGIN(NAME) +#define CAIRO_TRACE_END(NAME) +#define CAIRO_TRACE_ASYNC_BEGIN(NAME, KEY) +#define CAIRO_TRACE_ASYNC_END(NAME, KEY) +#endif + + diff --git a/src/cairo.c b/src/cairo.c index 983f02c..d339640 100644 --- a/src/cairo.c +++ b/src/cairo.c @@ -49,6 +49,7 @@ #include "cairo-surface-backend-private.h" #include +#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__); } /** -- 2.7.4