| OLD | NEW |
| 1 | |
| 2 /* | 1 /* |
| 3 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
| 4 * | 3 * |
| 5 * 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 |
| 6 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 7 */ | 6 */ |
| 8 | 7 |
| 9 | |
| 10 #ifndef Sk64_DEFINED | 8 #ifndef Sk64_DEFINED |
| 11 #define Sk64_DEFINED | 9 #define Sk64_DEFINED |
| 12 | 10 |
| 13 #include "SkTypes.h" | 11 #include "SkTypes.h" |
| 14 | 12 |
| 15 /** \class Sk64 | 13 /** \class Sk64 |
| 16 | 14 |
| 17 Sk64 is a 64-bit math package that does not require long long support from t
he compiler. | 15 Sk64 is a 64-bit math package that does not require long long support from t
he compiler. |
| 18 */ | 16 */ |
| 19 struct SK_API Sk64 { | 17 struct SK_API Sk64 { |
| 20 private: | 18 private: |
| 21 int32_t fHi; //!< the high 32 bits of the number (including sign) | 19 int32_t fHi; //!< the high 32 bits of the number (including sign) |
| 22 uint32_t fLo; //!< the low 32 bits of the number | 20 uint32_t fLo; //!< the low 32 bits of the number |
| 23 | 21 |
| 24 public: | 22 public: |
| 25 int32_t hi() const { return fHi; } | 23 int32_t hi() const { return fHi; } |
| 26 uint32_t lo() const { return fLo; } | 24 uint32_t lo() const { return fLo; } |
| 27 | 25 |
| 28 int64_t as64() const { return ((int64_t)fHi << 32) | fLo; } | 26 int64_t as64() const { return ((int64_t)fHi << 32) | fLo; } |
| 29 int64_t getLongLong() const { return this->as64(); } | 27 int64_t getLongLong() const { return this->as64(); } |
| 30 | 28 |
| 29 void set64(int64_t value) { |
| 30 fHi = (int32_t)(value >> 32); |
| 31 fLo = (uint32_t)value; |
| 32 } |
| 33 |
| 31 /** Returns non-zero if the Sk64 can be represented as a signed 32 bit integ
er | 34 /** Returns non-zero if the Sk64 can be represented as a signed 32 bit integ
er |
| 32 */ | 35 */ |
| 33 SkBool is32() const { return fHi == ((int32_t)fLo >> 31); } | 36 SkBool is32() const { return fHi == ((int32_t)fLo >> 31); } |
| 34 | 37 |
| 35 /** Returns non-zero if the Sk64 cannot be represented as a signed 32 bit in
teger | 38 /** Returns non-zero if the Sk64 cannot be represented as a signed 32 bit in
teger |
| 36 */ | 39 */ |
| 37 SkBool is64() const { return fHi != ((int32_t)fLo >> 31); } | 40 SkBool is64() const { return fHi != ((int32_t)fLo >> 31); } |
| 38 | 41 |
| 39 /** Return the signed 32 bit integer equivalent. Asserts that is32() returns
non-zero. | 42 /** Return the signed 32 bit integer equivalent. Asserts that is32() returns
non-zero. |
| 40 */ | 43 */ |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 | 178 |
| 176 friend bool operator>=(const Sk64& a, const Sk64& b) { | 179 friend bool operator>=(const Sk64& a, const Sk64& b) { |
| 177 return a.fHi > b.fHi || (a.fHi == b.fHi && a.fLo >= b.fLo); | 180 return a.fHi > b.fHi || (a.fHi == b.fHi && a.fLo >= b.fLo); |
| 178 } | 181 } |
| 179 | 182 |
| 180 // Private to unittests. Parameter is (skiatest::Reporter*) | 183 // Private to unittests. Parameter is (skiatest::Reporter*) |
| 181 static void UnitTestWithReporter(void* skiatest_reporter); | 184 static void UnitTestWithReporter(void* skiatest_reporter); |
| 182 }; | 185 }; |
| 183 | 186 |
| 184 #endif | 187 #endif |
| OLD | NEW |