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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 // Now look for ASM overrides for our portable versions (should consider putting
this in its own file) | 98 // Now look for ASM overrides for our portable versions (should consider putting
this in its own file) |
99 | 99 |
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_ARM32) |
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). When built on Android with -Os, needs forcing | 110 than (int)(x*65536). When built on Android with -Os, needs forcing |
111 to inline or we lose the speed benefit. | 111 to inline or we lose the speed benefit. |
112 */ | 112 */ |
113 SK_ALWAYS_INLINE SkFixed SkFloatToFixed_arm(float x) | 113 SK_ALWAYS_INLINE SkFixed SkFloatToFixed_arm(float x) |
114 { | 114 { |
115 int32_t y, z; | 115 int32_t y, z; |
116 asm("movs %1, %3, lsl #1 \n" | 116 asm("movs %1, %3, lsl #1 \n" |
117 "mov %2, #0x8E \n" | 117 "mov %2, #0x8E \n" |
118 "sub %1, %2, %1, lsr #24 \n" | 118 "sub %1, %2, %1, lsr #24 \n" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 | 156 |
157 #define SkIntToFixed48(x) ((SkFixed48)(x) << 48) | 157 #define SkIntToFixed48(x) ((SkFixed48)(x) << 48) |
158 #define SkFixed48ToInt(x) ((int)((x) >> 48)) | 158 #define SkFixed48ToInt(x) ((int)((x) >> 48)) |
159 #define SkFixedToFixed48(x) ((SkFixed48)(x) << 32) | 159 #define SkFixedToFixed48(x) ((SkFixed48)(x) << 32) |
160 #define SkFixed48ToFixed(x) ((SkFixed)((x) >> 32)) | 160 #define SkFixed48ToFixed(x) ((SkFixed)((x) >> 32)) |
161 #define SkFloatToFixed48(x) ((SkFixed48)((x) * (65536.0f * 65536.0f * 65536.
0f))) | 161 #define SkFloatToFixed48(x) ((SkFixed48)((x) * (65536.0f * 65536.0f * 65536.
0f))) |
162 | 162 |
163 #define SkScalarToFixed48(x) SkFloatToFixed48(x) | 163 #define SkScalarToFixed48(x) SkFloatToFixed48(x) |
164 | 164 |
165 #endif | 165 #endif |
OLD | NEW |