[base] Refactor experimental (disabled) BBox_Cubic_Check. * src/base/ftbbox.c (BBox_Cubic_Check): Implement the minimum search as the mirror image of the maximum search.
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
diff --git a/ChangeLog b/ChangeLog
index e1d3a33..dc12dd1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2013-08-13 Alexei Podtelezhnikov <apodtele@gmail.com>
+
+ [base] Refactor experimental (disabled) BBox_Cubic_Check.
+
+ * src/base/ftbbox.c (BBox_Cubic_Check): Implement the minimum search
+ as the mirror image of the maximum search.
+
2013-08-06 John Tytgat <John.Tytgat@esko.com>
Fix Savannah bug #39702.
diff --git a/src/base/ftbbox.c b/src/base/ftbbox.c
index 6d1c44c..ca53dd8 100644
--- a/src/base/ftbbox.c
+++ b/src/base/ftbbox.c
@@ -216,25 +216,16 @@
#if 0
- static void
- BBox_Cubic_Check( FT_Pos p1,
- FT_Pos p2,
- FT_Pos p3,
- FT_Pos p4,
- FT_Pos* min,
- FT_Pos* max )
+ static FT_Pos
+ update_max( FT_Pos q1,
+ FT_Pos q2,
+ FT_Pos q3,
+ FT_Pos q4,
+ FT_Pos max )
{
- FT_Pos q1, q2, q3, q4;
-
-
- q1 = p1;
- q2 = p2;
- q3 = p3;
- q4 = p4;
-
/* for a conic segment to possibly reach new maximum */
/* one of its off-points must be above the current value */
- while ( q2 > *max || q3 > *max )
+ while ( q2 > max || q3 > max )
{
/* determine which half contains the maximum and split */
if ( q1 + q2 > q3 + q4 ) /* first half */
@@ -263,61 +254,31 @@
/* check if either end reached the maximum */
if ( q1 == q2 && q1 >= q3 )
{
- *max = q1;
+ max = q1;
break;
}
if ( q3 == q4 && q2 <= q4 )
{
- *max = q4;
+ max = q4;
break;
}
}
- q1 = p1;
- q2 = p2;
- q3 = p3;
- q4 = p4;
+ return max;
+ }
- /* for a conic segment to possibly reach new minimum */
- /* one of its off-points must be below the current value */
- while ( q2 < *min || q3 < *min )
- {
- /* determine which half contains the minimum and split */
- if ( q1 + q2 < q3 + q4 ) /* first half */
- {
- q4 = q4 + q3;
- q3 = q3 + q2;
- q2 = q2 + q1;
- q4 = q4 + q3;
- q3 = q3 + q2;
- q4 = ( q4 + q3 ) / 8;
- q3 = q3 / 4;
- q2 = q2 / 2;
- }
- else /* second half */
- {
- q1 = q1 + q2;
- q2 = q2 + q3;
- q3 = q3 + q4;
- q1 = q1 + q2;
- q2 = q2 + q3;
- q1 = ( q1 + q2 ) / 8;
- q2 = q2 / 4;
- q3 = q3 / 2;
- }
+ static void
+ BBox_Cubic_Check( FT_Pos p1,
+ FT_Pos p2,
+ FT_Pos p3,
+ FT_Pos p4,
+ FT_Pos* min,
+ FT_Pos* max )
+ {
+ *max = update_max( p1, p2, p3, p4, *max );
- /* check if either end reached the minimum */
- if ( q1 == q2 && q1 <= q3 )
- {
- *min = q1;
- break;
- }
- if ( q3 == q4 && q2 >= q4 )
- {
- *min = q4;
- break;
- }
- }
+ /* now flip the signs to update the minimum */
+ *min = -update_max( -p1, -p2, -p3, -p4, -*min );
}
#else