summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Pablo Ceballos <pceballos@google.com> 2016-03-09 17:19:22 -0800
committer Pablo Ceballos <pceballos@google.com> 2016-03-09 17:19:22 -0800
commit19d72c06ac2bc2f57609a4eed3b228f1b4efae8a (patch)
tree2106cd0624ed09c1deb367c4614ac45057db0014
parent99dccfc3ec4b304d1ee3497ecbcc3322a84cf606 (diff)
ui: Fix Rect::reduce
- Properly handle the case where the Rect to be excluded is completely outside the other Rect. Bug 27415039 Change-Id: I3331d5b3ab231d023348079c781b194d24ac37dd
-rw-r--r--libs/ui/Rect.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/libs/ui/Rect.cpp b/libs/ui/Rect.cpp
index 99cbedc2ff..d8702e5755 100644
--- a/libs/ui/Rect.cpp
+++ b/libs/ui/Rect.cpp
@@ -127,13 +127,13 @@ Rect Rect::reduce(const Rect& exclude) const {
if (!(mask & (mask - 1))) {
// power-of-2, i.e.: just one bit is set
if (mask & 1) {
- result.right = exclude.left;
+ result.right = min(result.right, exclude.left);
} else if (mask & 2) {
- result.bottom = exclude.top;
+ result.bottom = min(result.bottom, exclude.top);
} else if (mask & 4) {
- result.left = exclude.right;
+ result.left = max(result.left, exclude.right);
} else if (mask & 8) {
- result.top = exclude.bottom;
+ result.top = max(result.top, exclude.bottom);
}
}
}