OLD | NEW |
1 /***************************************************************************/ | 1 /***************************************************************************/ |
2 /* */ | 2 /* */ |
3 /* cf2fixed.h */ | 3 /* cf2fixed.h */ |
4 /* */ | 4 /* */ |
5 /* Adobe's code for Fixed Point Mathematics (specification only). */ | 5 /* Adobe's code for Fixed Point Mathematics (specification only). */ |
6 /* */ | 6 /* */ |
7 /* Copyright 2007-2013 Adobe Systems Incorporated. */ | 7 /* Copyright 2007-2013 Adobe Systems Incorporated. */ |
8 /* */ | 8 /* */ |
9 /* This software, and all works of authorship, whether in source or */ | 9 /* This software, and all works of authorship, whether in source or */ |
10 /* object code form as indicated by the copyright notice(s) included */ | 10 /* object code form as indicated by the copyright notice(s) included */ |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 | 50 |
51 | 51 |
52 #define CF2_FIXED_MAX ( (CF2_Fixed)0x7FFFFFFFL ) | 52 #define CF2_FIXED_MAX ( (CF2_Fixed)0x7FFFFFFFL ) |
53 #define CF2_FIXED_MIN ( (CF2_Fixed)0x80000000L ) | 53 #define CF2_FIXED_MIN ( (CF2_Fixed)0x80000000L ) |
54 #define CF2_FIXED_ONE 0x10000L | 54 #define CF2_FIXED_ONE 0x10000L |
55 #define CF2_FIXED_EPSILON 0x0001 | 55 #define CF2_FIXED_EPSILON 0x0001 |
56 | 56 |
57 /* in C 89, left and right shift of negative numbers is */ | 57 /* in C 89, left and right shift of negative numbers is */ |
58 /* implementation specific behaviour in the general case */ | 58 /* implementation specific behaviour in the general case */ |
59 | 59 |
60 #define cf2_intToFixed( i ) \ | 60 #define cf2_intToFixed( i ) \ |
61 ( (CF2_Fixed)( (FT_UInt32)(i) << 16 ) ) | 61 ( (CF2_Fixed)( (FT_UInt32)(i) << 16 ) ) |
62 #define cf2_fixedToInt( x ) \ | 62 #define cf2_fixedToInt( x ) \ |
63 ( (FT_Short)( ( (FT_UInt32)(x) + 0x8000U ) >> 16 ) ) | 63 ( (FT_Short)( ( (FT_UInt32)(x) + 0x8000U ) >> 16 ) ) |
64 #define cf2_fixedRound( x ) \ | 64 #define cf2_fixedRound( x ) \ |
65 ( (CF2_Fixed)( ( (x) + 0x8000 ) & 0xFFFF0000L ) ) | 65 ( (CF2_Fixed)( ( (FT_UInt32)(x) + 0x8000U ) & 0xFFFF0000UL ) ) |
66 #define cf2_floatToFixed( f ) \ | 66 #define cf2_floatToFixed( f ) \ |
67 ( (CF2_Fixed)( (f) * 65536.0 + 0.5 ) ) | 67 ( (CF2_Fixed)( (f) * 65536.0 + 0.5 ) ) |
68 #define cf2_fixedAbs( x ) \ | 68 #define cf2_fixedAbs( x ) \ |
69 ( (x) < 0 ? -(x) : (x) ) | 69 ( (x) < 0 ? -(x) : (x) ) |
70 #define cf2_fixedFloor( x ) \ | 70 #define cf2_fixedFloor( x ) \ |
71 ( (CF2_Fixed)( (x) & 0xFFFF0000L ) ) | 71 ( (CF2_Fixed)( (FT_UInt32)(x) & 0xFFFF0000UL ) ) |
72 #define cf2_fixedFraction( x ) \ | 72 #define cf2_fixedFraction( x ) \ |
73 ( (x) - cf2_fixedFloor( x ) ) | 73 ( (x) - cf2_fixedFloor( x ) ) |
74 #define cf2_fracToFixed( x ) \ | 74 #define cf2_fracToFixed( x ) \ |
75 ( (x) < 0 ? -( ( -(x) + 0x2000 ) >> 14 ) \ | 75 ( (x) < 0 ? -( ( -(x) + 0x2000 ) >> 14 ) \ |
76 : ( ( (x) + 0x2000 ) >> 14 ) ) | 76 : ( ( (x) + 0x2000 ) >> 14 ) ) |
77 | 77 |
78 | 78 |
79 /* signed numeric types */ | 79 /* signed numeric types */ |
80 typedef enum CF2_NumberType_ | 80 typedef enum CF2_NumberType_ |
81 { | 81 { |
82 CF2_NumberFixed, /* 16.16 */ | 82 CF2_NumberFixed, /* 16.16 */ |
83 CF2_NumberFrac, /* 2.30 */ | 83 CF2_NumberFrac, /* 2.30 */ |
84 CF2_NumberInt /* 32.0 */ | 84 CF2_NumberInt /* 32.0 */ |
85 | 85 |
86 } CF2_NumberType; | 86 } CF2_NumberType; |
87 | 87 |
88 | 88 |
89 FT_END_HEADER | 89 FT_END_HEADER |
90 | 90 |
91 | 91 |
92 #endif /* __CF2FIXED_H__ */ | 92 #endif /* __CF2FIXED_H__ */ |
93 | 93 |
94 | 94 |
95 /* END */ | 95 /* END */ |
OLD | NEW |