1 /***************************************************************************/
5 /* Arithmetic computations (specification). */
7 /* Copyright 1996-2001, 2002, 2003, 2004 by */
8 /* David Turner, Robert Wilhelm, and Werner Lemberg. */
10 /* This file is part of the FreeType project, and may only be used, */
11 /* modified, and distributed under the terms of the FreeType project */
12 /* license, LICENSE.TXT. By continuing to use, modify, or distribute */
13 /* this file you indicate that you have read the license and */
14 /* understand and accept it fully. */
16 /***************************************************************************/
24 #include FT_FREETYPE_H
30 /*************************************************************************/
36 /* Computes the square root of a 16.16 fixed point value. */
39 /* x :: The value to compute the root for. */
42 /* The result of `sqrt(x)'. */
45 /* This function is not very fast. */
48 FT_SqrtFixed( FT_Int32 x );
51 #define SQRT_32( x ) FT_Sqrt32( x )
54 /*************************************************************************/
60 /* Computes the square root of an Int32 integer (which will be */
61 /* handled as an unsigned long value). */
64 /* x :: The value to compute the root for. */
67 /* The result of `sqrt(x)'. */
70 FT_Sqrt32( FT_Int32 x );
73 /*************************************************************************/
75 /* FT_MulDiv() and FT_MulFix() are declared in freetype.h. */
77 /*************************************************************************/
80 #ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
82 /*************************************************************************/
85 /* FT_MulDiv_No_Round */
88 /* A very simple function used to perform the computation `(a*b)/c' */
89 /* (without rounding) with maximal accuracy (it uses a 64-bit */
90 /* intermediate integer whenever necessary). */
92 /* This function isn't necessarily as fast as some processor specific */
93 /* operations, but is at least completely portable. */
96 /* a :: The first multiplier. */
97 /* b :: The second multiplier. */
98 /* c :: The divisor. */
101 /* The result of `(a*b)/c'. This function never traps when trying to */
102 /* divide by zero; it simply returns `MaxInt' or `MinInt' depending */
103 /* on the signs of `a' and `b'. */
106 FT_MulDiv_No_Round( FT_Long a,
110 #endif /* TT_CONFIG_OPTION_BYTECODE_INTERPRETER */
113 #define INT_TO_F26DOT6( x ) ( (FT_Long)(x) << 6 )
114 #define INT_TO_F2DOT14( x ) ( (FT_Long)(x) << 14 )
115 #define INT_TO_FIXED( x ) ( (FT_Long)(x) << 16 )
116 #define F2DOT14_TO_FIXED( x ) ( (FT_Long)(x) << 2 )
117 #define FLOAT_TO_FIXED( x ) ( (FT_Long)( x * 65536.0 ) )
119 #define ROUND_F26DOT6( x ) ( x >= 0 ? ( ( (x) + 32 ) & -64 ) \
120 : ( -( ( 32 - (x) ) & -64 ) ) )
125 #endif /* __FTCALC_H__ */