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 Sk64_DEFINED | 10 #ifndef Sk64_DEFINED |
11 #define Sk64_DEFINED | 11 #define Sk64_DEFINED |
12 | 12 |
13 #include "SkTypes.h" | 13 #include "SkTypes.h" |
14 | 14 |
15 /** \class Sk64 | 15 /** \class Sk64 |
16 | 16 |
17 Sk64 is a 64-bit math package that does not require long long support from t
he compiler. | 17 Sk64 is a 64-bit math package that does not require long long support from t
he compiler. |
18 */ | 18 */ |
19 struct SK_API Sk64 { | 19 struct SK_API Sk64 { |
20 private: | |
21 int32_t fHi; //!< the high 32 bits of the number (including sign) | 20 int32_t fHi; //!< the high 32 bits of the number (including sign) |
22 uint32_t fLo; //!< the low 32 bits of the number | 21 uint32_t fLo; //!< the low 32 bits of the number |
23 | 22 |
24 public: | |
25 int32_t hi() const { return fHi; } | |
26 uint32_t lo() const { return fLo; } | |
27 | |
28 int64_t as64() const { return ((int64_t)fHi << 32) | fLo; } | |
29 int64_t getLongLong() const { return this->as64(); } | |
30 | |
31 /** Returns non-zero if the Sk64 can be represented as a signed 32 bit integ
er | 23 /** Returns non-zero if the Sk64 can be represented as a signed 32 bit integ
er |
32 */ | 24 */ |
33 SkBool is32() const { return fHi == ((int32_t)fLo >> 31); } | 25 SkBool is32() const { return fHi == ((int32_t)fLo >> 31); } |
34 | 26 |
35 /** Returns non-zero if the Sk64 cannot be represented as a signed 32 bit in
teger | 27 /** Returns non-zero if the Sk64 cannot be represented as a signed 32 bit in
teger |
36 */ | 28 */ |
37 SkBool is64() const { return fHi != ((int32_t)fLo >> 31); } | 29 SkBool is64() const { return fHi != ((int32_t)fLo >> 31); } |
38 | 30 |
39 /** Return the signed 32 bit integer equivalent. Asserts that is32() returns
non-zero. | 31 /** Return the signed 32 bit integer equivalent. Asserts that is32() returns
non-zero. |
40 */ | 32 */ |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 } | 162 } |
171 | 163 |
172 friend bool operator>(const Sk64& a, const Sk64& b) { | 164 friend bool operator>(const Sk64& a, const Sk64& b) { |
173 return a.fHi > b.fHi || (a.fHi == b.fHi && a.fLo > b.fLo); | 165 return a.fHi > b.fHi || (a.fHi == b.fHi && a.fLo > b.fLo); |
174 } | 166 } |
175 | 167 |
176 friend bool operator>=(const Sk64& a, const Sk64& b) { | 168 friend bool operator>=(const Sk64& a, const Sk64& b) { |
177 return a.fHi > b.fHi || (a.fHi == b.fHi && a.fLo >= b.fLo); | 169 return a.fHi > b.fHi || (a.fHi == b.fHi && a.fLo >= b.fLo); |
178 } | 170 } |
179 | 171 |
180 // Private to unittests. Parameter is (skiatest::Reporter*) | 172 #ifdef SkLONGLONG |
181 static void UnitTestWithReporter(void* skiatest_reporter); | 173 SkLONGLONG getLongLong() const; |
| 174 #endif |
182 }; | 175 }; |
183 | 176 |
184 #endif | 177 #endif |
OLD | NEW |