OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef SkFixed_DEFINED | 8 #ifndef SkFixed_DEFINED |
9 #define SkFixed_DEFINED | 9 #define SkFixed_DEFINED |
10 | 10 |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 #define SkFixedCeilToInt(x) (((x) + SK_Fixed1 - 1) >> 16) | 91 #define SkFixedCeilToInt(x) (((x) + SK_Fixed1 - 1) >> 16) |
92 #define SkFixedFloorToInt(x) ((x) >> 16) | 92 #define SkFixedFloorToInt(x) ((x) >> 16) |
93 | 93 |
94 #define SkFixedRoundToFixed(x) (((x) + SK_FixedHalf) & 0xFFFF0000) | 94 #define SkFixedRoundToFixed(x) (((x) + SK_FixedHalf) & 0xFFFF0000) |
95 #define SkFixedCeilToFixed(x) (((x) + SK_Fixed1 - 1) & 0xFFFF0000) | 95 #define SkFixedCeilToFixed(x) (((x) + SK_Fixed1 - 1) & 0xFFFF0000) |
96 #define SkFixedFloorToFixed(x) ((x) & 0xFFFF0000) | 96 #define SkFixedFloorToFixed(x) ((x) & 0xFFFF0000) |
97 | 97 |
98 #define SkFixedAbs(x) SkAbs32(x) | 98 #define SkFixedAbs(x) SkAbs32(x) |
99 #define SkFixedAve(a, b) (((a) + (b)) >> 1) | 99 #define SkFixedAve(a, b) (((a) + (b)) >> 1) |
100 | 100 |
101 // Blink layout tests are baselined to Clang optimizing through undefined behavi
or in SkDivBits. | 101 // The divide may exceed 32 bits. Clamp to a signed 32 bit result. |
102 #if defined(SK_SUPPORT_LEGACY_DIVBITS_UB) | 102 #define SkFixedDiv(numer, denom) \ |
103 #define SkFixedDiv(numer, denom) SkDivBits(numer, denom, 16) | 103 SkToS32(SkTPin<int64_t>((SkLeftShift((int64_t)numer, 16) / denom), SK_MinS32
, SK_MaxS32)) |
104 #else | |
105 // The divide may exceed 32 bits. Clamp to a signed 32 bit result. | |
106 #define SkFixedDiv(numer, denom) \ | |
107 SkToS32(SkTPin<int64_t>((SkLeftShift((int64_t)numer, 16) / denom), SK_Mi
nS32, SK_MaxS32)) | |
108 #endif | |
109 | 104 |
110 ////////////////////////////////////////////////////////////////////////////////
////////////////////// | 105 ////////////////////////////////////////////////////////////////////////////////
////////////////////// |
111 // Now look for ASM overrides for our portable versions (should consider putting
this in its own file) | 106 // Now look for ASM overrides for our portable versions (should consider putting
this in its own file) |
112 | 107 |
113 inline SkFixed SkFixedMul_longlong(SkFixed a, SkFixed b) { | 108 inline SkFixed SkFixedMul_longlong(SkFixed a, SkFixed b) { |
114 return (SkFixed)((int64_t)a * b >> 16); | 109 return (SkFixed)((int64_t)a * b >> 16); |
115 } | 110 } |
116 #define SkFixedMul(a,b) SkFixedMul_longlong(a,b) | 111 #define SkFixedMul(a,b) SkFixedMul_longlong(a,b) |
117 | 112 |
118 | 113 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 | 174 |
180 #define SkIntToFixed3232(x) (SkLeftShift((SkFixed3232)(x), 32)) | 175 #define SkIntToFixed3232(x) (SkLeftShift((SkFixed3232)(x), 32)) |
181 #define SkFixed3232ToInt(x) ((int)((x) >> 32)) | 176 #define SkFixed3232ToInt(x) ((int)((x) >> 32)) |
182 #define SkFixedToFixed3232(x) (SkLeftShift((SkFixed3232)(x), 16)) | 177 #define SkFixedToFixed3232(x) (SkLeftShift((SkFixed3232)(x), 16)) |
183 #define SkFixed3232ToFixed(x) ((SkFixed)((x) >> 16)) | 178 #define SkFixed3232ToFixed(x) ((SkFixed)((x) >> 16)) |
184 #define SkFloatToFixed3232(x) ((SkFixed3232)((x) * (65536.0f * 65536.0f))) | 179 #define SkFloatToFixed3232(x) ((SkFixed3232)((x) * (65536.0f * 65536.0f))) |
185 | 180 |
186 #define SkScalarToFixed3232(x) SkFloatToFixed3232(x) | 181 #define SkScalarToFixed3232(x) SkFloatToFixed3232(x) |
187 | 182 |
188 #endif | 183 #endif |
OLD | NEW |