From e45e052279c609019822737421eec4f49fcd99cf Mon Sep 17 00:00:00 2001 From: suzuki toshiya Date: Sat, 1 Aug 2009 00:32:08 +0900 Subject: [PATCH] smooth: Fix some data types mismatching with their sources. --- ChangeLog | 29 +++++++++++++++++++++++++++++ src/smooth/ftgrays.c | 34 +++++++++++++++++----------------- 2 files changed, 46 insertions(+), 17 deletions(-) diff --git a/ChangeLog b/ChangeLog index 28ed08e5f..5279c9d3c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,32 @@ +2009-07-31 suzuki toshiya + + 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 cff: Fix some data types mismatching with their sources. diff --git a/src/smooth/ftgrays.c b/src/smooth/ftgrays.c index efb438b4e..ba5541d91 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;