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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 #define SkFixedCeilToFixed(x) (((x) + SK_Fixed1 - 1) & 0xFFFF0000) | 79 #define SkFixedCeilToFixed(x) (((x) + SK_Fixed1 - 1) & 0xFFFF0000) |
80 #define SkFixedFloorToFixed(x) ((x) & 0xFFFF0000) | 80 #define SkFixedFloorToFixed(x) ((x) & 0xFFFF0000) |
81 | 81 |
82 #define SkFixedAbs(x) SkAbs32(x) | 82 #define SkFixedAbs(x) SkAbs32(x) |
83 #define SkFixedAve(a, b) (((a) + (b)) >> 1) | 83 #define SkFixedAve(a, b) (((a) + (b)) >> 1) |
84 | 84 |
85 // Blink layout tests are baselined to Clang optimizing through undefined behavi
or in SkDivBits. | 85 // Blink layout tests are baselined to Clang optimizing through undefined behavi
or in SkDivBits. |
86 #if defined(SK_SUPPORT_LEGACY_DIVBITS_UB) | 86 #if defined(SK_SUPPORT_LEGACY_DIVBITS_UB) |
87 #define SkFixedDiv(numer, denom) SkDivBits(numer, denom, 16) | 87 #define SkFixedDiv(numer, denom) SkDivBits(numer, denom, 16) |
88 #else | 88 #else |
89 // TODO(reed): this clamp shouldn't be needed. Use SkToS32(). | 89 // The divide may exceed 32 bits. Clamp to a signed 32 bit result. |
90 #define SkFixedDiv(numer, denom) \ | 90 #define SkFixedDiv(numer, denom) \ |
91 SkTPin<int32_t>((int32_t)(SkLeftShift((int64_t)numer, 16) / denom), SK_M
inS32, SK_MaxS32) | 91 SkToS32(SkTPin<int64_t>((SkLeftShift((int64_t)numer, 16) / denom), SK_Mi
nS32, SK_MaxS32)) |
92 #endif | 92 #endif |
93 | 93 |
94 ////////////////////////////////////////////////////////////////////////////////
////////////////////// | 94 ////////////////////////////////////////////////////////////////////////////////
////////////////////// |
95 // Now look for ASM overrides for our portable versions (should consider putting
this in its own file) | 95 // Now look for ASM overrides for our portable versions (should consider putting
this in its own file) |
96 | 96 |
97 inline SkFixed SkFixedMul_longlong(SkFixed a, SkFixed b) { | 97 inline SkFixed SkFixedMul_longlong(SkFixed a, SkFixed b) { |
98 return (SkFixed)((int64_t)a * b >> 16); | 98 return (SkFixed)((int64_t)a * b >> 16); |
99 } | 99 } |
100 #define SkFixedMul(a,b) SkFixedMul_longlong(a,b) | 100 #define SkFixedMul(a,b) SkFixedMul_longlong(a,b) |
101 | 101 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 #define Sk48Dot16FloorToInt(x) static_cast<int>((x) >> 16) | 162 #define Sk48Dot16FloorToInt(x) static_cast<int>((x) >> 16) |
163 | 163 |
164 static inline float Sk48Dot16ToScalar(Sk48Dot16 x) { | 164 static inline float Sk48Dot16ToScalar(Sk48Dot16 x) { |
165 return static_cast<float>(x * 1.5258789e-5); // x * (1.0f / (1 << 16)) | 165 return static_cast<float>(x * 1.5258789e-5); // x * (1.0f / (1 << 16)) |
166 } | 166 } |
167 #define SkFloatTo48Dot16(x) (static_cast<Sk48Dot16>((x) * (1 << 16))) | 167 #define SkFloatTo48Dot16(x) (static_cast<Sk48Dot16>((x) * (1 << 16))) |
168 | 168 |
169 #define SkScalarTo48Dot16(x) SkFloatTo48Dot16(x) | 169 #define SkScalarTo48Dot16(x) SkFloatTo48Dot16(x) |
170 | 170 |
171 #endif | 171 #endif |
OLD | NEW |