/src/compiler/android-ndk/jni/freetype/include/freetype/internal/ftcalc.h

http://ftk.googlecode.com/ · C++ Header · 179 lines · 45 code · 34 blank · 100 comment · 0 complexity · 8ab30315ba473d514d6c583df95fa6ca MD5 · raw file

  1. /***************************************************************************/
  2. /* */
  3. /* ftcalc.h */
  4. /* */
  5. /* Arithmetic computations (specification). */
  6. /* */
  7. /* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2008, 2009 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. * A variant of FT_Matrix_Multiply which scales its result afterwards.
  96. * The idea is that both `a' and `b' are scaled by factors of 10 so that
  97. * the values are as precise as possible to get a correct result during
  98. * the 64bit multiplication. Let `sa' and `sb' be the scaling factors of
  99. * `a' and `b', respectively, then the scaling factor of the result is
  100. * `sa*sb'.
  101. */
  102. FT_BASE( void )
  103. FT_Matrix_Multiply_Scaled( const FT_Matrix* a,
  104. FT_Matrix *b,
  105. FT_Long scaling );
  106. /*
  107. * A variant of FT_Vector_Transform. See comments for
  108. * FT_Matrix_Multiply_Scaled.
  109. */
  110. FT_BASE( void )
  111. FT_Vector_Transform_Scaled( FT_Vector* vector,
  112. const FT_Matrix* matrix,
  113. FT_Long scaling );
  114. /*
  115. * Return -1, 0, or +1, depending on the orientation of a given corner.
  116. * We use the Cartesian coordinate system, with positive vertical values
  117. * going upwards. The function returns +1 if the corner turns to the
  118. * left, -1 to the right, and 0 for undecidable cases.
  119. */
  120. FT_BASE( FT_Int )
  121. ft_corner_orientation( FT_Pos in_x,
  122. FT_Pos in_y,
  123. FT_Pos out_x,
  124. FT_Pos out_y );
  125. /*
  126. * Return TRUE if a corner is flat or nearly flat. This is equivalent to
  127. * saying that the angle difference between the `in' and `out' vectors is
  128. * very small.
  129. */
  130. FT_BASE( FT_Int )
  131. ft_corner_is_flat( FT_Pos in_x,
  132. FT_Pos in_y,
  133. FT_Pos out_x,
  134. FT_Pos out_y );
  135. #define INT_TO_F26DOT6( x ) ( (FT_Long)(x) << 6 )
  136. #define INT_TO_F2DOT14( x ) ( (FT_Long)(x) << 14 )
  137. #define INT_TO_FIXED( x ) ( (FT_Long)(x) << 16 )
  138. #define F2DOT14_TO_FIXED( x ) ( (FT_Long)(x) << 2 )
  139. #define FLOAT_TO_FIXED( x ) ( (FT_Long)( x * 65536.0 ) )
  140. #define FIXED_TO_INT( x ) ( FT_RoundFix( x ) >> 16 )
  141. #define ROUND_F26DOT6( x ) ( x >= 0 ? ( ( (x) + 32 ) & -64 ) \
  142. : ( -( ( 32 - (x) ) & -64 ) ) )
  143. FT_END_HEADER
  144. #endif /* __FTCALC_H__ */
  145. /* END */