| 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 #define SkFixedCeilToInt(x) (((x) + SK_Fixed1 - 1) >> 16) | 75 #define SkFixedCeilToInt(x) (((x) + SK_Fixed1 - 1) >> 16) |
| 76 #define SkFixedFloorToInt(x) ((x) >> 16) | 76 #define SkFixedFloorToInt(x) ((x) >> 16) |
| 77 | 77 |
| 78 #define SkFixedRoundToFixed(x) (((x) + SK_FixedHalf) & 0xFFFF0000) | 78 #define SkFixedRoundToFixed(x) (((x) + SK_FixedHalf) & 0xFFFF0000) |
| 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 #define SkFixedDiv(numer, denom) SkDivBits(numer, denom, 16) | 85 // Blink layout tests are baselined to Clang optimizing through undefined behavi
or in SkDivBits. |
| 86 #if defined(SK_SUPPORT_LEGACY_DIVBITS_UB) |
| 87 #define SkFixedDiv(numer, denom) SkDivBits(numer, denom, 16) |
| 88 #else |
| 89 // TODO(reed): this clamp shouldn't be needed. Use SkToS32(). |
| 90 #define SkFixedDiv(numer, denom) \ |
| 91 SkTPin<int32_t>(((int64_t)numer << 16) / denom, SK_MinS32, SK_MaxS32) |
| 92 #endif |
| 86 | 93 |
| 87 ////////////////////////////////////////////////////////////////////////////////
////////////////////// | 94 ////////////////////////////////////////////////////////////////////////////////
////////////////////// |
| 88 // 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) |
| 89 | 96 |
| 90 inline SkFixed SkFixedMul_longlong(SkFixed a, SkFixed b) { | 97 inline SkFixed SkFixedMul_longlong(SkFixed a, SkFixed b) { |
| 91 return (SkFixed)((int64_t)a * b >> 16); | 98 return (SkFixed)((int64_t)a * b >> 16); |
| 92 } | 99 } |
| 93 #define SkFixedMul(a,b) SkFixedMul_longlong(a,b) | 100 #define SkFixedMul(a,b) SkFixedMul_longlong(a,b) |
| 94 | 101 |
| 95 | 102 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 #define Sk48Dot16FloorToInt(x) static_cast<int>((x) >> 16) | 162 #define Sk48Dot16FloorToInt(x) static_cast<int>((x) >> 16) |
| 156 | 163 |
| 157 static inline float Sk48Dot16ToScalar(Sk48Dot16 x) { | 164 static inline float Sk48Dot16ToScalar(Sk48Dot16 x) { |
| 158 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)) |
| 159 } | 166 } |
| 160 #define SkFloatTo48Dot16(x) (static_cast<Sk48Dot16>((x) * (1 << 16))) | 167 #define SkFloatTo48Dot16(x) (static_cast<Sk48Dot16>((x) * (1 << 16))) |
| 161 | 168 |
| 162 #define SkScalarTo48Dot16(x) SkFloatTo48Dot16(x) | 169 #define SkScalarTo48Dot16(x) SkFloatTo48Dot16(x) |
| 163 | 170 |
| 164 #endif | 171 #endif |
| OLD | NEW |