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 |
11 #include "SkTypes.h" | 11 #include "SkTypes.h" |
12 | 12 |
13 /** \file SkFixed.h | 13 /** \file SkFixed.h |
14 | 14 |
15 Types and macros for 16.16 fixed point | 15 Types and macros for 16.16 fixed point |
16 */ | 16 */ |
17 | 17 |
18 /** 32 bit signed integer used to represent fractions values with 16 bits to the
right of the decimal point | 18 /** 32 bit signed integer used to represent fractions values with 16 bits to the
right of the decimal point |
19 */ | 19 */ |
20 typedef int32_t SkFixed; | 20 typedef int32_t SkFixed; |
21 #define SK_Fixed1 (1 << 16) | 21 #define SK_Fixed1 (1 << 16) |
22 #define SK_FixedHalf (1 << 15) | 22 #define SK_FixedHalf (1 << 15) |
23 #define SK_FixedMax (0x7FFFFFFF) | 23 #define SK_FixedMax (0x7FFFFFFF) |
24 #define SK_FixedMin (-SK_FixedMax) | 24 #define SK_FixedMin (-SK_FixedMax) |
25 #define SK_FixedNaN ((int) 0x80000000) | |
26 #define SK_FixedPI (0x3243F) | 25 #define SK_FixedPI (0x3243F) |
27 #define SK_FixedSqrt2 (92682) | 26 #define SK_FixedSqrt2 (92682) |
28 #define SK_FixedTanPIOver8 (0x6A0A) | 27 #define SK_FixedTanPIOver8 (0x6A0A) |
29 #define SK_FixedRoot2Over2 (0xB505) | 28 #define SK_FixedRoot2Over2 (0xB505) |
30 | 29 |
31 #define SkFixedToFloat(x) ((x) * 1.52587890625e-5f) | 30 #define SkFixedToFloat(x) ((x) * 1.52587890625e-5f) |
32 #if 1 | 31 #if 1 |
33 #define SkFloatToFixed(x) ((SkFixed)((x) * SK_Fixed1)) | 32 #define SkFloatToFixed(x) ((SkFixed)((x) * SK_Fixed1)) |
34 #else | 33 #else |
35 // pins over/under flows to max/min int32 (slower than just a cast) | 34 // pins over/under flows to max/min int32 (slower than just a cast) |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 #define Sk48Dot16FloorToInt(x) static_cast<int>((x) >> 16) | 161 #define Sk48Dot16FloorToInt(x) static_cast<int>((x) >> 16) |
163 | 162 |
164 static inline float Sk48Dot16ToScalar(Sk48Dot16 x) { | 163 static inline float Sk48Dot16ToScalar(Sk48Dot16 x) { |
165 return static_cast<float>(x * 1.5258789e-5); // x * (1.0f / (1 << 16)) | 164 return static_cast<float>(x * 1.5258789e-5); // x * (1.0f / (1 << 16)) |
166 } | 165 } |
167 #define SkFloatTo48Dot16(x) (static_cast<Sk48Dot16>((x) * (1 << 16))) | 166 #define SkFloatTo48Dot16(x) (static_cast<Sk48Dot16>((x) * (1 << 16))) |
168 | 167 |
169 #define SkScalarTo48Dot16(x) SkFloatTo48Dot16(x) | 168 #define SkScalarTo48Dot16(x) SkFloatTo48Dot16(x) |
170 | 169 |
171 #endif | 170 #endif |
OLD | NEW |