| 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: |
| 20 int32_t fHi; //!< the high 32 bits of the number (including sign) | 21 int32_t fHi; //!< the high 32 bits of the number (including sign) |
| 21 uint32_t fLo; //!< the low 32 bits of the number | 22 uint32_t fLo; //!< the low 32 bits of the number |
| 22 | 23 |
| 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 |
| 23 /** Returns non-zero if the Sk64 can be represented as a signed 32 bit integ
er | 31 /** Returns non-zero if the Sk64 can be represented as a signed 32 bit integ
er |
| 24 */ | 32 */ |
| 25 SkBool is32() const { return fHi == ((int32_t)fLo >> 31); } | 33 SkBool is32() const { return fHi == ((int32_t)fLo >> 31); } |
| 26 | 34 |
| 27 /** Returns non-zero if the Sk64 cannot be represented as a signed 32 bit in
teger | 35 /** Returns non-zero if the Sk64 cannot be represented as a signed 32 bit in
teger |
| 28 */ | 36 */ |
| 29 SkBool is64() const { return fHi != ((int32_t)fLo >> 31); } | 37 SkBool is64() const { return fHi != ((int32_t)fLo >> 31); } |
| 30 | 38 |
| 31 /** Return the signed 32 bit integer equivalent. Asserts that is32() returns
non-zero. | 39 /** Return the signed 32 bit integer equivalent. Asserts that is32() returns
non-zero. |
| 32 */ | 40 */ |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 } | 170 } |
| 163 | 171 |
| 164 friend bool operator>(const Sk64& a, const Sk64& b) { | 172 friend bool operator>(const Sk64& a, const Sk64& b) { |
| 165 return a.fHi > b.fHi || (a.fHi == b.fHi && a.fLo > b.fLo); | 173 return a.fHi > b.fHi || (a.fHi == b.fHi && a.fLo > b.fLo); |
| 166 } | 174 } |
| 167 | 175 |
| 168 friend bool operator>=(const Sk64& a, const Sk64& b) { | 176 friend bool operator>=(const Sk64& a, const Sk64& b) { |
| 169 return a.fHi > b.fHi || (a.fHi == b.fHi && a.fLo >= b.fLo); | 177 return a.fHi > b.fHi || (a.fHi == b.fHi && a.fLo >= b.fLo); |
| 170 } | 178 } |
| 171 | 179 |
| 172 #ifdef SkLONGLONG | 180 // Private to unittests. Parameter is (skiatest::Reporter*) |
| 173 SkLONGLONG getLongLong() const; | 181 static void UnitTestWithReporter(void* skiatest_reporter); |
| 174 #endif | |
| 175 }; | 182 }; |
| 176 | 183 |
| 177 #endif | 184 #endif |
| OLD | NEW |