| 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 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 #define SkFractMul(a,b) SkFractMul_longlong(a,b) | 189 #define SkFractMul(a,b) SkFractMul_longlong(a,b) |
| 190 #define SkFixedSquare(a) SkFixedSquare_longlong(a) | 190 #define SkFixedSquare(a) SkFixedSquare_longlong(a) |
| 191 #endif | 191 #endif |
| 192 | 192 |
| 193 #if defined(SK_CPU_ARM) | 193 #if defined(SK_CPU_ARM) |
| 194 /* This guy does not handle NaN or other obscurities, but is faster than | 194 /* This guy does not handle NaN or other obscurities, but is faster than |
| 195 than (int)(x*65536) | 195 than (int)(x*65536) |
| 196 */ | 196 */ |
| 197 inline SkFixed SkFloatToFixed_arm(float x) | 197 inline SkFixed SkFloatToFixed_arm(float x) |
| 198 { | 198 { |
| 199 register int32_t y, z; | 199 int32_t y, z; |
| 200 asm("movs %1, %3, lsl #1 \n" | 200 asm("movs %1, %3, lsl #1 \n" |
| 201 "mov %2, #0x8E \n" | 201 "mov %2, #0x8E \n" |
| 202 "sub %1, %2, %1, lsr #24 \n" | 202 "sub %1, %2, %1, lsr #24 \n" |
| 203 "mov %2, %3, lsl #8 \n" | 203 "mov %2, %3, lsl #8 \n" |
| 204 "orr %2, %2, #0x80000000 \n" | 204 "orr %2, %2, #0x80000000 \n" |
| 205 "mov %1, %2, lsr %1 \n" | 205 "mov %1, %2, lsr %1 \n" |
| 206 "it cs \n" | 206 "it cs \n" |
| 207 "rsbcs %1, %1, #0 \n" | 207 "rsbcs %1, %1, #0 \n" |
| 208 : "=r"(x), "=&r"(y), "=&r"(z) | 208 : "=r"(x), "=&r"(y), "=&r"(z) |
| 209 : "r"(x) | 209 : "r"(x) |
| 210 : "cc" | 210 : "cc" |
| 211 ); | 211 ); |
| 212 return y; | 212 return y; |
| 213 } | 213 } |
| 214 inline SkFixed SkFixedMul_arm(SkFixed x, SkFixed y) | 214 inline SkFixed SkFixedMul_arm(SkFixed x, SkFixed y) |
| 215 { | 215 { |
| 216 register int32_t t; | 216 int32_t t; |
| 217 asm("smull %0, %2, %1, %3 \n" | 217 asm("smull %0, %2, %1, %3 \n" |
| 218 "mov %0, %0, lsr #16 \n" | 218 "mov %0, %0, lsr #16 \n" |
| 219 "orr %0, %0, %2, lsl #16 \n" | 219 "orr %0, %0, %2, lsl #16 \n" |
| 220 : "=r"(x), "=&r"(y), "=r"(t) | 220 : "=r"(x), "=&r"(y), "=r"(t) |
| 221 : "r"(x), "1"(y) | 221 : "r"(x), "1"(y) |
| 222 : | 222 : |
| 223 ); | 223 ); |
| 224 return x; | 224 return x; |
| 225 } | 225 } |
| 226 inline SkFixed SkFixedMulAdd_arm(SkFixed x, SkFixed y, SkFixed a) | 226 inline SkFixed SkFixedMulAdd_arm(SkFixed x, SkFixed y, SkFixed a) |
| 227 { | 227 { |
| 228 register int32_t t; | 228 int32_t t; |
| 229 asm("smull %0, %3, %1, %4 \n" | 229 asm("smull %0, %3, %1, %4 \n" |
| 230 "add %0, %2, %0, lsr #16 \n" | 230 "add %0, %2, %0, lsr #16 \n" |
| 231 "add %0, %0, %3, lsl #16 \n" | 231 "add %0, %0, %3, lsl #16 \n" |
| 232 : "=r"(x), "=&r"(y), "=&r"(a), "=r"(t) | 232 : "=r"(x), "=&r"(y), "=&r"(a), "=r"(t) |
| 233 : "%r"(x), "1"(y), "2"(a) | 233 : "%r"(x), "1"(y), "2"(a) |
| 234 : | 234 : |
| 235 ); | 235 ); |
| 236 return x; | 236 return x; |
| 237 } | 237 } |
| 238 inline SkFixed SkFractMul_arm(SkFixed x, SkFixed y) | 238 inline SkFixed SkFractMul_arm(SkFixed x, SkFixed y) |
| 239 { | 239 { |
| 240 register int32_t t; | 240 int32_t t; |
| 241 asm("smull %0, %2, %1, %3 \n" | 241 asm("smull %0, %2, %1, %3 \n" |
| 242 "mov %0, %0, lsr #30 \n" | 242 "mov %0, %0, lsr #30 \n" |
| 243 "orr %0, %0, %2, lsl #2 \n" | 243 "orr %0, %0, %2, lsl #2 \n" |
| 244 : "=r"(x), "=&r"(y), "=r"(t) | 244 : "=r"(x), "=&r"(y), "=r"(t) |
| 245 : "r"(x), "1"(y) | 245 : "r"(x), "1"(y) |
| 246 : | 246 : |
| 247 ); | 247 ); |
| 248 return x; | 248 return x; |
| 249 } | 249 } |
| 250 #undef SkFixedMul | 250 #undef SkFixedMul |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 #define SkFixed48ToFixed(x) ((SkFixed)((x) >> 32)) | 282 #define SkFixed48ToFixed(x) ((SkFixed)((x) >> 32)) |
| 283 #define SkFloatToFixed48(x) ((SkFixed48)((x) * (65536.0f * 65536.0f * 65536.
0f))) | 283 #define SkFloatToFixed48(x) ((SkFixed48)((x) * (65536.0f * 65536.0f * 65536.
0f))) |
| 284 | 284 |
| 285 #ifdef SK_SCALAR_IS_FLOAT | 285 #ifdef SK_SCALAR_IS_FLOAT |
| 286 #define SkScalarToFixed48(x) SkFloatToFixed48(x) | 286 #define SkScalarToFixed48(x) SkFloatToFixed48(x) |
| 287 #else | 287 #else |
| 288 #define SkScalarToFixed48(x) SkFixedToFixed48(x) | 288 #define SkScalarToFixed48(x) SkFixedToFixed48(x) |
| 289 #endif | 289 #endif |
| 290 | 290 |
| 291 #endif | 291 #endif |
| OLD | NEW |