OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
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 SkMathPriv_DEFINED | 8 #ifndef SkMathPriv_DEFINED |
9 #define SkMathPriv_DEFINED | 9 #define SkMathPriv_DEFINED |
10 | 10 |
11 #include "SkMath.h" | 11 #include "SkMath.h" |
12 | 12 |
| 13 #ifdef SK_BUILD_FOR_IOS |
| 14 // The iOS ARM processor discards small denormalized numbers to go faster. |
| 15 // Algorithms that rely on denormalized numbers need alternative implementations
. |
| 16 #define SK_DISCARD_DENORMALIZED_FOR_SPEED |
| 17 #endif |
| 18 |
13 /** Returns -1 if n < 0, else returns 0 | 19 /** Returns -1 if n < 0, else returns 0 |
14 */ | 20 */ |
15 #define SkExtractSign(n) ((int32_t)(n) >> 31) | 21 #define SkExtractSign(n) ((int32_t)(n) >> 31) |
16 | 22 |
17 /** If sign == -1, returns -n, else sign must be 0, and returns n. | 23 /** If sign == -1, returns -n, else sign must be 0, and returns n. |
18 Typically used in conjunction with SkExtractSign(). | 24 Typically used in conjunction with SkExtractSign(). |
19 */ | 25 */ |
20 static inline int32_t SkApplySign(int32_t n, int32_t sign) { | 26 static inline int32_t SkApplySign(int32_t n, int32_t sign) { |
21 SkASSERT(sign == 0 || sign == -1); | 27 SkASSERT(sign == 0 || sign == -1); |
22 return (n ^ sign) - sign; | 28 return (n ^ sign) - sign; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 } | 68 } |
63 | 69 |
64 /** Just the rounding step in SkDiv255Round: round(value / 255) | 70 /** Just the rounding step in SkDiv255Round: round(value / 255) |
65 */ | 71 */ |
66 static inline unsigned SkDiv255Round(unsigned prod) { | 72 static inline unsigned SkDiv255Round(unsigned prod) { |
67 prod += 128; | 73 prod += 128; |
68 return (prod + (prod >> 8)) >> 8; | 74 return (prod + (prod >> 8)) >> 8; |
69 } | 75 } |
70 | 76 |
71 #endif | 77 #endif |
OLD | NEW |