FT_EXPORT( FT_Long )
FT_MulDiv( FT_Long a,
FT_Long b,
FT_Long c );
A very simple function used to perform the
computation `(a*b)/c' with maximal accuracy (it
uses a 64-bit intermediate integer whenever
necessary).
This function isn't necessarily as fast as some
processor specific operations, but is at least
completely portable.
input
a
The first multiplier.
b
The second multiplier.
c
The divisor.
return
The result of `(a*b)/c'. This function never
traps when trying to divide by zero; it simply
returns `MaxInt' or `MinInt' depending on the
signs of `a' and `b'.
FT_EXPORT( FT_Long )
FT_MulFix( FT_Long a,
FT_Long b );
A very simple function used to perform the
computation `(a*b)/0x10000' with maximal
accuracy. Most of the time this is used to
multiply a given value by a 16.16 fixed float
factor.
input
a
The first multiplier.
b
The second multiplier. Use a 16.16 factor here
whenever possible (see note below).
return
The result of `(a*b)/0x10000'.
note
This function has been optimized for the case
where the absolute value of `a' is less than
2048, and `b' is a 16.16 scaling factor. As this
happens mainly when scaling from notional units
to fractional pixels in FreeType, it resulted in
noticeable speed improvements between versions
2.x and 1.x.
As a conclusion, always try to place a 16.16
factor as the _second_ argument of this function;
this can make a great difference.
FT_EXPORT( FT_Long )
FT_DivFix( FT_Long a,
FT_Long b );
A very simple function used to perform the
computation `(a*0x10000)/b' with maximal
accuracy. Most of the time, this is used to
divide a given value by a 16.16 fixed float
factor.
input
a
The first multiplier.
b
The second multiplier. Use a 16.16 factor here
whenever possible (see note below).
return
The result of `(a*0x10000)/b'.
note
The optimization for FT_DivFix() is simple: If (a
<< 16) fits in 32 bits, then the division is
computed directly. Otherwise, we use a
specialized version of the old FT_MulDiv64().
Return the unit vector corresponding to a given
angle. After the call, the value of `vec.x' will
be `sin(angle)', and the value of `vec.y' will be
`cos(angle)'.
This function is useful to retrieve both the
sinus and cosinus of a given angle quickly.