ftcalc.h

Go to the documentation of this file.
00001 /***************************************************************************/
00002 /*                                                                         */
00003 /*  ftcalc.h                                                               */
00004 /*                                                                         */
00005 /*    Arithmetic computations (specification).                             */
00006 /*                                                                         */
00007 /*  Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2008, 2009 by       */
00008 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
00009 /*                                                                         */
00010 /*  This file is part of the FreeType project, and may only be used,       */
00011 /*  modified, and distributed under the terms of the FreeType project      */
00012 /*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
00013 /*  this file you indicate that you have read the license and              */
00014 /*  understand and accept it fully.                                        */
00015 /*                                                                         */
00016 /***************************************************************************/
00017 
00018 
00019 #ifndef __FTCALC_H__
00020 #define __FTCALC_H__
00021 
00022 
00023 #include <ft2build.h>
00024 #include FT_FREETYPE_H
00025 
00026 
00027 FT_BEGIN_HEADER
00028 
00029 
00030   /*************************************************************************/
00031   /*                                                                       */
00032   /* <Function>                                                            */
00033   /*    FT_FixedSqrt                                                       */
00034   /*                                                                       */
00035   /* <Description>                                                         */
00036   /*    Computes the square root of a 16.16 fixed point value.             */
00037   /*                                                                       */
00038   /* <Input>                                                               */
00039   /*    x :: The value to compute the root for.                            */
00040   /*                                                                       */
00041   /* <Return>                                                              */
00042   /*    The result of `sqrt(x)'.                                           */
00043   /*                                                                       */
00044   /* <Note>                                                                */
00045   /*    This function is not very fast.                                    */
00046   /*                                                                       */
00047   FT_BASE( FT_Int32 )
00048   FT_SqrtFixed( FT_Int32  x );
00049 
00050 
00051 #ifdef FT_CONFIG_OPTION_OLD_INTERNALS
00052 
00053   /*************************************************************************/
00054   /*                                                                       */
00055   /* <Function>                                                            */
00056   /*    FT_Sqrt32                                                          */
00057   /*                                                                       */
00058   /* <Description>                                                         */
00059   /*    Computes the square root of an Int32 integer (which will be        */
00060   /*    handled as an unsigned long value).                                */
00061   /*                                                                       */
00062   /* <Input>                                                               */
00063   /*    x :: The value to compute the root for.                            */
00064   /*                                                                       */
00065   /* <Return>                                                              */
00066   /*    The result of `sqrt(x)'.                                           */
00067   /*                                                                       */
00068   FT_EXPORT( FT_Int32 )
00069   FT_Sqrt32( FT_Int32  x );
00070 
00071 #endif /* FT_CONFIG_OPTION_OLD_INTERNALS */
00072 
00073 
00074   /*************************************************************************/
00075   /*                                                                       */
00076   /* FT_MulDiv() and FT_MulFix() are declared in freetype.h.               */
00077   /*                                                                       */
00078   /*************************************************************************/
00079 
00080 
00081 #ifdef TT_USE_BYTECODE_INTERPRETER
00082 
00083   /*************************************************************************/
00084   /*                                                                       */
00085   /* <Function>                                                            */
00086   /*    FT_MulDiv_No_Round                                                 */
00087   /*                                                                       */
00088   /* <Description>                                                         */
00089   /*    A very simple function used to perform the computation `(a*b)/c'   */
00090   /*    (without rounding) with maximal accuracy (it uses a 64-bit         */
00091   /*    intermediate integer whenever necessary).                          */
00092   /*                                                                       */
00093   /*    This function isn't necessarily as fast as some processor specific */
00094   /*    operations, but is at least completely portable.                   */
00095   /*                                                                       */
00096   /* <Input>                                                               */
00097   /*    a :: The first multiplier.                                         */
00098   /*    b :: The second multiplier.                                        */
00099   /*    c :: The divisor.                                                  */
00100   /*                                                                       */
00101   /* <Return>                                                              */
00102   /*    The result of `(a*b)/c'.  This function never traps when trying to */
00103   /*    divide by zero; it simply returns `MaxInt' or `MinInt' depending   */
00104   /*    on the signs of `a' and `b'.                                       */
00105   /*                                                                       */
00106   FT_BASE( FT_Long )
00107   FT_MulDiv_No_Round( FT_Long  a,
00108                       FT_Long  b,
00109                       FT_Long  c );
00110 
00111 #endif /* TT_USE_BYTECODE_INTERPRETER */
00112 
00113 
00114   /*
00115    *  A variant of FT_Matrix_Multiply which scales its result afterwards.
00116    *  The idea is that both `a' and `b' are scaled by factors of 10 so that
00117    *  the values are as precise as possible to get a correct result during
00118    *  the 64bit multiplication.  Let `sa' and `sb' be the scaling factors of
00119    *  `a' and `b', respectively, then the scaling factor of the result is
00120    *  `sa*sb'.
00121    */
00122   FT_BASE( void )
00123   FT_Matrix_Multiply_Scaled( const FT_Matrix*  a,
00124                              FT_Matrix        *b,
00125                              FT_Long           scaling );
00126 
00127 
00128   /*
00129    *  A variant of FT_Vector_Transform.  See comments for
00130    *  FT_Matrix_Multiply_Scaled.
00131    */
00132 
00133   FT_BASE( void )
00134   FT_Vector_Transform_Scaled( FT_Vector*        vector,
00135                               const FT_Matrix*  matrix,
00136                               FT_Long           scaling );
00137 
00138 
00139   /*
00140    *  Return -1, 0, or +1, depending on the orientation of a given corner.
00141    *  We use the Cartesian coordinate system, with positive vertical values
00142    *  going upwards.  The function returns +1 if the corner turns to the
00143    *  left, -1 to the right, and 0 for undecidable cases.
00144    */
00145   FT_BASE( FT_Int )
00146   ft_corner_orientation( FT_Pos  in_x,
00147                          FT_Pos  in_y,
00148                          FT_Pos  out_x,
00149                          FT_Pos  out_y );
00150 
00151   /*
00152    *  Return TRUE if a corner is flat or nearly flat.  This is equivalent to
00153    *  saying that the angle difference between the `in' and `out' vectors is
00154    *  very small.
00155    */
00156   FT_BASE( FT_Int )
00157   ft_corner_is_flat( FT_Pos  in_x,
00158                      FT_Pos  in_y,
00159                      FT_Pos  out_x,
00160                      FT_Pos  out_y );
00161 
00162 
00163 #define INT_TO_F26DOT6( x )    ( (FT_Long)(x) << 6  )
00164 #define INT_TO_F2DOT14( x )    ( (FT_Long)(x) << 14 )
00165 #define INT_TO_FIXED( x )      ( (FT_Long)(x) << 16 )
00166 #define F2DOT14_TO_FIXED( x )  ( (FT_Long)(x) << 2  )
00167 #define FLOAT_TO_FIXED( x )    ( (FT_Long)( x * 65536.0 ) )
00168 #define FIXED_TO_INT( x )      ( FT_RoundFix( x ) >> 16 )
00169 
00170 #define ROUND_F26DOT6( x )     ( x >= 0 ? (    ( (x) + 32 ) & -64 )     \
00171                                         : ( -( ( 32 - (x) ) & -64 ) ) )
00172 
00173 
00174 FT_END_HEADER
00175 
00176 #endif /* __FTCALC_H__ */
00177 
00178 
00179 /* END */

Generated on Tue Jul 5 14:13:38 2011 for ROOT_528-00b_version by  doxygen 1.5.1