Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(639)

Side by Side Diff: include/freetype/internal/ftcalc.h

Issue 89753003: Update freetype to latest version of ASOP. (Closed) Base URL: https://chromium.googlesource.com/chromium/src/third_party/freetype.git@master
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « include/freetype/internal/autohint.h ('k') | include/freetype/internal/ftdebug.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /***************************************************************************/ 1 /***************************************************************************/
2 /* */ 2 /* */
3 /* ftcalc.h */ 3 /* ftcalc.h */
4 /* */ 4 /* */
5 /* Arithmetic computations (specification). */ 5 /* Arithmetic computations (specification). */
6 /* */ 6 /* */
7 /* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2008, 2009 by */ 7 /* Copyright 1996-2006, 2008, 2009, 2012-2013 by */
8 /* David Turner, Robert Wilhelm, and Werner Lemberg. */ 8 /* David Turner, Robert Wilhelm, and Werner Lemberg. */
9 /* */ 9 /* */
10 /* This file is part of the FreeType project, and may only be used, */ 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 */ 11 /* modified, and distributed under the terms of the FreeType project */
12 /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ 12 /* license, LICENSE.TXT. By continuing to use, modify, or distribute */
13 /* this file you indicate that you have read the license and */ 13 /* this file you indicate that you have read the license and */
14 /* understand and accept it fully. */ 14 /* understand and accept it fully. */
15 /* */ 15 /* */
16 /***************************************************************************/ 16 /***************************************************************************/
17 17
18 18
19 #ifndef __FTCALC_H__ 19 #ifndef __FTCALC_H__
20 #define __FTCALC_H__ 20 #define __FTCALC_H__
21 21
22 22
23 #include <ft2build.h> 23 #include <ft2build.h>
24 #include FT_FREETYPE_H 24 #include FT_FREETYPE_H
25 25
26 26
27 FT_BEGIN_HEADER 27 FT_BEGIN_HEADER
28 28
29 29
30 /*************************************************************************/ 30 /*************************************************************************/
31 /* */ 31 /* */
32 /* <Function> */ 32 /* <Function> */
33 /* FT_FixedSqrt */ 33 /* FT_FixedSqrt */
34 /* */ 34 /* */
35 /* <Description> */ 35 /* <Description> */
36 /* Computes the square root of a 16.16 fixed point value. */ 36 /* Computes the square root of a 16.16 fixed-point value. */
37 /* */ 37 /* */
38 /* <Input> */ 38 /* <Input> */
39 /* x :: The value to compute the root for. */ 39 /* x :: The value to compute the root for. */
40 /* */ 40 /* */
41 /* <Return> */ 41 /* <Return> */
42 /* The result of `sqrt(x)'. */ 42 /* The result of `sqrt(x)'. */
43 /* */ 43 /* */
44 /* <Note> */ 44 /* <Note> */
45 /* This function is not very fast. */ 45 /* This function is not very fast. */
46 /* */ 46 /* */
47 FT_BASE( FT_Int32 ) 47 FT_BASE( FT_Int32 )
48 FT_SqrtFixed( FT_Int32 x ); 48 FT_SqrtFixed( FT_Int32 x );
49 49
50 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 /*************************************************************************/ 51 /*************************************************************************/
75 /* */ 52 /* */
76 /* FT_MulDiv() and FT_MulFix() are declared in freetype.h. */ 53 /* FT_MulDiv() and FT_MulFix() are declared in freetype.h. */
77 /* */ 54 /* */
78 /*************************************************************************/ 55 /*************************************************************************/
79 56
80 57
81 #ifdef TT_USE_BYTECODE_INTERPRETER
82
83 /*************************************************************************/ 58 /*************************************************************************/
84 /* */ 59 /* */
85 /* <Function> */ 60 /* <Function> */
86 /* FT_MulDiv_No_Round */ 61 /* FT_MulDiv_No_Round */
87 /* */ 62 /* */
88 /* <Description> */ 63 /* <Description> */
89 /* A very simple function used to perform the computation `(a*b)/c' */ 64 /* A very simple function used to perform the computation `(a*b)/c' */
90 /* (without rounding) with maximal accuracy (it uses a 64-bit */ 65 /* (without rounding) with maximum accuracy (it uses a 64-bit */
91 /* intermediate integer whenever necessary). */ 66 /* intermediate integer whenever necessary). */
92 /* */ 67 /* */
93 /* This function isn't necessarily as fast as some processor specific */ 68 /* This function isn't necessarily as fast as some processor specific */
94 /* operations, but is at least completely portable. */ 69 /* operations, but is at least completely portable. */
95 /* */ 70 /* */
96 /* <Input> */ 71 /* <Input> */
97 /* a :: The first multiplier. */ 72 /* a :: The first multiplier. */
98 /* b :: The second multiplier. */ 73 /* b :: The second multiplier. */
99 /* c :: The divisor. */ 74 /* c :: The divisor. */
100 /* */ 75 /* */
101 /* <Return> */ 76 /* <Return> */
102 /* The result of `(a*b)/c'. This function never traps when trying to */ 77 /* The result of `(a*b)/c'. This function never traps when trying to */
103 /* divide by zero; it simply returns `MaxInt' or `MinInt' depending */ 78 /* divide by zero; it simply returns `MaxInt' or `MinInt' depending */
104 /* on the signs of `a' and `b'. */ 79 /* on the signs of `a' and `b'. */
105 /* */ 80 /* */
106 FT_BASE( FT_Long ) 81 FT_BASE( FT_Long )
107 FT_MulDiv_No_Round( FT_Long a, 82 FT_MulDiv_No_Round( FT_Long a,
108 FT_Long b, 83 FT_Long b,
109 FT_Long c ); 84 FT_Long c );
110 85
111 #endif /* TT_USE_BYTECODE_INTERPRETER */
112
113 86
114 /* 87 /*
115 * A variant of FT_Matrix_Multiply which scales its result afterwards. 88 * A variant of FT_Matrix_Multiply which scales its result afterwards.
116 * The idea is that both `a' and `b' are scaled by factors of 10 so that 89 * The idea is that both `a' and `b' are scaled by factors of 10 so that
117 * the values are as precise as possible to get a correct result during 90 * the values are as precise as possible to get a correct result during
118 * the 64bit multiplication. Let `sa' and `sb' be the scaling factors of 91 * the 64bit multiplication. Let `sa' and `sb' be the scaling factors of
119 * `a' and `b', respectively, then the scaling factor of the result is 92 * `a' and `b', respectively, then the scaling factor of the result is
120 * `sa*sb'. 93 * `sa*sb'.
121 */ 94 */
122 FT_BASE( void ) 95 FT_BASE( void )
123 FT_Matrix_Multiply_Scaled( const FT_Matrix* a, 96 FT_Matrix_Multiply_Scaled( const FT_Matrix* a,
124 FT_Matrix *b, 97 FT_Matrix *b,
125 FT_Long scaling ); 98 FT_Long scaling );
126 99
127 100
128 /* 101 /*
129 * A variant of FT_Vector_Transform. See comments for 102 * A variant of FT_Vector_Transform. See comments for
130 * FT_Matrix_Multiply_Scaled. 103 * FT_Matrix_Multiply_Scaled.
131 */ 104 */
132
133 FT_BASE( void ) 105 FT_BASE( void )
134 FT_Vector_Transform_Scaled( FT_Vector* vector, 106 FT_Vector_Transform_Scaled( FT_Vector* vector,
135 const FT_Matrix* matrix, 107 const FT_Matrix* matrix,
136 FT_Long scaling ); 108 FT_Long scaling );
137 109
138 110
139 /* 111 /*
140 * Return -1, 0, or +1, depending on the orientation of a given corner. 112 * Return -1, 0, or +1, depending on the orientation of a given corner.
141 * We use the Cartesian coordinate system, with positive vertical values 113 * We use the Cartesian coordinate system, with positive vertical values
142 * going upwards. The function returns +1 if the corner turns to the 114 * going upwards. The function returns +1 if the corner turns to the
(...skipping 10 matching lines...) Expand all
153 * saying that the angle difference between the `in' and `out' vectors is 125 * saying that the angle difference between the `in' and `out' vectors is
154 * very small. 126 * very small.
155 */ 127 */
156 FT_BASE( FT_Int ) 128 FT_BASE( FT_Int )
157 ft_corner_is_flat( FT_Pos in_x, 129 ft_corner_is_flat( FT_Pos in_x,
158 FT_Pos in_y, 130 FT_Pos in_y,
159 FT_Pos out_x, 131 FT_Pos out_x,
160 FT_Pos out_y ); 132 FT_Pos out_y );
161 133
162 134
135 /*
136 * Return the most significant bit index.
137 */
138 FT_BASE( FT_Int )
139 FT_MSB( FT_UInt32 z );
140
141
142 /*
143 * Return sqrt(x*x+y*y), which is the same as `FT_Vector_Length' but uses
144 * two fixed-point arguments instead.
145 */
146 FT_BASE( FT_Fixed )
147 FT_Hypot( FT_Fixed x,
148 FT_Fixed y );
149
150
163 #define INT_TO_F26DOT6( x ) ( (FT_Long)(x) << 6 ) 151 #define INT_TO_F26DOT6( x ) ( (FT_Long)(x) << 6 )
164 #define INT_TO_F2DOT14( x ) ( (FT_Long)(x) << 14 ) 152 #define INT_TO_F2DOT14( x ) ( (FT_Long)(x) << 14 )
165 #define INT_TO_FIXED( x ) ( (FT_Long)(x) << 16 ) 153 #define INT_TO_FIXED( x ) ( (FT_Long)(x) << 16 )
166 #define F2DOT14_TO_FIXED( x ) ( (FT_Long)(x) << 2 ) 154 #define F2DOT14_TO_FIXED( x ) ( (FT_Long)(x) << 2 )
167 #define FLOAT_TO_FIXED( x ) ( (FT_Long)( x * 65536.0 ) ) 155 #define FLOAT_TO_FIXED( x ) ( (FT_Long)( x * 65536.0 ) )
168 #define FIXED_TO_INT( x ) ( FT_RoundFix( x ) >> 16 ) 156 #define FIXED_TO_INT( x ) ( FT_RoundFix( x ) >> 16 )
169 157
170 #define ROUND_F26DOT6( x ) ( x >= 0 ? ( ( (x) + 32 ) & -64 ) \ 158 #define ROUND_F26DOT6( x ) ( x >= 0 ? ( ( (x) + 32 ) & -64 ) \
171 : ( -( ( 32 - (x) ) & -64 ) ) ) 159 : ( -( ( 32 - (x) ) & -64 ) ) )
172 160
173 161
174 FT_END_HEADER 162 FT_END_HEADER
175 163
176 #endif /* __FTCALC_H__ */ 164 #endif /* __FTCALC_H__ */
177 165
178 166
179 /* END */ 167 /* END */
OLDNEW
« no previous file with comments | « include/freetype/internal/autohint.h ('k') | include/freetype/internal/ftdebug.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698