1 /***************************************************************************/
5 /* Arithmetic computations (specification). */
7 /* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006 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 #ifdef FT_CONFIG_OPTION_OLD_INTERNALS
53 /*************************************************************************/
59 /* Computes the square root of an Int32 integer (which will be */
60 /* handled as an unsigned long value). */
63 /* x :: The value to compute the root for. */
66 /* The result of `sqrt(x)'. */
69 FT_Sqrt32( FT_Int32 x
);
71 #endif /* FT_CONFIG_OPTION_OLD_INTERNALS */
74 /*************************************************************************/
76 /* FT_MulDiv() and FT_MulFix() are declared in freetype.h. */
78 /*************************************************************************/
81 #ifdef TT_USE_BYTECODE_INTERPRETER
83 /*************************************************************************/
86 /* FT_MulDiv_No_Round */
89 /* A very simple function used to perform the computation `(a*b)/c' */
90 /* (without rounding) with maximal accuracy (it uses a 64-bit */
91 /* intermediate integer whenever necessary). */
93 /* This function isn't necessarily as fast as some processor specific */
94 /* operations, but is at least completely portable. */
97 /* a :: The first multiplier. */
98 /* b :: The second multiplier. */
99 /* c :: The divisor. */
102 /* The result of `(a*b)/c'. This function never traps when trying to */
103 /* divide by zero; it simply returns `MaxInt' or `MinInt' depending */
104 /* on the signs of `a' and `b'. */
107 FT_MulDiv_No_Round( FT_Long a
,
111 #endif /* TT_USE_BYTECODE_INTERPRETER */
115 * Return -1, 0, or +1, depending on the orientation of a given corner.
116 * We use the Cartesian coordinate system, with positive vertical values
117 * going upwards. The function returns +1 if the corner turns to the
118 * left, -1 to the right, and 0 for undecidable cases.
121 ft_corner_orientation( FT_Pos in_x
,
127 * Return TRUE if a corner is flat or nearly flat. This is equivalent to
128 * saying that the angle difference between the `in' and `out' vectors is
132 ft_corner_is_flat( FT_Pos in_x
,
138 #define INT_TO_F26DOT6( x ) ( (FT_Long)(x) << 6 )
139 #define INT_TO_F2DOT14( x ) ( (FT_Long)(x) << 14 )
140 #define INT_TO_FIXED( x ) ( (FT_Long)(x) << 16 )
141 #define F2DOT14_TO_FIXED( x ) ( (FT_Long)(x) << 2 )
142 #define FLOAT_TO_FIXED( x ) ( (FT_Long)( x * 65536.0 ) )
144 #define ROUND_F26DOT6( x ) ( x >= 0 ? ( ( (x) + 32 ) & -64 ) \
145 : ( -( ( 32 - (x) ) & -64 ) ) )
150 #endif /* __FTCALC_H__ */