vrshoot

annotate libs/ft2static/freetype/internal/ftcalc.h @ 0:b2f14e535253

initial commit
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 01 Feb 2014 19:58:19 +0200
parents
children
rev   line source
nuclear@0 1 /***************************************************************************/
nuclear@0 2 /* */
nuclear@0 3 /* ftcalc.h */
nuclear@0 4 /* */
nuclear@0 5 /* Arithmetic computations (specification). */
nuclear@0 6 /* */
nuclear@0 7 /* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2008, 2009 by */
nuclear@0 8 /* David Turner, Robert Wilhelm, and Werner Lemberg. */
nuclear@0 9 /* */
nuclear@0 10 /* This file is part of the FreeType project, and may only be used, */
nuclear@0 11 /* modified, and distributed under the terms of the FreeType project */
nuclear@0 12 /* license, LICENSE.TXT. By continuing to use, modify, or distribute */
nuclear@0 13 /* this file you indicate that you have read the license and */
nuclear@0 14 /* understand and accept it fully. */
nuclear@0 15 /* */
nuclear@0 16 /***************************************************************************/
nuclear@0 17
nuclear@0 18
nuclear@0 19 #ifndef __FTCALC_H__
nuclear@0 20 #define __FTCALC_H__
nuclear@0 21
nuclear@0 22
nuclear@0 23 #include <ft2build.h>
nuclear@0 24 #include FT_FREETYPE_H
nuclear@0 25
nuclear@0 26
nuclear@0 27 FT_BEGIN_HEADER
nuclear@0 28
nuclear@0 29
nuclear@0 30 /*************************************************************************/
nuclear@0 31 /* */
nuclear@0 32 /* <Function> */
nuclear@0 33 /* FT_FixedSqrt */
nuclear@0 34 /* */
nuclear@0 35 /* <Description> */
nuclear@0 36 /* Computes the square root of a 16.16 fixed point value. */
nuclear@0 37 /* */
nuclear@0 38 /* <Input> */
nuclear@0 39 /* x :: The value to compute the root for. */
nuclear@0 40 /* */
nuclear@0 41 /* <Return> */
nuclear@0 42 /* The result of `sqrt(x)'. */
nuclear@0 43 /* */
nuclear@0 44 /* <Note> */
nuclear@0 45 /* This function is not very fast. */
nuclear@0 46 /* */
nuclear@0 47 FT_BASE( FT_Int32 )
nuclear@0 48 FT_SqrtFixed( FT_Int32 x );
nuclear@0 49
nuclear@0 50
nuclear@0 51 #ifdef FT_CONFIG_OPTION_OLD_INTERNALS
nuclear@0 52
nuclear@0 53 /*************************************************************************/
nuclear@0 54 /* */
nuclear@0 55 /* <Function> */
nuclear@0 56 /* FT_Sqrt32 */
nuclear@0 57 /* */
nuclear@0 58 /* <Description> */
nuclear@0 59 /* Computes the square root of an Int32 integer (which will be */
nuclear@0 60 /* handled as an unsigned long value). */
nuclear@0 61 /* */
nuclear@0 62 /* <Input> */
nuclear@0 63 /* x :: The value to compute the root for. */
nuclear@0 64 /* */
nuclear@0 65 /* <Return> */
nuclear@0 66 /* The result of `sqrt(x)'. */
nuclear@0 67 /* */
nuclear@0 68 FT_EXPORT( FT_Int32 )
nuclear@0 69 FT_Sqrt32( FT_Int32 x );
nuclear@0 70
nuclear@0 71 #endif /* FT_CONFIG_OPTION_OLD_INTERNALS */
nuclear@0 72
nuclear@0 73
nuclear@0 74 /*************************************************************************/
nuclear@0 75 /* */
nuclear@0 76 /* FT_MulDiv() and FT_MulFix() are declared in freetype.h. */
nuclear@0 77 /* */
nuclear@0 78 /*************************************************************************/
nuclear@0 79
nuclear@0 80
nuclear@0 81 #ifdef TT_USE_BYTECODE_INTERPRETER
nuclear@0 82
nuclear@0 83 /*************************************************************************/
nuclear@0 84 /* */
nuclear@0 85 /* <Function> */
nuclear@0 86 /* FT_MulDiv_No_Round */
nuclear@0 87 /* */
nuclear@0 88 /* <Description> */
nuclear@0 89 /* A very simple function used to perform the computation `(a*b)/c' */
nuclear@0 90 /* (without rounding) with maximal accuracy (it uses a 64-bit */
nuclear@0 91 /* intermediate integer whenever necessary). */
nuclear@0 92 /* */
nuclear@0 93 /* This function isn't necessarily as fast as some processor specific */
nuclear@0 94 /* operations, but is at least completely portable. */
nuclear@0 95 /* */
nuclear@0 96 /* <Input> */
nuclear@0 97 /* a :: The first multiplier. */
nuclear@0 98 /* b :: The second multiplier. */
nuclear@0 99 /* c :: The divisor. */
nuclear@0 100 /* */
nuclear@0 101 /* <Return> */
nuclear@0 102 /* The result of `(a*b)/c'. This function never traps when trying to */
nuclear@0 103 /* divide by zero; it simply returns `MaxInt' or `MinInt' depending */
nuclear@0 104 /* on the signs of `a' and `b'. */
nuclear@0 105 /* */
nuclear@0 106 FT_BASE( FT_Long )
nuclear@0 107 FT_MulDiv_No_Round( FT_Long a,
nuclear@0 108 FT_Long b,
nuclear@0 109 FT_Long c );
nuclear@0 110
nuclear@0 111 #endif /* TT_USE_BYTECODE_INTERPRETER */
nuclear@0 112
nuclear@0 113
nuclear@0 114 /*
nuclear@0 115 * A variant of FT_Matrix_Multiply which scales its result afterwards.
nuclear@0 116 * The idea is that both `a' and `b' are scaled by factors of 10 so that
nuclear@0 117 * the values are as precise as possible to get a correct result during
nuclear@0 118 * the 64bit multiplication. Let `sa' and `sb' be the scaling factors of
nuclear@0 119 * `a' and `b', respectively, then the scaling factor of the result is
nuclear@0 120 * `sa*sb'.
nuclear@0 121 */
nuclear@0 122 FT_BASE( void )
nuclear@0 123 FT_Matrix_Multiply_Scaled( const FT_Matrix* a,
nuclear@0 124 FT_Matrix *b,
nuclear@0 125 FT_Long scaling );
nuclear@0 126
nuclear@0 127
nuclear@0 128 /*
nuclear@0 129 * A variant of FT_Vector_Transform. See comments for
nuclear@0 130 * FT_Matrix_Multiply_Scaled.
nuclear@0 131 */
nuclear@0 132
nuclear@0 133 FT_BASE( void )
nuclear@0 134 FT_Vector_Transform_Scaled( FT_Vector* vector,
nuclear@0 135 const FT_Matrix* matrix,
nuclear@0 136 FT_Long scaling );
nuclear@0 137
nuclear@0 138
nuclear@0 139 /*
nuclear@0 140 * Return -1, 0, or +1, depending on the orientation of a given corner.
nuclear@0 141 * We use the Cartesian coordinate system, with positive vertical values
nuclear@0 142 * going upwards. The function returns +1 if the corner turns to the
nuclear@0 143 * left, -1 to the right, and 0 for undecidable cases.
nuclear@0 144 */
nuclear@0 145 FT_BASE( FT_Int )
nuclear@0 146 ft_corner_orientation( FT_Pos in_x,
nuclear@0 147 FT_Pos in_y,
nuclear@0 148 FT_Pos out_x,
nuclear@0 149 FT_Pos out_y );
nuclear@0 150
nuclear@0 151 /*
nuclear@0 152 * Return TRUE if a corner is flat or nearly flat. This is equivalent to
nuclear@0 153 * saying that the angle difference between the `in' and `out' vectors is
nuclear@0 154 * very small.
nuclear@0 155 */
nuclear@0 156 FT_BASE( FT_Int )
nuclear@0 157 ft_corner_is_flat( FT_Pos in_x,
nuclear@0 158 FT_Pos in_y,
nuclear@0 159 FT_Pos out_x,
nuclear@0 160 FT_Pos out_y );
nuclear@0 161
nuclear@0 162
nuclear@0 163 #define INT_TO_F26DOT6( x ) ( (FT_Long)(x) << 6 )
nuclear@0 164 #define INT_TO_F2DOT14( x ) ( (FT_Long)(x) << 14 )
nuclear@0 165 #define INT_TO_FIXED( x ) ( (FT_Long)(x) << 16 )
nuclear@0 166 #define F2DOT14_TO_FIXED( x ) ( (FT_Long)(x) << 2 )
nuclear@0 167 #define FLOAT_TO_FIXED( x ) ( (FT_Long)( x * 65536.0 ) )
nuclear@0 168 #define FIXED_TO_INT( x ) ( FT_RoundFix( x ) >> 16 )
nuclear@0 169
nuclear@0 170 #define ROUND_F26DOT6( x ) ( x >= 0 ? ( ( (x) + 32 ) & -64 ) \
nuclear@0 171 : ( -( ( 32 - (x) ) & -64 ) ) )
nuclear@0 172
nuclear@0 173
nuclear@0 174 FT_END_HEADER
nuclear@0 175
nuclear@0 176 #endif /* __FTCALC_H__ */
nuclear@0 177
nuclear@0 178
nuclear@0 179 /* END */