Visualization Library 2.0.0-b5

A lightweight C++ OpenGL middleware for 2D/3D graphics

VL     Star     Watch     Fork     Issue

[Download] [Tutorials] [All Classes] [Grouped Classes]
ftcalc.h
Go to the documentation of this file.
1 /***************************************************************************/
2 /* */
3 /* ftcalc.h */
4 /* */
5 /* Arithmetic computations (specification). */
6 /* */
7 /* Copyright 1996-2006, 2008, 2009, 2012-2013 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 
18 
19 #ifndef __FTCALC_H__
20 #define __FTCALC_H__
21 
22 
23 #include <ft2build.h>
24 #include FT_FREETYPE_H
25 
26 
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 )
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  /* */
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  /*************************************************************************/
82  /* */
83  /* <Function> */
84  /* FT_MulDiv_No_Round */
85  /* */
86  /* <Description> */
87  /* A very simple function used to perform the computation `(a*b)/c' */
88  /* (without rounding) with maximum accuracy (it uses a 64-bit */
89  /* intermediate integer whenever necessary). */
90  /* */
91  /* This function isn't necessarily as fast as some processor specific */
92  /* operations, but is at least completely portable. */
93  /* */
94  /* <Input> */
95  /* a :: The first multiplier. */
96  /* b :: The second multiplier. */
97  /* c :: The divisor. */
98  /* */
99  /* <Return> */
100  /* The result of `(a*b)/c'. This function never traps when trying to */
101  /* divide by zero; it simply returns `MaxInt' or `MinInt' depending */
102  /* on the signs of `a' and `b'. */
103  /* */
104  FT_BASE( FT_Long )
106  FT_Long b,
107  FT_Long c );
108 
109 
110  /*
111  * A variant of FT_Matrix_Multiply which scales its result afterwards.
112  * The idea is that both `a' and `b' are scaled by factors of 10 so that
113  * the values are as precise as possible to get a correct result during
114  * the 64bit multiplication. Let `sa' and `sb' be the scaling factors of
115  * `a' and `b', respectively, then the scaling factor of the result is
116  * `sa*sb'.
117  */
118  FT_BASE( void )
120  FT_Matrix *b,
121  FT_Long scaling );
122 
123 
124  /*
125  * A variant of FT_Vector_Transform. See comments for
126  * FT_Matrix_Multiply_Scaled.
127  */
128  FT_BASE( void )
130  const FT_Matrix* matrix,
131  FT_Long scaling );
132 
133 
134  /*
135  * Return -1, 0, or +1, depending on the orientation of a given corner.
136  * We use the Cartesian coordinate system, with positive vertical values
137  * going upwards. The function returns +1 if the corner turns to the
138  * left, -1 to the right, and 0 for undecidable cases.
139  */
140  FT_BASE( FT_Int )
142  FT_Pos in_y,
143  FT_Pos out_x,
144  FT_Pos out_y );
145 
146  /*
147  * Return TRUE if a corner is flat or nearly flat. This is equivalent to
148  * saying that the angle difference between the `in' and `out' vectors is
149  * very small.
150  */
151  FT_BASE( FT_Int )
153  FT_Pos in_y,
154  FT_Pos out_x,
155  FT_Pos out_y );
156 
157 
158  /*
159  * Return the most significant bit index.
160  */
161  FT_BASE( FT_Int )
162  FT_MSB( FT_UInt32 z );
163 
164 
165  /*
166  * Return sqrt(x*x+y*y), which is the same as `FT_Vector_Length' but uses
167  * two fixed-point arguments instead.
168  */
169  FT_BASE( FT_Fixed )
171  FT_Fixed y );
172 
173 
174 #define INT_TO_F26DOT6( x ) ( (FT_Long)(x) << 6 )
175 #define INT_TO_F2DOT14( x ) ( (FT_Long)(x) << 14 )
176 #define INT_TO_FIXED( x ) ( (FT_Long)(x) << 16 )
177 #define F2DOT14_TO_FIXED( x ) ( (FT_Long)(x) << 2 )
178 #define FLOAT_TO_FIXED( x ) ( (FT_Long)( x * 65536.0 ) )
179 #define FIXED_TO_INT( x ) ( FT_RoundFix( x ) >> 16 )
180 
181 #define ROUND_F26DOT6( x ) ( x >= 0 ? ( ( (x) + 32 ) & -64 ) \
182  : ( -( ( 32 - (x) ) & -64 ) ) )
183 
184 
186 
187 #endif /* __FTCALC_H__ */
188 
189 
190 /* END */
FT_MulDiv_No_Round(FT_Long a, FT_Long b, FT_Long c)
Definition: ftcalc.c:450
signed long FT_Long
Definition: fttypes.h:238
FT_BEGIN_HEADER typedef signed long FT_Pos
Definition: ftimage.h:59
GLboolean GLboolean GLboolean GLboolean a
#define FT_END_HEADER
Definition: ftheader.h:54
GLint GLint GLint GLint GLint GLint y
signed int FT_Int
Definition: fttypes.h:216
unsigned int FT_UInt32
Definition: ftconfig.h:133
GLint GLint GLint GLint GLint x
GLboolean GLboolean GLboolean b
ft_corner_is_flat(FT_Pos in_x, FT_Pos in_y, FT_Pos out_x, FT_Pos out_y)
Definition: ftcalc.c:971
#define FT_BEGIN_HEADER
Definition: ftheader.h:36
GLdouble GLdouble z
#define FT_BASE(x)
Definition: ftconfig.h:247
const GLubyte * c
signed int FT_Int32
Definition: ftconfig.h:132
FT_BEGIN_HEADER FT_SqrtFixed(FT_Int32 x)
Definition: ftcalc.c:856
ft_corner_orientation(FT_Pos in_x, FT_Pos in_y, FT_Pos out_x, FT_Pos out_y)
Definition: ftcalc.c:891
FT_MSB(FT_UInt32 z)
Definition: ftcalc.c:104
FT_Vector_Transform_Scaled(FT_Vector *vector, const FT_Matrix *matrix, FT_Long scaling)
Definition: ftcalc.c:830
signed long FT_Fixed
Definition: fttypes.h:284
#define FT_EXPORT(x)
Definition: ftconfig.h:269
FT_Matrix_Multiply_Scaled(const FT_Matrix *a, FT_Matrix *b, FT_Long scaling)
Definition: ftcalc.c:805
FT_Hypot(FT_Fixed x, FT_Fixed y)
Definition: ftcalc.c:142
GLuint GLenum matrix