| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2006 The Android Open Source Project | 3 * Copyright 2006 The Android Open Source Project |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 | 9 |
| 10 #ifndef SkFixed_DEFINED | 10 #ifndef SkFixed_DEFINED |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 | 165 |
| 166 inline bool SkFixedNearlyZero(SkFixed x, SkFixed tolerance = SK_FixedNearlyZero) | 166 inline bool SkFixedNearlyZero(SkFixed x, SkFixed tolerance = SK_FixedNearlyZero) |
| 167 { | 167 { |
| 168 SkASSERT(tolerance > 0); | 168 SkASSERT(tolerance > 0); |
| 169 return SkAbs32(x) < tolerance; | 169 return SkAbs32(x) < tolerance; |
| 170 } | 170 } |
| 171 | 171 |
| 172 ////////////////////////////////////////////////////////////////////////////////
////////////////////// | 172 ////////////////////////////////////////////////////////////////////////////////
////////////////////// |
| 173 // Now look for ASM overrides for our portable versions (should consider putting
this in its own file) | 173 // Now look for ASM overrides for our portable versions (should consider putting
this in its own file) |
| 174 | 174 |
| 175 #ifdef SkLONGLONG | |
| 176 inline SkFixed SkFixedMul_longlong(SkFixed a, SkFixed b) | |
| 177 { | |
| 178 return (SkFixed)((SkLONGLONG)a * b >> 16); | |
| 179 } | |
| 180 inline SkFract SkFractMul_longlong(SkFract a, SkFract b) | |
| 181 { | |
| 182 return (SkFract)((SkLONGLONG)a * b >> 30); | |
| 183 } | |
| 184 inline SkFixed SkFixedSquare_longlong(SkFixed value) | |
| 185 { | |
| 186 return (SkFixed)((SkLONGLONG)value * value >> 16); | |
| 187 } | |
| 188 #define SkFixedMul(a,b) SkFixedMul_longlong(a,b) | |
| 189 #define SkFractMul(a,b) SkFractMul_longlong(a,b) | |
| 190 #define SkFixedSquare(a) SkFixedSquare_longlong(a) | |
| 191 #endif | |
| 192 | |
| 193 #if defined(SK_CPU_ARM) | 175 #if defined(SK_CPU_ARM) |
| 194 /* This guy does not handle NaN or other obscurities, but is faster than | 176 /* This guy does not handle NaN or other obscurities, but is faster than |
| 195 than (int)(x*65536) | 177 than (int)(x*65536) |
| 196 */ | 178 */ |
| 197 inline SkFixed SkFloatToFixed_arm(float x) | 179 inline SkFixed SkFloatToFixed_arm(float x) |
| 198 { | 180 { |
| 199 register int32_t y, z; | 181 register int32_t y, z; |
| 200 asm("movs %1, %3, lsl #1 \n" | 182 asm("movs %1, %3, lsl #1 \n" |
| 201 "mov %2, #0x8E \n" | 183 "mov %2, #0x8E \n" |
| 202 "sub %1, %2, %1, lsr #24 \n" | 184 "sub %1, %2, %1, lsr #24 \n" |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 #define SkFixed48ToFixed(x) ((SkFixed)((x) >> 32)) | 264 #define SkFixed48ToFixed(x) ((SkFixed)((x) >> 32)) |
| 283 #define SkFloatToFixed48(x) ((SkFixed48)((x) * (65536.0f * 65536.0f * 65536.
0f))) | 265 #define SkFloatToFixed48(x) ((SkFixed48)((x) * (65536.0f * 65536.0f * 65536.
0f))) |
| 284 | 266 |
| 285 #ifdef SK_SCALAR_IS_FLOAT | 267 #ifdef SK_SCALAR_IS_FLOAT |
| 286 #define SkScalarToFixed48(x) SkFloatToFixed48(x) | 268 #define SkScalarToFixed48(x) SkFloatToFixed48(x) |
| 287 #else | 269 #else |
| 288 #define SkScalarToFixed48(x) SkFixedToFixed48(x) | 270 #define SkScalarToFixed48(x) SkFixedToFixed48(x) |
| 289 #endif | 271 #endif |
| 290 | 272 |
| 291 #endif | 273 #endif |
| OLD | NEW |