summaryrefslogtreecommitdiffstats
path: root/gentoo/media-libs/libart_lgpl/files/0002-TDE-fix-a-number-of-problems.patch
blob: b00967e08cd1b9c9255c4899018bd8b86762d484 (plain)
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
From 12ea00aa1898e33a467e2d8e18b6ebad43a181f3 Mon Sep 17 00:00:00 2001
From: Golubev Alexander <fatzer2@gmail.com>
Date: Thu, 15 Aug 2013 02:08:26 +0400
Subject: [PATCH 2/3] TDE: fix a number of problems

Conflicts:
	art_config.h
---
 ChangeLog             |   2 +
 README                |  14 ++++++
 art_render_gradient.c |  28 ++++++++++++
 art_render_gradient.h |   3 +-
 art_vpath_bpath.c     | 119 ++++++++++++++++++++++++--------------------------
 gen_art_config.sh.in  |   6 +++
 libart-config.in      |  13 +++++-
 testart.c             |   6 +++
 8 files changed, 127 insertions(+), 64 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 6861cf3..e274c9c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,5 @@
+*** PLEASE SEE THE GIT COMMIT LOG FOR NEWER CHANGES ***
+
 2009-01-14  Fridrich Strba  <fridrich.strba@bluewin.ch>
 
 	* gen_art_config.c: remove
diff --git a/README b/README
index 882527e..a88ec40 100644
--- a/README
+++ b/README
@@ -17,3 +17,17 @@ For more information about libart, see the web page:
 There's also a libart tutorial available at
 http://www.gnome.org/~mathieu/libart/libart.html
 
+======================================================================
+
+NOTE: The TDE project has take over maintinance of this library,
+starting with the sources from the final upstream release v2.3.21.
+
+This allows the TDE project to resolve remaining issues that cause
+problems or crashes within TDE.
+
+This patched library is only available under the terms of the
+GPL/LGPL, and is NOT for sale by the original author as mentioned
+above, as patch copyright has NOT been transferred to the original
+author and we have no plans to do so.
+
+======================================================================
diff --git a/art_render_gradient.c b/art_render_gradient.c
index bf93c6f..008d61a 100644
--- a/art_render_gradient.c
+++ b/art_render_gradient.c
@@ -30,7 +30,9 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#if 0
 #include <assert.h>
+#endif
 
 /* Hack to find out how to define alloca on different platforms.
  * Modified version of glib/galloca.h.
@@ -203,7 +205,9 @@ calc_color_at (ArtGradientStop *stops,
     }
 
   printf ("WARNING! bad ix %d in calc_color_at() [internal error]\n", ix);
+#if 0
   assert (0);
+#endif
 }
 
 static void
@@ -331,6 +335,7 @@ art_render_gradient_linear_render_8 (ArtRenderCallback *self,
   printf ("Initial ix: %d\n", ix);
 #endif
   
+#if 0
   assert (ix > 0);
   assert (ix < n_stops);
   assert ((stops[ix-1].offset <= offset_fraction + EPSILON) ||
@@ -344,6 +349,17 @@ art_render_gradient_linear_render_8 (ArtRenderCallback *self,
   assert ((offset_fraction != stops[ix].offset) ||
 	  (d_offset <= 0.0));
   */
