smooth: Fix some data types mismatching with their sources.
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
diff --git a/ChangeLog b/ChangeLog
index 28ed08e..5279c9d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,34 @@
2009-07-31 suzuki toshiya <mpsuzuki@hiroshima-u.ac.jp>
+ smooth: Fix some data types mismatching with their sources.
+
+ * src/smooth/ftgrays.c: The type of `TCoord' is
+ matched to `TPos', because they are mixed in
+ gray_set_cell(). The type of TCell->x is extended
+ to `TPos', because gray_find_cell() sets it by
+ TWorker.ex. The type of TCell->cover is extended
+ to `TCoord', because gray_render_scanline() adds
+ TCoord value to it. The type of TWork.cover is matched
+ with TCell->cover. The types of
+ TWork.{max_cells,num_cells} are changed to FT_PtrDist,
+ because they are calculated from the memory addresses.
+ The type of TWork.ycount is changed to TPos, because
+ it is calculated from TPos variables.
+ (gray_find_cell): The type of `x' is matched with
+ its initial value ras.ex.
+ (gray_render_scanline): The types of `mod', `lift'
+ and `rem' are changed to TCoord, because their values
+ are set with explicit casts to TCoord. When ras.area
+ is updated by the differential values including
+ `delta', they are explicitly casted to TArea, because
+ the type of `delta' is not TArea but TCoord.
+ (gray_render_line): The type of `mod' is extended
+ from int to TCoord, because (TCoord)dy is added to mod.
+ (gray_hline): The argument `acount' is extended to
+ TCoord, to match with the parameters in the callers.
+
+2009-07-31 suzuki toshiya <mpsuzuki@hiroshima-u.ac.jp>
+
cff: Fix some data types mismatching with their sources.
* src/cff/cffobjs.c (cff_face_init): The type of
diff --git a/src/smooth/ftgrays.c b/src/smooth/ftgrays.c
index efb438b..ba5541d 100644
--- a/src/smooth/ftgrays.c
+++ b/src/smooth/ftgrays.c
@@ -275,7 +275,7 @@
/* need to define them to "float" or "double" when experimenting with */
/* new algorithms */
- typedef int TCoord; /* integer scanline/pixel coordinate */
+ typedef long TCoord; /* integer scanline/pixel coordinate */
typedef long TPos; /* sub-pixel coordinate */
/* determine the type used to store cell areas. This normally takes at */
@@ -306,8 +306,8 @@
typedef struct TCell_
{
- int x;
- int cover;
+ TPos x; /* same with TWorker.ex */
+ TCoord cover; /* same with TWorker.cover */
TArea area;
PCell next;
@@ -322,12 +322,12 @@
TPos count_ex, count_ey;
TArea area;
- int cover;
+ TCoord cover;
int invalid;
PCell cells;
- int max_cells;
- int num_cells;
+ FT_PtrDist max_cells;
+ FT_PtrDist num_cells;
TCoord cx, cy;
TPos x, y;
@@ -359,7 +359,7 @@
long buffer_size;
PCell* ycells;
- int ycount;
+ TPos ycount;
} TWorker, *PWorker;
@@ -456,7 +456,7 @@
gray_find_cell( RAS_ARG )
{
PCell *pcell, cell;
- int x = ras.ex;
+ TPos x = ras.ex;
if ( x > ras.count_ex )
@@ -588,9 +588,9 @@
TPos x2,
TCoord y2 )
{
- TCoord ex1, ex2, fx1, fx2, delta;
+ TCoord ex1, ex2, fx1, fx2, delta, mod, lift, rem;
long p, first, dx;
- int incr, lift, mod, rem;
+ int incr;
dx = x2 - x1;
@@ -612,7 +612,7 @@
if ( ex1 == ex2 )
{
delta = y2 - y1;
- ras.area += (TArea)( fx1 + fx2 ) * delta;
+ ras.area += (TArea)(( fx1 + fx2 ) * delta);
ras.cover += delta;
return;
}
@@ -640,7 +640,7 @@
mod += (TCoord)dx;
}
- ras.area += (TArea)( fx1 + first ) * delta;
+ ras.area += (TArea)(( fx1 + first ) * delta);
ras.cover += delta;
ex1 += incr;
@@ -670,7 +670,7 @@
delta++;
}
- ras.area += (TArea)ONE_PIXEL * delta;
+ ras.area += (TArea)(ONE_PIXEL * delta);
ras.cover += delta;
y1 += delta;
ex1 += incr;
@@ -679,7 +679,7 @@
}
delta = y2 - y1;
- ras.area += (TArea)( fx2 + ONE_PIXEL - first ) * delta;
+ ras.area += (TArea)(( fx2 + ONE_PIXEL - first ) * delta);
ras.cover += delta;
}
@@ -692,10 +692,10 @@
gray_render_line( RAS_ARG_ TPos to_x,
TPos to_y )
{
- TCoord ey1, ey2, fy1, fy2;
+ TCoord ey1, ey2, fy1, fy2, mod;
TPos dx, dy, x, x2;
long p, first;
- int delta, rem, mod, lift, incr;
+ int delta, rem, lift, incr;
ey1 = TRUNC( ras.last_ey );
@@ -1231,7 +1231,7 @@
gray_hline( RAS_ARG_ TCoord x,
TCoord y,
TPos area,
- int acount )
+ TCoord acount )
{
FT_Span* span;
int count;