| 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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 #ifdef SkLONGLONG | 100 #ifdef SkLONGLONG |
| 101 inline SkFixed SkFixedMul_longlong(SkFixed a, SkFixed b) | 101 inline SkFixed SkFixedMul_longlong(SkFixed a, SkFixed b) |
| 102 { | 102 { |
| 103 return (SkFixed)((int64_t)a * b >> 16); | 103 return (SkFixed)((int64_t)a * b >> 16); |
| 104 } | 104 } |
| 105 #define SkFixedMul(a,b) SkFixedMul_longlong(a,b) | 105 #define SkFixedMul(a,b) SkFixedMul_longlong(a,b) |
| 106 #endif | 106 #endif |
| 107 | 107 |
| 108 #if defined(SK_CPU_ARM) | 108 #if defined(SK_CPU_ARM) |
| 109 /* This guy does not handle NaN or other obscurities, but is faster than | 109 /* This guy does not handle NaN or other obscurities, but is faster than |
| 110 than (int)(x*65536) | 110 than (int)(x*65536). When built on Android with -Os, needs forcing |
| 111 to inline or we lose the speed benefit. |
| 111 */ | 112 */ |
| 112 inline SkFixed SkFloatToFixed_arm(float x) | 113 SK_ALWAYS_INLINE SkFixed SkFloatToFixed_arm(float x) |
| 113 { | 114 { |
| 114 int32_t y, z; | 115 int32_t y, z; |
| 115 asm("movs %1, %3, lsl #1 \n" | 116 asm("movs %1, %3, lsl #1 \n" |
| 116 "mov %2, #0x8E \n" | 117 "mov %2, #0x8E \n" |
| 117 "sub %1, %2, %1, lsr #24 \n" | 118 "sub %1, %2, %1, lsr #24 \n" |
| 118 "mov %2, %3, lsl #8 \n" | 119 "mov %2, %3, lsl #8 \n" |
| 119 "orr %2, %2, #0x80000000 \n" | 120 "orr %2, %2, #0x80000000 \n" |
| 120 "mov %1, %2, lsr %1 \n" | 121 "mov %1, %2, lsr %1 \n" |
| 121 "it cs \n" | 122 "it cs \n" |
| 122 "rsbcs %1, %1, #0 \n" | 123 "rsbcs %1, %1, #0 \n" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 | 156 |
| 156 #define SkIntToFixed48(x) ((SkFixed48)(x) << 48) | 157 #define SkIntToFixed48(x) ((SkFixed48)(x) << 48) |
| 157 #define SkFixed48ToInt(x) ((int)((x) >> 48)) | 158 #define SkFixed48ToInt(x) ((int)((x) >> 48)) |
| 158 #define SkFixedToFixed48(x) ((SkFixed48)(x) << 32) | 159 #define SkFixedToFixed48(x) ((SkFixed48)(x) << 32) |
| 159 #define SkFixed48ToFixed(x) ((SkFixed)((x) >> 32)) | 160 #define SkFixed48ToFixed(x) ((SkFixed)((x) >> 32)) |
| 160 #define SkFloatToFixed48(x) ((SkFixed48)((x) * (65536.0f * 65536.0f * 65536.
0f))) | 161 #define SkFloatToFixed48(x) ((SkFixed48)((x) * (65536.0f * 65536.0f * 65536.
0f))) |
| 161 | 162 |
| 162 #define SkScalarToFixed48(x) SkFloatToFixed48(x) | 163 #define SkScalarToFixed48(x) SkFloatToFixed48(x) |
| 163 | 164 |
| 164 #endif | 165 #endif |
| OLD | NEW |