vrshoot

diff 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
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/libs/ft2static/freetype/internal/ftcalc.h	Sat Feb 01 19:58:19 2014 +0200
     1.3 @@ -0,0 +1,179 @@
     1.4 +/***************************************************************************/
     1.5 +/*                                                                         */
     1.6 +/*  ftcalc.h                                                               */
     1.7 +/*                                                                         */
     1.8 +/*    Arithmetic computations (specification).                             */
     1.9 +/*                                                                         */
    1.10 +/*  Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2008, 2009 by       */
    1.11 +/*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
    1.12 +/*                                                                         */
    1.13 +/*  This file is part of the FreeType project, and may only be used,       */
    1.14 +/*  modified, and distributed under the terms of the FreeType project      */
    1.15 +/*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
    1.16 +/*  this file you indicate that you have read the license and              */
    1.17 +/*  understand and accept it fully.                                        */
    1.18 +/*                                                                         */
    1.19 +/***************************************************************************/
    1.20 +
    1.21 +
    1.22 +#ifndef __FTCALC_H__
    1.23 +#define __FTCALC_H__
    1.24 +
    1.25 +
    1.26 +#include <ft2build.h>
    1.27 +#include FT_FREETYPE_H
    1.28 +
    1.29 +
    1.30 +FT_BEGIN_HEADER
    1.31 +
    1.32 +
    1.33 +  /*************************************************************************/
    1.34 +  /*                                                                       */
    1.35 +  /* <Function>                                                            */
    1.36 +  /*    FT_FixedSqrt                                                       */
    1.37 +  /*                                                                       */
    1.38 +  /* <Description>                                                         */
    1.39 +  /*    Computes the square root of a 16.16 fixed point value.             */
    1.40 +  /*                                                                       */
    1.41 +  /* <Input>                                                               */
    1.42 +  /*    x :: The value to compute the root for.                            */
    1.43 +  /*                                                                       */
    1.44 +  /* <Return>                                                              */
    1.45 +  /*    The result of `sqrt(x)'.                                           */
    1.46 +  /*                                                                       */
    1.47 +  /* <Note>                                                                */
    1.48 +  /*    This function is not very fast.                                    */
    1.49 +  /*                                                                       */
    1.50 +  FT_BASE( FT_Int32 )
    1.51 +  FT_SqrtFixed( FT_Int32  x );
    1.52 +
    1.53 +
    1.54 +#ifdef FT_CONFIG_OPTION_OLD_INTERNALS
    1.55 +
    1.56 +  /*************************************************************************/
    1.57 +  /*                                                                       */
    1.58 +  /* <Function>                                                            */
    1.59 +  /*    FT_Sqrt32                                                          */
    1.60 +  /*                                                                       */
    1.61 +  /* <Description>                                                         */
    1.62 +  /*    Computes the square root of an Int32 integer (which will be        */
    1.63 +  /*    handled as an unsigned long value).                                */
    1.64 +  /*                                                                       */
    1.65 +  /* <Input>                                                               */
    1.66 +  /*    x :: The value to compute the root for.                            */
    1.67 +  /*                                                                       */
    1.68 +  /* <Return>                                                              */
    1.69 +  /*    The result of `sqrt(x)'.                                           */
    1.70 +  /*                                                                       */
    1.71 +  FT_EXPORT( FT_Int32 )
    1.72 +  FT_Sqrt32( FT_Int32  x );
    1.73 +
    1.74 +#endif /* FT_CONFIG_OPTION_OLD_INTERNALS */
    1.75 +
    1.76 +
    1.77 +  /*************************************************************************/
    1.78 +  /*                                                                       */
    1.79 +  /* FT_MulDiv() and FT_MulFix() are declared in freetype.h.               */
    1.80 +  /*                                                                       */
    1.81 +  /*************************************************************************/
    1.82 +
    1.83 +
    1.84 +#ifdef TT_USE_BYTECODE_INTERPRETER
    1.85 +
    1.86 +  /*************************************************************************/
    1.87 +  /*                                                                       */
    1.88 +  /* <Function>                                                            */
    1.89 +  /*    FT_MulDiv_No_Round                                                 */
    1.90 +  /*                                                                       */
    1.91 +  /* <Description>                                                         */
    1.92 +  /*    A very simple function used to perform the computation `(a*b)/c'   */
    1.93 +  /*    (without rounding) with maximal accuracy (it uses a 64-bit         */
    1.94 +  /*    intermediate integer whenever necessary).                          */
    1.95 +  /*                                                                       */
    1.96 +  /*    This function isn't necessarily as fast as some processor specific */
    1.97 +  /*    operations, but is at least completely portable.                   */
    1.98 +  /*                                                                       */
    1.99 +  /* <Input>                                                               */
   1.100 +  /*    a :: The first multiplier.                                         */
   1.101 +  /*    b :: The second multiplier.                                        */
   1.102 +  /*    c :: The divisor.                                                  */
   1.103 +  /*                                                                       */
   1.104 +  /* <Return>                                                              */
   1.105 +  /*    The result of `(a*b)/c'.  This function never traps when trying to */
   1.106 +  /*    divide by zero; it simply returns `MaxInt' or `MinInt' depending   */
   1.107 +  /*    on the signs of `a' and `b'.                                       */
   1.108 +  /*                                                                       */
   1.109 +  FT_BASE( FT_Long )
   1.110 +  FT_MulDiv_No_Round( FT_Long  a,
   1.111 +                      FT_Long  b,
   1.112 +                      FT_Long  c );
   1.113 +
   1.114 +#endif /* TT_USE_BYTECODE_INTERPRETER */
   1.115 +
   1.116 +
   1.117 +  /*
   1.118 +   *  A variant of FT_Matrix_Multiply which scales its result afterwards.
   1.119 +   *  The idea is that both `a' and `b' are scaled by factors of 10 so that
   1.120 +   *  the values are as precise as possible to get a correct result during
   1.121 +   *  the 64bit multiplication.  Let `sa' and `sb' be the scaling factors of
   1.122 +   *  `a' and `b', respectively, then the scaling factor of the result is
   1.123 +   *  `sa*sb'.
   1.124 +   */
   1.125 +  FT_BASE( void )
   1.126 +  FT_Matrix_Multiply_Scaled( const FT_Matrix*  a,
   1.127 +                             FT_Matrix        *b,
   1.128 +                             FT_Long           scaling );
   1.129 +
   1.130 +
   1.131 +  /*
   1.132 +   *  A variant of FT_Vector_Transform.  See comments for
   1.133 +   *  FT_Matrix_Multiply_Scaled.
   1.134 +   */
   1.135 +
   1.136 +  FT_BASE( void )
   1.137 +  FT_Vector_Transform_Scaled( FT_Vector*        vector,
   1.138 +                              const FT_Matrix*  matrix,
   1.139 +                              FT_Long           scaling );
   1.140 +
   1.141 +
   1.142 +  /*
   1.143 +   *  Return -1, 0, or +1, depending on the orientation of a given corner.
   1.144 +   *  We use the Cartesian coordinate system, with positive vertical values
   1.145 +   *  going upwards.  The function returns +1 if the corner turns to the
   1.146 +   *  left, -1 to the right, and 0 for undecidable cases.
   1.147 +   */
   1.148 +  FT_BASE( FT_Int )
   1.149 +  ft_corner_orientation( FT_Pos  in_x,
   1.150 +                         FT_Pos  in_y,
   1.151 +                         FT_Pos  out_x,
   1.152 +                         FT_Pos  out_y );
   1.153 +
   1.154 +  /*
   1.155 +   *  Return TRUE if a corner is flat or nearly flat.  This is equivalent to
   1.156 +   *  saying that the angle difference between the `in' and `out' vectors is
   1.157 +   *  very small.
   1.158 +   */
   1.159 +  FT_BASE( FT_Int )
   1.160 +  ft_corner_is_flat( FT_Pos  in_x,
   1.161 +                     FT_Pos  in_y,
   1.162 +                     FT_Pos  out_x,
   1.163 +                     FT_Pos  out_y );
   1.164 +
   1.165 +
   1.166 +#define INT_TO_F26DOT6( x )    ( (FT_Long)(x) << 6  )
   1.167 +#define INT_TO_F2DOT14( x )    ( (FT_Long)(x) << 14 )
   1.168 +#define INT_TO_FIXED( x )      ( (FT_Long)(x) << 16 )
   1.169 +#define F2DOT14_TO_FIXED( x )  ( (FT_Long)(x) << 2  )
   1.170 +#define FLOAT_TO_FIXED( x )    ( (FT_Long)( x * 65536.0 ) )
   1.171 +#define FIXED_TO_INT( x )      ( FT_RoundFix( x ) >> 16 )
   1.172 +
   1.173 +#define ROUND_F26DOT6( x )     ( x >= 0 ? (    ( (x) + 32 ) & -64 )     \
   1.174 +                                        : ( -( ( 32 - (x) ) & -64 ) ) )
   1.175 +
   1.176 +
   1.177 +FT_END_HEADER
   1.178 +
   1.179 +#endif /* __FTCALC_H__ */
   1.180 +
   1.181 +
   1.182 +/* END */