diff options
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 630b6c0887..a82f2ecefe 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 |