+#else
+  if (!( (ix > 0) && (ix < n_stops)
+         && ((stops[ix-1].offset <= offset_fraction + EPSILON) ||
+             ((stops[ix].offset > (1.0 - EPSILON))
+              && (offset_fraction < EPSILON /* == 0.0*/)))
+         && (offset_fraction <= stops[ix].offset)))
+  {
+    printf ("art_render_gradient.c:%d: Old assert() failed!\n", __LINE__);
+    return;
+  }
+#endif
   
   while (width > 0)
     {
@@ -663,6 +679,18 @@ art_render_gradient_radial_render (ArtRenderCallback *self, ArtRender *render,
 	z = b_a + sqrt (rad);
       else
 	z = b_a;
+
+      if (gradient->spread == ART_GRADIENT_PAD)
+	z = z;
+      else if (gradient->spread == ART_GRADIENT_REPEAT)
+	z = z - floor (z);
+      else /* (gradient->spread == ART_GRADIENT_REFLECT) */
+	{
+	  double tmp;
+
+	  tmp = z - 2 * floor (0.5 * z);
+	  z = tmp > 1 ? 2 - tmp : tmp;
+	}
       art_render_gradient_setpix (render, bufp, n_stops, stops, z);
       bufp += pixstride;
       b_a += db_a;
diff --git a/art_render_gradient.h b/art_render_gradient.h
index ef5da95..7e8e0c8 100644
--- a/art_render_gradient.h
+++ b/art_render_gradient.h
@@ -52,14 +52,15 @@ struct _ArtGradientLinear {
   double a;
   double b;
   double c;
-  ArtGradientSpread spread;
   int n_stops;
   ArtGradientStop *stops;
+  ArtGradientSpread spread;
 };
 
 struct _ArtGradientRadial {
   double affine[6]; /* transforms user coordinates to unit circle */
   double fx, fy;    /* focal point in unit circle coords */
+  ArtGradientSpread spread;
   int n_stops;
   ArtGradientStop *stops;
 };
diff --git a/art_vpath_bpath.c b/art_vpath_bpath.c
index 3f9afe7..2459f23 100644
--- a/art_vpath_bpath.c
+++ b/art_vpath_bpath.c
@@ -123,18 +123,6 @@ art_vpath_render_bez (ArtVpath **p_vpath, int *pn, int *pn_max,
 		      double x3, double y3,
 		      double flatness)
 {
-  double x3_0, y3_0;
-  double z3_0_dot;
-  double z1_dot, z2_dot;
-  double z1_perp, z2_perp;
-  double max_perp_sq;
-
-  double x_m, y_m;
-  double xa1, ya1;
-  double xa2, ya2;
-  double xb1, yb1;
-  double xb2, yb2;
-
   /* It's possible to optimize this routine a fair amount.
 
      First, once the _dot conditions are met, they will also be met in
@@ -157,70 +145,79 @@ art_vpath_render_bez (ArtVpath **p_vpath, int *pn, int *pn_max,
      just that I have this undying quest for more speed...
 
   */
-
-  x3_0 = x3 - x0;
-  y3_0 = y3 - y0;
-
-  /* z3_0_dot is dist z0-z3 squared */
-  z3_0_dot = x3_0 * x3_0 + y3_0 * y3_0;
-
-  if (z3_0_dot < 0.001)
+  do
     {
-      /* if start and end point are almost identical, the flatness tests
-       * don't work properly, so fall back on testing whether both of
-       * the other two control points are the same as the start point,
-       * too.
-       */
-      if (hypot(x1 - x0, y1 - y0) < 0.001
-	  && hypot(x2 - x0, y2 - y0) < 0.001)
-	  goto nosubdivide;
-      else
-	  goto subdivide;
-    }
+    /* don't subdivide inside this */
+    double x3_0, y3_0;
+    double z3_0_dot;
+    double z1_dot, z2_dot;
+    double z1_perp, z2_perp;
+    double max_perp_sq;
 
-  /* we can avoid subdivision if:
+    x3_0 = x3 - x0;
+    y3_0 = y3 - y0;
 
-     z1 has distance no more than flatness from the z0-z3 line
+    /* z3_0_dot is dist z0-z3 squared */
+    z3_0_dot = x3_0 * x3_0 + y3_0 * y3_0;
 
-     z1 is no more z0'ward than flatness past z0-z3
+    if (z3_0_dot > 0.001)
+      {
+       /* we can avoid subdivision if:
 
-     z1 is more z0'ward than z3'ward on the line traversing z0-z3
+          z1 has distance no more than flatness from the z0-z3 line
 
-     and correspondingly for z2 */
+          z1 is no more z0'ward than flatness past z0-z3
 
-  /* perp is distance from line, multiplied by dist z0-z3 */
-  max_perp_sq = flatness * flatness * z3_0_dot;
+          z1 is more z0'ward than z3'ward on the line traversing z0-z3
 
-  z1_perp = (y1 - y0) * x3_0 - (x1 - x0) * y3_0;
-  if (z1_perp * z1_perp > max_perp_sq)
-    goto subdivide;
+          and correspondingly for z2 */
 
-  z2_perp = (y3 - y2) * x3_0 - (x3 - x2) * y3_0;
-  if (z2_perp * z2_perp > max_perp_sq)
-    goto subdivide;
+        /* perp is distance from line, multiplied by dist z0-z3 */
+        max_perp_sq = flatness * flatness * z3_0_dot;
 
-  z1_dot = (x1 - x0) * x3_0 + (y1 - y0) * y3_0;
-  if (z1_dot < 0 && z1_dot * z1_dot > max_perp_sq)
-    goto subdivide;
+        z1_perp = (y1 - y0) * x3_0 - (x1 - x0) * y3_0;
+        if (z1_perp * z1_perp > max_perp_sq)
+          break;
 
-  z2_dot = (x3 - x2) * x3_0 + (y3 - y2) * y3_0;
-  if (z2_dot < 0 && z2_dot * z2_dot > max_perp_sq)
-    goto subdivide;
+        z2_perp = (y3 - y2) * x3_0 - (x3 - x2) * y3_0;
+        if (z2_perp * z2_perp > max_perp_sq)
+          break;
 
-  if (z1_dot + z1_dot > z3_0_dot)
-    goto subdivide;
+        z1_dot = (x1 - x0) * x3_0 + (y1 - y0) * y3_0;
+        if (z1_dot < 0 && z1_dot * z1_dot > max_perp_sq)
+          break;
 
-  if (z2_dot + z2_dot > z3_0_dot)
-    goto subdivide;
+        if (z1_dot + z1_dot > z3_0_dot)
+          break;
 
-      
- nosubdivide:
-  /* don't subdivide */
-  art_vpath_add_point (p_vpath, pn, pn_max,
-		       ART_LINETO, x3, y3);
-  return;
+        z2_dot = (x3 - x2) * x3_0 + (y3 - y2) * y3_0;
+        if (z2_dot < 0 && z2_dot * z2_dot > max_perp_sq)
+          break;
 
- subdivide:
+        if (z2_dot + z2_dot > z3_0_dot)
+          break;
+      }
+    else
+      {
+      /* if start and end point are almost identical, the flatness tests
+       * don't work properly, so fall back on testing whether both of
+       * the other two control points are the same as the start point,
+       * too.
+       */
+        if (hypot(x1 - x0, y1 - y0) > 0.001
+            || hypot(x2 - x0, y2 - y0) > 0.001)
+            break;
+      }
+
+      art_vpath_add_point (p_vpath, pn, pn_max,
+                           ART_LINETO, x3, y3);
+      return;
+    } while (0);
+  double x_m, y_m;
+  double xa1, ya1;
+  double xa2, ya2;
+  double xb1, yb1;
+  double xb2, yb2;
 
   xa1 = (x0 + x1) * 0.5;
   ya1 = (y0 + y1) * 0.5;
diff --git a/gen_art_config.sh.in b/gen_art_config.sh.in
index 79843bc..8c525bd 100644
--- a/gen_art_config.sh.in
+++ b/gen_art_config.sh.in
@@ -8,6 +8,9 @@
 
 echo "/* Automatically generated by gen_art_config */"
 echo
+echo "#ifndef _ART_CONFIG_H_"
+echo "#define _ART_CONFIG_H_"
+echo
 echo "#define ART_SIZEOF_CHAR @ART_SIZEOF_CHAR@"
 echo "#define ART_SIZEOF_SHORT @ART_SIZEOF_SHORT@"
 echo "#define ART_SIZEOF_INT @ART_SIZEOF_INT@"
@@ -39,5 +42,8 @@ else
   fi
 fi
 
+echo
+echo "#endif /* _ART_CONFIG_H_ */"
+
 exit 0
 }
diff --git a/libart-config.in b/libart-config.in
index 0a2f3a9..e32f010 100644
--- a/libart-config.in
+++ b/libart-config.in
@@ -3,6 +3,8 @@
 prefix=@prefix@
 exec_prefix=@exec_prefix@
 exec_prefix_set=no
+libs=""
+output_libs=no
 
 usage="\
 Usage: libart-config [--prefix[=DIR]] [--exec-prefix[=DIR]] [--version] [--libs] [--cflags]"
@@ -43,8 +45,11 @@ while test $# -gt 0; do
       echo $includes
       ;;
     --libs)
