- added a new function called FT_SqrtFixed to compute the

16.16 square root of a 16.16 number (this could come handy
  in a later version of the auto-hinter)

- small fixes to the smooth renderer. It used to use way too
  much line segments when drawing beziers !!
This commit is contained in:
David Turner 2000-09-02 00:20:42 +00:00
parent 21a27ee3cb
commit a8194a97db
4 changed files with 35 additions and 24 deletions

View File

@ -34,9 +34,7 @@
#define ADD_64( x, y, z ) z = (x) + (y) #define ADD_64( x, y, z ) z = (x) + (y)
#define MUL_64( x, y, z ) z = (FT_Int64)(x) * (y) #define MUL_64( x, y, z ) z = (FT_Int64)(x) * (y)
#define DIV_64( x, y ) ((x)/(y))
#define DIV_64( x, y ) ( (x) / (y) )
#ifdef FT_CONFIG_OPTION_OLD_CALCS #ifdef FT_CONFIG_OPTION_OLD_CALCS
@ -62,7 +60,6 @@
#define MUL_64( x, y, z ) FT_MulTo64( x, y, &z ) #define MUL_64( x, y, z ) FT_MulTo64( x, y, &z )
#define DIV_64( x, y ) FT_Div64by32( &x, y ) #define DIV_64( x, y ) FT_Div64by32( &x, y )
FT_EXPORT_DEF( void ) FT_Add64( FT_Int64* x, FT_EXPORT_DEF( void ) FT_Add64( FT_Int64* x,
FT_Int64* y, FT_Int64* y,
FT_Int64* z ); FT_Int64* z );
@ -77,6 +74,8 @@
#ifdef FT_CONFIG_OPTION_OLD_CALCS #ifdef FT_CONFIG_OPTION_OLD_CALCS
FT_EXPORT_DEF(FT_Int32) FT_SqrtFixed( FT_Int32 x );
#define SQRT_64( z ) FT_Sqrt64( &z ) #define SQRT_64( z ) FT_Sqrt64( &z )
FT_EXPORT_DEF( FT_Int32 ) FT_Sqrt64( FT_Int64* x ); FT_EXPORT_DEF( FT_Int32 ) FT_Sqrt64( FT_Int64* x );

View File

@ -295,6 +295,15 @@
return r; return r;
} }
FT_EXPORT_DEF(FT_Int32) FT_SqrtFixed( FT_Int32 x )
{
FT_Int64 z;
z = (FT_Int64)(x) << 16;
return FT_Sqrt64( z );
}
#endif /* FT_CONFIG_OPTION_OLD_CALCS */ #endif /* FT_CONFIG_OPTION_OLD_CALCS */
@ -488,21 +497,14 @@
else else
{ {
/* we need more bits; we have to do it by hand */ /* we need more bits; we have to do it by hand */
FT_UInt32 c; FT_Int64 temp, temp2;
temp.hi = (FT_Int32) (a >> 16);
q = ( a / b ) << 16; temp.lo = (FT_UInt32)(a << 16);
c = a % b; temp2.hi = (FT_Int32)( b >> 31 );
temp2.lo = (FT_UInt32)( b / 2 );
/* we must compute C*0x10000/B: we simply shift C and B so */ FT_Add64( &temp, &temp2, &temp );
/* C becomes smaller than 16 bits */ q = FT_Div64by32( &temp, b );
while ( c >> 16 )
{
c >>= 1;
b <<= 1;
}
q += ( c << 16 ) / b;
} }
return ( s < 0 ? -(FT_Int32)q : (FT_Int32)q ); return ( s < 0 ? -(FT_Int32)q : (FT_Int32)q );
@ -765,6 +767,16 @@
return r; return r;
} }
FT_EXPORT_DEF(FT_Int32) FT_SqrtFixed( FT_Int32 x )
{
FT_Int64 z;
z.hi = (FT_UInt32)((FT_Int32)(x) >> 16);
z.lo = (FT_UInt32)( x << 16 );
return FT_Sqrt64( &z );
}
#endif /* FT_CONFIG_OPTION_OLD_CALCS */ #endif /* FT_CONFIG_OPTION_OLD_CALCS */
#endif /* FT_LONG64 */ #endif /* FT_LONG64 */

View File

@ -726,7 +726,7 @@
dx = dx / ras.conic_level; dx = dx / ras.conic_level;
while ( dx > 0 ) while ( dx > 0 )
{ {
dx >>= 1; dx >>= 2;
level++; level++;
} }
@ -874,8 +874,8 @@
db = db / ras.conic_level; db = db / ras.conic_level;
while ( da > 0 || db > 0 ) while ( da > 0 || db > 0 )
{ {
da >>= 1; da >>= 2;
db >>= 2; db >>= 3;
level++; level++;
} }
@ -1740,7 +1740,7 @@
if ( ras.max_ex > 24 || ras.max_ey > 24 ) if ( ras.max_ex > 24 || ras.max_ey > 24 )
level++; level++;
if ( ras.max_ex > 120 || ras.max_ey > 120 ) if ( ras.max_ex > 120 || ras.max_ey > 120 )
level += 2; level ++;
ras.conic_level <<= level; ras.conic_level <<= level;
ras.cubic_level <<= level; ras.cubic_level <<= level;