diff options
author | wolfbeast <mcwerewolf@gmail.com> | 2018-07-11 23:29:50 +0200 |
---|---|---|
committer | wolfbeast <mcwerewolf@gmail.com> | 2018-07-11 23:31:02 +0200 |
commit | 70dd5e7c66b1fe3f82e5b4db2406050baba15f05 (patch) | |
tree | 3f012200ef3c934f33db1a4ef2b790fae3141860 /gfx/angle/src/common/mathutil.h | |
parent | 3b7ffb477eec078c7036c92c6a51bb5de6de4f28 (diff) | |
parent | 8481fa25d246f1968d0a254ee3c6cdd82c60781a (diff) | |
download | UXP-70dd5e7c66b1fe3f82e5b4db2406050baba15f05.tar UXP-70dd5e7c66b1fe3f82e5b4db2406050baba15f05.tar.gz UXP-70dd5e7c66b1fe3f82e5b4db2406050baba15f05.tar.lz UXP-70dd5e7c66b1fe3f82e5b4db2406050baba15f05.tar.xz UXP-70dd5e7c66b1fe3f82e5b4db2406050baba15f05.zip |
Merge branch 'ANGLE-rollback'
This resolves #624
Note: Cherry-picked some fixes on top of the ANGLE version that we want to keep.
Diffstat (limited to 'gfx/angle/src/common/mathutil.h')
-rwxr-xr-x | gfx/angle/src/common/mathutil.h | 43 |
1 files changed, 0 insertions, 43 deletions
diff --git a/gfx/angle/src/common/mathutil.h b/gfx/angle/src/common/mathutil.h index 630b6c088..a82f2ecef 100755 --- a/gfx/angle/src/common/mathutil.h +++ b/gfx/angle/src/common/mathutil.h @@ -44,15 +44,6 @@ struct Vector4 float w; }; -struct Vector2 -{ - Vector2() {} - Vector2(float x, float y) : x(x), y(y) {} - - float x; - float y; -}; - inline bool isPow2(int x) { return (x & (x - 1)) == 0 && (x != 0); @@ -765,40 +756,6 @@ constexpr unsigned int iSquareRoot() return priv::iSquareRoot<N, 1>::value; } -// Sum, difference and multiplication operations for signed ints that wrap on 32-bit overflow. -// -// Unsigned types are defined to do arithmetic modulo 2^n in C++. For signed types, overflow -// behavior is undefined. - -template <typename T> -inline T WrappingSum(T lhs, T rhs) -{ - uint32_t lhsUnsigned = static_cast<uint32_t>(lhs); - uint32_t rhsUnsigned = static_cast<uint32_t>(rhs); - return static_cast<T>(lhsUnsigned + rhsUnsigned); -} - -template <typename T> -inline T WrappingDiff(T lhs, T rhs) -{ - uint32_t lhsUnsigned = static_cast<uint32_t>(lhs); - uint32_t rhsUnsigned = static_cast<uint32_t>(rhs); - return static_cast<T>(lhsUnsigned - rhsUnsigned); -} - -inline int32_t WrappingMul(int32_t lhs, int32_t rhs) -{ - int64_t lhsWide = static_cast<int64_t>(lhs); - int64_t rhsWide = static_cast<int64_t>(rhs); - // The multiplication is guaranteed not to overflow. - int64_t resultWide = lhsWide * rhsWide; - // Implement the desired wrapping behavior by masking out the high-order 32 bits. - resultWide = resultWide & 0xffffffffll; - // Casting to a narrower signed type is fine since the casted value is representable in the - // narrower type. - return static_cast<int32_t>(resultWide); -} - } // namespace gl namespace rx |