[smooth] Minor refactoring. * src/smooth/ftgrays.c (gray_render_scanline, gray_render_line): Updated.
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
diff --git a/ChangeLog b/ChangeLog
index 4254ed4..b0953dd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2016-08-05 Alexei Podtelezhnikov <apodtele@gmail.com>
+
+ [smooth] Minor refactoring.
+
+ * src/smooth/ftgrays.c (gray_render_scanline, gray_render_line):
+ Updated.
+
2016-07-29 Werner Lemberg <wl@gnu.org>
[sfnt, truetype] Don't abort on invalid `maxComponentDepth'.
diff --git a/src/smooth/ftgrays.c b/src/smooth/ftgrays.c
index 0bf3ac6..48d01cd 100644
--- a/src/smooth/ftgrays.c
+++ b/src/smooth/ftgrays.c
@@ -657,14 +657,14 @@ typedef ptrdiff_t FT_PtrDist;
return;
}
- fx1 = (TCoord)( x1 - SUBPIXELS( ex1 ) );
- fx2 = (TCoord)( x2 - SUBPIXELS( ex2 ) );
+ fx1 = (TCoord)( x1 - SUBPIXELS( ex1 ) );
+ fx2 = (TCoord)( x2 - SUBPIXELS( ex2 ) );
+ delta = y2 - y1;
/* everything is located in a single cell. That is easy! */
/* */
if ( ex1 == ex2 )
{
- delta = y2 - y1;
ras.area += (TArea)(( fx1 + fx2 ) * delta);
ras.cover += delta;
return;
@@ -673,14 +673,17 @@ typedef ptrdiff_t FT_PtrDist;
/* ok, we'll have to render a run of adjacent cells on the same */
/* scanline... */
/* */
- p = ( ONE_PIXEL - fx1 ) * ( y2 - y1 );
- first = ONE_PIXEL;
- incr = 1;
- dx = x2 - x1;
+ dx = x2 - x1;
- if ( dx < 0 )
+ if ( dx > 0 )
{
- p = fx1 * ( y2 - y1 );
+ p = ( ONE_PIXEL - fx1 ) * delta;
+ first = ONE_PIXEL;
+ incr = 1;
+ }
+ else
+ {
+ p = fx1 * delta;
first = 0;
incr = -1;
dx = -dx;
@@ -764,8 +767,6 @@ typedef ptrdiff_t FT_PtrDist;
dy = to_y - ras.y;
/* vertical line - avoid calling gray_render_scanline */
- incr = 1;
-
if ( dx == 0 )
{
TCoord ex = TRUNC( ras.x );
@@ -773,8 +774,12 @@ typedef ptrdiff_t FT_PtrDist;
TArea area;
- first = ONE_PIXEL;
- if ( dy < 0 )
+ if ( dy > 0)
+ {
+ first = ONE_PIXEL;
+ incr = 1;
+ }
+ else
{
first = 0;
incr = -1;
@@ -806,11 +811,13 @@ typedef ptrdiff_t FT_PtrDist;
}
/* ok, we have to render several scanlines */
- p = ( ONE_PIXEL - fy1 ) * dx;
- first = ONE_PIXEL;
- incr = 1;
-
- if ( dy < 0 )
+ if ( dy > 0)
+ {
+ p = ( ONE_PIXEL - fy1 ) * dx;
+ first = ONE_PIXEL;
+ incr = 1;
+ }
+ else
{
p = fy1 * dx;
first = 0;