nuclear@0: /***************************************************************************/ nuclear@0: /* */ nuclear@0: /* ftcalc.h */ nuclear@0: /* */ nuclear@0: /* Arithmetic computations (specification). */ nuclear@0: /* */ nuclear@0: /* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2008, 2009 by */ nuclear@0: /* David Turner, Robert Wilhelm, and Werner Lemberg. */ nuclear@0: /* */ nuclear@0: /* This file is part of the FreeType project, and may only be used, */ nuclear@0: /* modified, and distributed under the terms of the FreeType project */ nuclear@0: /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ nuclear@0: /* this file you indicate that you have read the license and */ nuclear@0: /* understand and accept it fully. */ nuclear@0: /* */ nuclear@0: /***************************************************************************/ nuclear@0: nuclear@0: nuclear@0: #ifndef __FTCALC_H__ nuclear@0: #define __FTCALC_H__ nuclear@0: nuclear@0: nuclear@0: #include nuclear@0: #include FT_FREETYPE_H nuclear@0: nuclear@0: nuclear@0: FT_BEGIN_HEADER nuclear@0: nuclear@0: nuclear@0: /*************************************************************************/ nuclear@0: /* */ nuclear@0: /* */ nuclear@0: /* FT_FixedSqrt */ nuclear@0: /* */ nuclear@0: /* */ nuclear@0: /* Computes the square root of a 16.16 fixed point value. */ nuclear@0: /* */ nuclear@0: /* */ nuclear@0: /* x :: The value to compute the root for. */ nuclear@0: /* */ nuclear@0: /* */ nuclear@0: /* The result of `sqrt(x)'. */ nuclear@0: /* */ nuclear@0: /* */ nuclear@0: /* This function is not very fast. */ nuclear@0: /* */ nuclear@0: FT_BASE( FT_Int32 ) nuclear@0: FT_SqrtFixed( FT_Int32 x ); nuclear@0: nuclear@0: nuclear@0: #ifdef FT_CONFIG_OPTION_OLD_INTERNALS nuclear@0: nuclear@0: /*************************************************************************/ nuclear@0: /* */ nuclear@0: /* */ nuclear@0: /* FT_Sqrt32 */ nuclear@0: /* */ nuclear@0: /* */ nuclear@0: /* Computes the square root of an Int32 integer (which will be */ nuclear@0: /* handled as an unsigned long value). */ nuclear@0: /* */ nuclear@0: /* */ nuclear@0: /* x :: The value to compute the root for. */ nuclear@0: /* */ nuclear@0: /* */ nuclear@0: /* The result of `sqrt(x)'. */ nuclear@0: /* */ nuclear@0: FT_EXPORT( FT_Int32 ) nuclear@0: FT_Sqrt32( FT_Int32 x ); nuclear@0: nuclear@0: #endif /* FT_CONFIG_OPTION_OLD_INTERNALS */ nuclear@0: nuclear@0: nuclear@0: /*************************************************************************/ nuclear@0: /* */ nuclear@0: /* FT_MulDiv() and FT_MulFix() are declared in freetype.h. */ nuclear@0: /* */ nuclear@0: /*************************************************************************/ nuclear@0: nuclear@0: nuclear@0: #ifdef TT_USE_BYTECODE_INTERPRETER nuclear@0: nuclear@0: /*************************************************************************/ nuclear@0: /* */ nuclear@0: /* */ nuclear@0: /* FT_MulDiv_No_Round */ nuclear@0: /* */ nuclear@0: /* */ nuclear@0: /* A very simple function used to perform the computation `(a*b)/c' */ nuclear@0: /* (without rounding) with maximal accuracy (it uses a 64-bit */ nuclear@0: /* intermediate integer whenever necessary). */ nuclear@0: /* */ nuclear@0: /* This function isn't necessarily as fast as some processor specific */ nuclear@0: /* operations, but is at least completely portable. */ nuclear@0: /* */ nuclear@0: /* */ nuclear@0: /* a :: The first multiplier. */ nuclear@0: /* b :: The second multiplier. */ nuclear@0: /* c :: The divisor. */ nuclear@0: /* */ nuclear@0: /* */ nuclear@0: /* The result of `(a*b)/c'. This function never traps when trying to */ nuclear@0: /* divide by zero; it simply returns `MaxInt' or `MinInt' depending */ nuclear@0: /* on the signs of `a' and `b'. */ nuclear@0: /* */ nuclear@0: FT_BASE( FT_Long ) nuclear@0: FT_MulDiv_No_Round( FT_Long a, nuclear@0: FT_Long b, nuclear@0: FT_Long c ); nuclear@0: nuclear@0: #endif /* TT_USE_BYTECODE_INTERPRETER */ nuclear@0: nuclear@0: nuclear@0: /* nuclear@0: * A variant of FT_Matrix_Multiply which scales its result afterwards. nuclear@0: * The idea is that both `a' and `b' are scaled by factors of 10 so that nuclear@0: * the values are as precise as possible to get a correct result during nuclear@0: * the 64bit multiplication. Let `sa' and `sb' be the scaling factors of nuclear@0: * `a' and `b', respectively, then the scaling factor of the result is nuclear@0: * `sa*sb'. nuclear@0: */ nuclear@0: FT_BASE( void ) nuclear@0: FT_Matrix_Multiply_Scaled( const FT_Matrix* a, nuclear@0: FT_Matrix *b, nuclear@0: FT_Long scaling ); nuclear@0: nuclear@0: nuclear@0: /* nuclear@0: * A variant of FT_Vector_Transform. See comments for nuclear@0: * FT_Matrix_Multiply_Scaled. nuclear@0: */ nuclear@0: nuclear@0: FT_BASE( void ) nuclear@0: FT_Vector_Transform_Scaled( FT_Vector* vector, nuclear@0: const FT_Matrix* matrix, nuclear@0: FT_Long scaling ); nuclear@0: nuclear@0: nuclear@0: /* nuclear@0: * Return -1, 0, or +1, depending on the orientation of a given corner. nuclear@0: * We use the Cartesian coordinate system, with positive vertical values nuclear@0: * going upwards. The function returns +1 if the corner turns to the nuclear@0: * left, -1 to the right, and 0 for undecidable cases. nuclear@0: */ nuclear@0: FT_BASE( FT_Int ) nuclear@0: ft_corner_orientation( FT_Pos in_x, nuclear@0: FT_Pos in_y, nuclear@0: FT_Pos out_x, nuclear@0: FT_Pos out_y ); nuclear@0: nuclear@0: /* nuclear@0: * Return TRUE if a corner is flat or nearly flat. This is equivalent to nuclear@0: * saying that the angle difference between the `in' and `out' vectors is nuclear@0: * very small. nuclear@0: */ nuclear@0: FT_BASE( FT_Int ) nuclear@0: ft_corner_is_flat( FT_Pos in_x, nuclear@0: FT_Pos in_y, nuclear@0: FT_Pos out_x, nuclear@0: FT_Pos out_y ); nuclear@0: nuclear@0: nuclear@0: #define INT_TO_F26DOT6( x ) ( (FT_Long)(x) << 6 ) nuclear@0: #define INT_TO_F2DOT14( x ) ( (FT_Long)(x) << 14 ) nuclear@0: #define INT_TO_FIXED( x ) ( (FT_Long)(x) << 16 ) nuclear@0: #define F2DOT14_TO_FIXED( x ) ( (FT_Long)(x) << 2 ) nuclear@0: #define FLOAT_TO_FIXED( x ) ( (FT_Long)( x * 65536.0 ) ) nuclear@0: #define FIXED_TO_INT( x ) ( FT_RoundFix( x ) >> 16 ) nuclear@0: nuclear@0: #define ROUND_F26DOT6( x ) ( x >= 0 ? ( ( (x) + 32 ) & -64 ) \ nuclear@0: : ( -( ( 32 - (x) ) & -64 ) ) ) nuclear@0: nuclear@0: nuclear@0: FT_END_HEADER nuclear@0: nuclear@0: #endif /* __FTCALC_H__ */ nuclear@0: nuclear@0: nuclear@0: /* END */