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