* src/smooth/ftgrays.c (gray_render_scanline): Improve code.
This commit is contained in:
parent
fa437d8d3c
commit
2ca5b07d4f
|
@ -1,3 +1,7 @@
|
||||||
|
2017-01-31 Alexei Podtelezhnikov <apodtele@gmail.com>
|
||||||
|
|
||||||
|
* src/smooth/ftgrays.c (gray_render_scanline): Improve code.
|
||||||
|
|
||||||
2017-01-31 Werner Lemberg <wl@gnu.org>
|
2017-01-31 Werner Lemberg <wl@gnu.org>
|
||||||
|
|
||||||
[cff] Provide metrics variation service interface (#50196).
|
[cff] Provide metrics variation service interface (#50196).
|
||||||
|
|
|
@ -600,7 +600,7 @@ typedef ptrdiff_t FT_PtrDist;
|
||||||
TPos x2,
|
TPos x2,
|
||||||
TCoord y2 )
|
TCoord y2 )
|
||||||
{
|
{
|
||||||
TCoord ex1, ex2, fx1, fx2, first, delta, mod;
|
TCoord ex1, ex2, fx1, fx2, first, dy, delta, mod;
|
||||||
TPos p, dx;
|
TPos p, dx;
|
||||||
int incr;
|
int incr;
|
||||||
|
|
||||||
|
@ -617,31 +617,27 @@ typedef ptrdiff_t FT_PtrDist;
|
||||||
|
|
||||||
fx1 = (TCoord)( x1 - SUBPIXELS( ex1 ) );
|
fx1 = (TCoord)( x1 - SUBPIXELS( ex1 ) );
|
||||||
fx2 = (TCoord)( x2 - SUBPIXELS( ex2 ) );
|
fx2 = (TCoord)( x2 - SUBPIXELS( ex2 ) );
|
||||||
delta = y2 - y1;
|
|
||||||
|
|
||||||
/* everything is located in a single cell. That is easy! */
|
/* everything is located in a single cell. That is easy! */
|
||||||
/* */
|
/* */
|
||||||
if ( ex1 == ex2 )
|
if ( ex1 == ex2 )
|
||||||
{
|
goto End;
|
||||||
ras.area += (TArea)(( fx1 + fx2 ) * delta);
|
|
||||||
ras.cover += delta;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ok, we'll have to render a run of adjacent cells on the same */
|
/* ok, we'll have to render a run of adjacent cells on the same */
|
||||||
/* scanline... */
|
/* scanline... */
|
||||||
/* */
|
/* */
|
||||||
dx = x2 - x1;
|
dx = x2 - x1;
|
||||||
|
dy = y2 - y1;
|
||||||
|
|
||||||
if ( dx > 0 )
|
if ( dx > 0 )
|
||||||
{
|
{
|
||||||
p = ( ONE_PIXEL - fx1 ) * delta;
|
p = ( ONE_PIXEL - fx1 ) * dy;
|
||||||
first = ONE_PIXEL;
|
first = ONE_PIXEL;
|
||||||
incr = 1;
|
incr = 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
p = fx1 * delta;
|
p = fx1 * dy;
|
||||||
first = 0;
|
first = 0;
|
||||||
incr = -1;
|
incr = -1;
|
||||||
dx = -dx;
|
dx = -dx;
|
||||||
|
@ -649,34 +645,31 @@ typedef ptrdiff_t FT_PtrDist;
|
||||||
|
|
||||||
FT_DIV_MOD( TCoord, p, dx, delta, mod );
|
FT_DIV_MOD( TCoord, p, dx, delta, mod );
|
||||||
|
|
||||||
ras.area += (TArea)(( fx1 + first ) * delta);
|
ras.area += (TArea)( ( fx1 + first ) * delta );
|
||||||
ras.cover += delta;
|
ras.cover += delta;
|
||||||
|
y1 += delta;
|
||||||
ex1 += incr;
|
ex1 += incr;
|
||||||
gray_set_cell( RAS_VAR_ ex1, ey );
|
gray_set_cell( RAS_VAR_ ex1, ey );
|
||||||
y1 += delta;
|
|
||||||
|
|
||||||
if ( ex1 != ex2 )
|
if ( ex1 != ex2 )
|
||||||
{
|
{
|
||||||
TCoord lift, rem;
|
TCoord lift, rem;
|
||||||
|
|
||||||
|
|
||||||
p = ONE_PIXEL * ( y2 - y1 + delta );
|
p = ONE_PIXEL * dy;
|
||||||
FT_DIV_MOD( TCoord, p, dx, lift, rem );
|
FT_DIV_MOD( TCoord, p, dx, lift, rem );
|
||||||
|
|
||||||
mod -= (int)dx;
|
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
delta = lift;
|
delta = lift;
|
||||||
mod += rem;
|
mod += rem;
|
||||||
if ( mod >= 0 )
|
if ( mod >= (TCoord)dx )
|
||||||
{
|
{
|
||||||
mod -= (TCoord)dx;
|
mod -= (TCoord)dx;
|
||||||
delta++;
|
delta++;
|
||||||
}
|
}
|
||||||
|
|
||||||
ras.area += (TArea)(ONE_PIXEL * delta);
|
ras.area += (TArea)( ONE_PIXEL * delta );
|
||||||
ras.cover += delta;
|
ras.cover += delta;
|
||||||
y1 += delta;
|
y1 += delta;
|
||||||
ex1 += incr;
|
ex1 += incr;
|
||||||
|
@ -684,9 +677,13 @@ typedef ptrdiff_t FT_PtrDist;
|
||||||
} while ( ex1 != ex2 );
|
} while ( ex1 != ex2 );
|
||||||
}
|
}
|
||||||
|
|
||||||
delta = y2 - y1;
|
fx1 = ONE_PIXEL - first;
|
||||||
ras.area += (TArea)(( fx2 + ONE_PIXEL - first ) * delta);
|
|
||||||
ras.cover += delta;
|
End:
|
||||||
|
dy = y2 - y1;
|
||||||
|
|
||||||
|
ras.area += (TArea)( ( fx1 + fx2 ) * dy );
|
||||||
|
ras.cover += dy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -798,13 +795,12 @@ typedef ptrdiff_t FT_PtrDist;
|
||||||
|
|
||||||
p = ONE_PIXEL * dx;
|
p = ONE_PIXEL * dx;
|
||||||
FT_DIV_MOD( TCoord, p, dy, lift, rem );
|
FT_DIV_MOD( TCoord, p, dy, lift, rem );
|
||||||
mod -= (TCoord)dy;
|
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
delta = lift;
|
delta = lift;
|
||||||
mod += rem;
|
mod += rem;
|
||||||
if ( mod >= 0 )
|
if ( mod >= (TCoord)dy )
|
||||||
{
|
{
|
||||||
mod -= (TCoord)dy;
|
mod -= (TCoord)dy;
|
||||||
delta++;
|
delta++;
|
||||||
|
|
Loading…
Reference in New Issue