fontservices/freetypefontrasteriser/freetype2/include/freetype/internal/ftcalc.h
changeset 66 18fedaf0292a
equal deleted inserted replaced
64:f66674566702 66:18fedaf0292a
       
     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, FTL.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 
       
    18 
       
    19 #ifndef __FTCALC_H__
       
    20 #define __FTCALC_H__
       
    21 
       
    22 
       
    23 #include <ft2build.h>
       
    24 #include FT_FREETYPE_H
       
    25 
       
    26 
       
    27 FT_BEGIN_HEADER
       
    28 
       
    29 
       
    30   /*************************************************************************/
       
    31   /*                                                                       */
       
    32   /* <Function>                                                            */
       
    33   /*    FT_FixedSqrt                                                       */
       
    34   /*                                                                       */
       
    35   /* <Description>                                                         */
       
    36   /*    Computes the square root of a 16.16 fixed point value.             */
       
    37   /*                                                                       */
       
    38   /* <Input>                                                               */
       
    39   /*    x :: The value to compute the root for.                            */
       
    40   /*                                                                       */
       
    41   /* <Return>                                                              */
       
    42   /*    The result of `sqrt(x)'.                                           */
       
    43   /*                                                                       */
       
    44   /* <Note>                                                                */
       
    45   /*    This function is not very fast.                                    */
       
    46   /*                                                                       */
       
    47   FT_BASE( FT_Int32 )
       
    48   FT_SqrtFixed( FT_Int32  x );
       
    49 
       
    50 
       
    51 #ifdef FT_CONFIG_OPTION_OLD_INTERNALS
       
    52 
       
    53   /*************************************************************************/
       
    54   /*                                                                       */
       
    55   /* <Function>                                                            */
       
    56   /*    FT_Sqrt32                                                          */
       
    57   /*                                                                       */
       
    58   /* <Description>                                                         */
       
    59   /*    Computes the square root of an Int32 integer (which will be        */
       
    60   /*    handled as an unsigned long value).                                */
       
    61   /*                                                                       */
       
    62   /* <Input>                                                               */
       
    63   /*    x :: The value to compute the root for.                            */
       
    64   /*                                                                       */
       
    65   /* <Return>                                                              */
       
    66   /*    The result of `sqrt(x)'.                                           */
       
    67   /*                                                                       */
       
    68   FT_EXPORT( FT_Int32 )
       
    69   FT_Sqrt32( FT_Int32  x );
       
    70 
       
    71 #endif /* FT_CONFIG_OPTION_OLD_INTERNALS */
       
    72 
       
    73 
       
    74   /*************************************************************************/
       
    75   /*                                                                       */
       
    76   /* FT_MulDiv() and FT_MulFix() are declared in freetype.h.               */
       
    77   /*                                                                       */
       
    78   /*************************************************************************/
       
    79 
       
    80 
       
    81 #ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
       
    82 
       
    83   /*************************************************************************/
       
    84   /*                                                                       */
       
    85   /* <Function>                                                            */
       
    86   /*    FT_MulDiv_No_Round                                                 */
       
    87   /*                                                                       */
       
    88   /* <Description>                                                         */
       
    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).                          */
       
    92   /*                                                                       */
       
    93   /*    This function isn't necessarily as fast as some processor specific */
       
    94   /*    operations, but is at least completely portable.                   */
       
    95   /*                                                                       */
       
    96   /* <Input>                                                               */
       
    97   /*    a :: The first multiplier.                                         */
       
    98   /*    b :: The second multiplier.                                        */
       
    99   /*    c :: The divisor.                                                  */
       
   100   /*                                                                       */
       
   101   /* <Return>                                                              */
       
   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'.                                       */
       
   105   /*                                                                       */
       
   106   FT_BASE( FT_Long )
       
   107   FT_MulDiv_No_Round( FT_Long  a,
       
   108                       FT_Long  b,
       
   109                       FT_Long  c );
       
   110 
       
   111 #endif /* TT_CONFIG_OPTION_BYTECODE_INTERPRETER */
       
   112 
       
   113 
       
   114 #define INT_TO_F26DOT6( x )    ( (FT_Long)(x) << 6  )
       
   115 #define INT_TO_F2DOT14( x )    ( (FT_Long)(x) << 14 )
       
   116 #define INT_TO_FIXED( x )      ( (FT_Long)(x) << 16 )
       
   117 #define F2DOT14_TO_FIXED( x )  ( (FT_Long)(x) << 2  )
       
   118 #define FLOAT_TO_FIXED( x )    ( (FT_Long)( x * 65536.0 ) )
       
   119 
       
   120 #define ROUND_F26DOT6( x )     ( x >= 0 ? (    ( (x) + 32 ) & -64 )     \
       
   121                                         : ( -( ( 32 - (x) ) & -64 ) ) )
       
   122 
       
   123 
       
   124 FT_END_HEADER
       
   125 
       
   126 #endif /* __FTCALC_H__ */
       
   127 
       
   128 
       
   129 /* END */