diff options
author | Rodrigo Locatti <reinuseslisp@airmail.cc> | 2020-03-09 22:34:37 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-09 22:34:37 +0100 |
commit | 22e825a3bc0d9bfb5f8c29a50724c2887014dc02 (patch) | |
tree | d68f0ace93ba44292e3017dcb219f3132b3314ef /src/common | |
parent | Merge pull request #3486 from ReinUsesLisp/fix-anisotropy-hack (diff) | |
parent | video_core/dirty_flags: Address feedback (diff) | |
download | yuzu-22e825a3bc0d9bfb5f8c29a50724c2887014dc02.tar yuzu-22e825a3bc0d9bfb5f8c29a50724c2887014dc02.tar.gz yuzu-22e825a3bc0d9bfb5f8c29a50724c2887014dc02.tar.bz2 yuzu-22e825a3bc0d9bfb5f8c29a50724c2887014dc02.tar.lz yuzu-22e825a3bc0d9bfb5f8c29a50724c2887014dc02.tar.xz yuzu-22e825a3bc0d9bfb5f8c29a50724c2887014dc02.tar.zst yuzu-22e825a3bc0d9bfb5f8c29a50724c2887014dc02.zip |
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/math_util.h | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/common/math_util.h b/src/common/math_util.h index d6c35ee89..83ef0201f 100644 --- a/src/common/math_util.h +++ b/src/common/math_util.h @@ -24,17 +24,29 @@ struct Rectangle { : left(left), top(top), right(right), bottom(bottom) {} T GetWidth() const { - return std::abs(static_cast<std::make_signed_t<T>>(right - left)); + if constexpr (std::is_floating_point_v<T>) { + return std::abs(right - left); + } else { + return std::abs(static_cast<std::make_signed_t<T>>(right - left)); + } } + T GetHeight() const { - return std::abs(static_cast<std::make_signed_t<T>>(bottom - top)); + if constexpr (std::is_floating_point_v<T>) { + return std::abs(bottom - top); + } else { + return std::abs(static_cast<std::make_signed_t<T>>(bottom - top)); + } } + Rectangle<T> TranslateX(const T x) const { return Rectangle{left + x, top, right + x, bottom}; } + Rectangle<T> TranslateY(const T y) const { return Rectangle{left, top + y, right, bottom + y}; } + Rectangle<T> Scale(const float s) const { return Rectangle{left, top, static_cast<T>(left + GetWidth() * s), static_cast<T>(top + GetHeight() * s)}; |