-      libdirs=-L@libdir@
-      echo $libdirs -lart_lgpl_2 -lm
+      libs="$libs -L@libdir@ -lart_lgpl_2"
+      output_libs=yes
+      ;;
+    --static)
+      libs="$libs -lm"
       ;;
     *)
       echo "${usage}" 1>&2
@@ -54,3 +59,7 @@ while test $# -gt 0; do
   shift
 done
 
+if test $output_libs = yes ; then
+    echo $libs
+fi
+
diff --git a/testart.c b/testart.c
index f20b292..994c7ba 100644
--- a/testart.c
+++ b/testart.c
@@ -228,6 +228,7 @@ make_testpat (void)
   art_free (vpath3);
 #else
   svp2 = art_svp_from_vpath (vpath2);
+  art_free (vpath2);
 #endif
 
 #if 1
@@ -361,6 +362,7 @@ test_dist (void)
 			       4,
 			       0.5);
 #endif
+  art_free (vpath);
 
   art_rgb_svp_aa (svp, 0, 0, 512, 512,
 		  0xffe0a0, 0x100040,
@@ -431,10 +433,12 @@ test_render_gradient (art_u8 *buf)
 
   vpath = randstar (50);
   svp = art_svp_from_vpath (vpath);
+  art_free (vpath);
 
   render = art_render_new (0, 0, 512, 512, buf, 512 * 3, 3, 8, ART_ALPHA_NONE,
 			   NULL);
   art_render_svp (render, svp);
+  art_svp_free (svp);
   art_render_gradient_linear (render, &gradient, ART_FILTER_NEAREST);
   art_render_invoke (render);
 
@@ -467,6 +471,7 @@ test_render_rad_gradient (art_u8 *buf)
 
   vpath = randstar (50);
   svp = art_svp_from_vpath (vpath);
+  art_free (vpath);
 
   render = art_render_new (0, 0, 512, 512, buf, 512 * 3, 3, 8, ART_ALPHA_NONE,
 			   NULL);
@@ -489,6 +494,7 @@ test_gradient (void)
 
   vpath = randstar (50);
   svp = art_svp_from_vpath (vpath);
+  art_free (vpath);
 
   for (i = 0; i < n_iter; i++)
     {
-- 
1.8.1.5