diff options
Diffstat (limited to 'libs/ui')
| -rw-r--r-- | libs/ui/include/ui/FloatRect.h | 2 | ||||
| -rw-r--r-- | libs/ui/include/ui/StretchEffect.h | 3 |
2 files changed, 4 insertions, 1 deletions
diff --git a/libs/ui/include/ui/FloatRect.h b/libs/ui/include/ui/FloatRect.h index bec2552fde..5d329ea6a9 100644 --- a/libs/ui/include/ui/FloatRect.h +++ b/libs/ui/include/ui/FloatRect.h @@ -48,6 +48,8 @@ public: float top = 0.0f; float right = 0.0f; float bottom = 0.0f; + + constexpr bool isEmpty() const { return !(left < right && top < bottom); } }; inline bool operator==(const FloatRect& a, const FloatRect& b) { diff --git a/libs/ui/include/ui/StretchEffect.h b/libs/ui/include/ui/StretchEffect.h index 1d2460ccfc..0803df3828 100644 --- a/libs/ui/include/ui/StretchEffect.h +++ b/libs/ui/include/ui/StretchEffect.h @@ -19,6 +19,7 @@ #include <utils/Flattenable.h> #include "FloatRect.h" +#include <math.h> #include <type_traits> namespace android { @@ -45,7 +46,7 @@ struct StretchEffect : public LightFlattenablePod<StretchEffect> { void sanitize() { // If the area is empty, or the max amount is zero, then reset back to defaults - if (area.bottom >= area.top || area.left >= area.right || isZero(maxAmount)) { + if (area.isEmpty() || isZero(maxAmount)) { *this = StretchEffect{}; } } |