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 SkFDot6_DEFINED | 10 #ifndef SkFDot6_DEFINED |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 #define SkIntToFDot6(x) ((x) << 6) | 49 #define SkIntToFDot6(x) ((x) << 6) |
50 #endif | 50 #endif |
51 | 51 |
52 #define SkFDot6Floor(x) ((x) >> 6) | 52 #define SkFDot6Floor(x) ((x) >> 6) |
53 #define SkFDot6Ceil(x) (((x) + 63) >> 6) | 53 #define SkFDot6Ceil(x) (((x) + 63) >> 6) |
54 #define SkFDot6Round(x) (((x) + 32) >> 6) | 54 #define SkFDot6Round(x) (((x) + 32) >> 6) |
55 | 55 |
56 #define SkFixedToFDot6(x) ((x) >> 10) | 56 #define SkFixedToFDot6(x) ((x) >> 10) |
57 | 57 |
58 inline SkFixed SkFDot6ToFixed(SkFDot6 x) { | 58 inline SkFixed SkFDot6ToFixed(SkFDot6 x) { |
59 SkASSERT((x << 10 >> 10) == x); | 59 SkASSERT((SkLeftShift(x, 10) >> 10) == x); |
60 | 60 |
61 return x << 10; | 61 return SkLeftShift(x, 10); |
62 } | 62 } |
63 | 63 |
64 #define SkScalarToFDot6(x) (SkFDot6)((x) * 64) | 64 #define SkScalarToFDot6(x) (SkFDot6)((x) * 64) |
65 #define SkFDot6ToScalar(x) ((SkScalar)(x) * 0.015625f) | 65 #define SkFDot6ToScalar(x) ((SkScalar)(x) * 0.015625f) |
66 | 66 |
67 inline SkFixed SkFDot6Div(SkFDot6 a, SkFDot6 b) { | 67 inline SkFixed SkFDot6Div(SkFDot6 a, SkFDot6 b) { |
68 SkASSERT(b != 0); | 68 SkASSERT(b != 0); |
69 | 69 |
70 if (a == (int16_t)a) { | 70 if (a == (int16_t)a) { |
71 return (a << 16) / b; | 71 return SkLeftShift(a, 16) / b; |
72 } else { | 72 } else { |
73 return SkFixedDiv(a, b); | 73 return SkFixedDiv(a, b); |
74 } | 74 } |
75 } | 75 } |
76 | 76 |
77 #endif | 77 #endif |
OLD | NEW |