ftcalc.h
上传用户:yisoukefu
上传日期:2020-08-09
资源大小:39506k
文件大小:8k
源码类别:

其他游戏

开发平台:

Visual C++

  1. /***************************************************************************/
  2. /*                                                                         */
  3. /*  ftcalc.h                                                               */
  4. /*                                                                         */
  5. /*    Arithmetic computations (specification).                             */
  6. /*                                                                         */
  7. /*  Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006 by                   */
  8. /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
  9. /*                                                                         */
  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.                                        */
  15. /*                                                                         */
  16. /***************************************************************************/
  17. #ifndef __FTCALC_H__
  18. #define __FTCALC_H__
  19. #include <ft2build.h>
  20. #include FT_FREETYPE_H
  21. FT_BEGIN_HEADER
  22.   /*************************************************************************/
  23.   /*                                                                       */
  24.   /* <Function>                                                            */
  25.   /*    FT_FixedSqrt                                                       */
  26.   /*                                                                       */
  27.   /* <Description>                                                         */
  28.   /*    Computes the square root of a 16.16 fixed point value.             */
  29.   /*                                                                       */
  30.   /* <Input>                                                               */
  31.   /*    x :: The value to compute the root for.                            */
  32.   /*                                                                       */
  33.   /* <Return>                                                              */
  34.   /*    The result of `sqrt(x)'.                                           */
  35.   /*                                                                       */
  36.   /* <Note>                                                                */
  37.   /*    This function is not very fast.                                    */
  38.   /*                                                                       */
  39.   FT_BASE( FT_Int32 )
  40.   FT_SqrtFixed( FT_Int32  x );
  41. #ifdef FT_CONFIG_OPTION_OLD_INTERNALS
  42.   /*************************************************************************/
  43.   /*                                                                       */
  44.   /* <Function>                                                            */
  45.   /*    FT_Sqrt32                                                          */
  46.   /*                                                                       */
  47.   /* <Description>                                                         */
  48.   /*    Computes the square root of an Int32 integer (which will be        */
  49.   /*    handled as an unsigned long value).                                */
  50.   /*                                                                       */
  51.   /* <Input>                                                               */
  52.   /*    x :: The value to compute the root for.                            */
  53.   /*                                                                       */
  54.   /* <Return>                                                              */
  55.   /*    The result of `sqrt(x)'.                                           */
  56.   /*                                                                       */
  57.   FT_EXPORT( FT_Int32 )
  58.   FT_Sqrt32( FT_Int32  x );
  59. #endif /* FT_CONFIG_OPTION_OLD_INTERNALS */
  60.   /*************************************************************************/
  61.   /*                                                                       */
  62.   /* FT_MulDiv() and FT_MulFix() are declared in freetype.h.               */
  63.   /*                                                                       */
  64.   /*************************************************************************/
  65. #ifdef TT_USE_BYTECODE_INTERPRETER
  66.   /*************************************************************************/
  67.   /*                                                                       */
  68.   /* <Function>                                                            */
  69.   /*    FT_MulDiv_No_Round                                                 */
  70.   /*                                                                       */
  71.   /* <Description>                                                         */
  72.   /*    A very simple function used to perform the computation `(a*b)/c'   */
  73.   /*    (without rounding) with maximal accuracy (it uses a 64-bit         */
  74.   /*    intermediate integer whenever necessary).                          */
  75.   /*                                                                       */
  76.   /*    This function isn't necessarily as fast as some processor specific */
  77.   /*    operations, but is at least completely portable.                   */
  78.   /*                                                                       */
  79.   /* <Input>                                                               */
  80.   /*    a :: The first multiplier.                                         */
  81.   /*    b :: The second multiplier.                                        */
  82.   /*    c :: The divisor.                                                  */
  83.   /*                                                                       */
  84.   /* <Return>                                                              */
  85.   /*    The result of `(a*b)/c'.  This function never traps when trying to */
  86.   /*    divide by zero; it simply returns `MaxInt' or `MinInt' depending   */
  87.   /*    on the signs of `a' and `b'.                                       */
  88.   /*                                                                       */
  89.   FT_BASE( FT_Long )
  90.   FT_MulDiv_No_Round( FT_Long  a,
  91.                       FT_Long  b,
  92.                       FT_Long  c );
  93. #endif /* TT_USE_BYTECODE_INTERPRETER */
  94.   /*
  95.    *  Return -1, 0, or +1, depending on the orientation of a given corner.
  96.    *  We use the Cartesian coordinate system, with positive vertical values
  97.    *  going upwards.  The function returns +1 if the corner turns to the
  98.    *  left, -1 to the right, and 0 for undecidable cases.
  99.    */
  100.   FT_BASE( FT_Int )
  101.   ft_corner_orientation( FT_Pos  in_x,
  102.                          FT_Pos  in_y,
  103.                          FT_Pos  out_x,
  104.                          FT_Pos  out_y );
  105.   /*
  106.    *  Return TRUE if a corner is flat or nearly flat.  This is equivalent to
  107.    *  saying that the angle difference between the `in' and `out' vectors is
  108.    *  very small.
  109.    */
  110.   FT_BASE( FT_Int )
  111.   ft_corner_is_flat( FT_Pos  in_x,
  112.                      FT_Pos  in_y,
  113.                      FT_Pos  out_x,
  114.                      FT_Pos  out_y );
  115. #define INT_TO_F26DOT6( x )    ( (FT_Long)(x) << 6  )
  116. #define INT_TO_F2DOT14( x )    ( (FT_Long)(x) << 14 )
  117. #define INT_TO_FIXED( x )      ( (FT_Long)(x) << 16 )
  118. #define F2DOT14_TO_FIXED( x )  ( (FT_Long)(x) << 2  )
  119. #define FLOAT_TO_FIXED( x )    ( (FT_Long)( x * 65536.0 ) )
  120. #define ROUND_F26DOT6( x )     ( x >= 0 ? (    ( (x) + 32 ) & -64 )     
  121.                                         : ( -( ( 32 - (x) ) & -64 ) ) )
  122. FT_END_HEADER
  123. #endif /* __FTCALC_H__ */
  124. /* END */