1 svntiny: svntiny_gradient.c: only print debugging if GRADIENT_DEBUG is enabled
3 Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk>
5 src/svgtiny_gradient.c | 23 ++++++++++++++++++++++-
6 1 file changed, 22 insertions(+), 1 deletion(-)
8 Index: libsvgtiny/src/svgtiny_gradient.c
9 ===================================================================
10 --- libsvgtiny.orig/src/svgtiny_gradient.c
11 +++ libsvgtiny/src/svgtiny_gradient.c
12 @@ -30,8 +30,9 @@ void svgtiny_find_gradient(const char *i
16 +#ifdef GRADIENT_DEBUG
17 fprintf(stderr, "svgtiny_find_gradient: id \"%s\"\n", id);
20 state->linear_gradient_stop_count = 0;
21 state->gradient_x1 = "0%";
22 state->gradient_y1 = "0%";
23 @@ -47,13 +48,17 @@ void svgtiny_find_gradient(const char *i
25 gradient = svgtiny_find_element_by_id(
26 (xmlNode *) state->document, id);
27 +#ifdef GRADIENT_DEBUG
28 fprintf(stderr, "gradient %p\n", (void *) gradient);
31 fprintf(stderr, "gradient \"%s\" not found\n", id);
35 +#ifdef GRADIENT_DEBUG
36 fprintf(stderr, "gradient name \"%s\"\n", gradient->name);
38 if (strcmp((const char *) gradient->name, "linearGradient") == 0) {
39 svgtiny_parse_linear_gradient(gradient, state);
41 @@ -98,8 +103,10 @@ svgtiny_code svgtiny_parse_linear_gradie
42 return svgtiny_OUT_OF_MEMORY;
43 svgtiny_parse_transform(s, &a, &b, &c, &d, &e, &f);
45 +#ifdef GRADIENT_DEBUG
46 fprintf(stderr, "transform %g %g %g %g %g %g\n",
49 state->gradient_transform.a = a;
50 state->gradient_transform.b = b;
51 state->gradient_transform.c = c;
52 @@ -143,7 +150,9 @@ svgtiny_code svgtiny_parse_linear_gradie
55 if (offset != -1 && color != svgtiny_TRANSPARENT) {
56 +#ifdef GRADIENT_DEBUG
57 fprintf(stderr, "stop %g %x\n", offset, color);
59 state->gradient_stop[i].offset = offset;
60 state->gradient_stop[i].color = color;
62 @@ -220,9 +229,11 @@ svgtiny_code svgtiny_add_path_linear_gra
65 /* compute gradient vector */
66 +#ifdef GRADIENT_DEBUG
67 fprintf(stderr, "x1 %s, y1 %s, x2 %s, y2 %s\n",
68 state->gradient_x1, state->gradient_y1,
69 state->gradient_x2, state->gradient_y2);
71 if (!state->gradient_user_space_on_use) {
72 gradient_x0 = object_x0 +
73 svgtiny_parse_length(state->gradient_x1,
74 @@ -297,9 +308,11 @@ svgtiny_code svgtiny_add_path_linear_gra
76 /* invert gradient transform for applying to vertices */
77 svgtiny_invert_matrix(&state->gradient_transform.a, trans);
78 +#ifdef GRADIENT_DEBUG
79 fprintf(stderr, "inverse transform %g %g %g %g %g %g\n",
80 trans[0], trans[1], trans[2], trans[3],
84 /* compute points on the path for triangle vertices */
85 /* r, r0, r1 are distance along gradient vector */
86 @@ -372,8 +385,10 @@ svgtiny_code svgtiny_add_path_linear_gra
87 steps = ceilf(fabsf(r1 - r0) / 0.05);
90 +#ifdef GRADIENT_DEBUG
91 fprintf(stderr, "r0 %g, r1 %g, steps %i\n",
95 /* loop through intermediate points */
96 for (z = 1; z != steps; z++) {
97 @@ -398,7 +413,9 @@ svgtiny_code svgtiny_add_path_linear_gra
98 r = ((x_trans - gradient_x0) * gradient_dx +
99 (y_trans - gradient_y0) * gradient_dy) /
100 gradient_norm_squared;
101 +#ifdef GRADIENT_DEBUG
102 fprintf(stderr, "(%g %g [%g]) ", x, y, r);
104 point = svgtiny_list_push(pts);
106 svgtiny_list_free(pts);
107 @@ -412,14 +429,18 @@ svgtiny_code svgtiny_add_path_linear_gra
108 min_pt = svgtiny_list_size(pts) - 1;
111 +#ifdef GRADIENT_DEBUG
112 fprintf(stderr, "\n");
115 /* next segment start point is this segment end point */
119 +#ifdef GRADIENT_DEBUG
120 fprintf(stderr, "pts size %i, min_pt %i, min_r %.3f\n",
121 svgtiny_list_size(pts), min_pt, min_r);
124 /* render triangles */
125 stop_count = state->linear_gradient_stop_count;