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 #if SK_BUILD_FOR_IOS |
| 14 #define SK_FAST_UNDERFLOW_BEHAVIOR |
| 15 #endif |
| 16 |
13 /** Returns -1 if n < 0, else returns 0 | 17 /** Returns -1 if n < 0, else returns 0 |
14 */ | 18 */ |
15 #define SkExtractSign(n) ((int32_t)(n) >> 31) | 19 #define SkExtractSign(n) ((int32_t)(n) >> 31) |
16 | 20 |
17 /** If sign == -1, returns -n, else sign must be 0, and returns n. | 21 /** If sign == -1, returns -n, else sign must be 0, and returns n. |
18 Typically used in conjunction with SkExtractSign(). | 22 Typically used in conjunction with SkExtractSign(). |
19 */ | 23 */ |
20 static inline int32_t SkApplySign(int32_t n, int32_t sign) { | 24 static inline int32_t SkApplySign(int32_t n, int32_t sign) { |
21 SkASSERT(sign == 0 || sign == -1); | 25 SkASSERT(sign == 0 || sign == -1); |
22 return (n ^ sign) - sign; | 26 return (n ^ sign) - sign; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 } | 66 } |
63 | 67 |
64 /** Just the rounding step in SkDiv255Round: round(value / 255) | 68 /** Just the rounding step in SkDiv255Round: round(value / 255) |
65 */ | 69 */ |
66 static inline unsigned SkDiv255Round(unsigned prod) { | 70 static inline unsigned SkDiv255Round(unsigned prod) { |
67 prod += 128; | 71 prod += 128; |
68 return (prod + (prod >> 8)) >> 8; | 72 return (prod + (prod >> 8)) >> 8; |
69 } | 73 } |
70 | 74 |
71 #endif | 75 #endif |
OLD | NEW |