summaryrefslogtreecommitdiffstats
path: root/libs/ui
diff options
context:
space:
mode:
authorMichael Wright <michaelwr@google.com>2014-02-10 13:00:14 -0800
committerMichael Wright <michaelwr@google.com>2014-02-10 13:00:14 -0800
commit1c284a9431f98bbefd27a30c3368bbf7366dff3a (patch)
treecc57db9d4963929f36eff25c5312675bd9762ceb /libs/ui
parent835f5df6cc83471a909a2ebc0311fe29778a6b8f (diff)
downloadframeworks_native-1c284a9431f98bbefd27a30c3368bbf7366dff3a.zip
frameworks_native-1c284a9431f98bbefd27a30c3368bbf7366dff3a.tar.gz
frameworks_native-1c284a9431f98bbefd27a30c3368bbf7366dff3a.tar.bz2
Add contains point method to Region
Change-Id: I553433ff7ac39f14ffca8278960d2abc95b4dd63
Diffstat (limited to 'libs/ui')
-rw-r--r--libs/ui/Region.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/libs/ui/Region.cpp b/libs/ui/Region.cpp
index e5abcf5..7de48a4 100644
--- a/libs/ui/Region.cpp
+++ b/libs/ui/Region.cpp
@@ -221,6 +221,22 @@ Region& Region::makeBoundsSelf()
return *this;
}
+bool Region::contains(const Point& point) const {
+ return contains(point.x, point.y);
+}
+
+bool Region::contains(int x, int y) const {
+ const_iterator cur = begin();
+ const_iterator const tail = end();
+ while (cur != tail) {
+ if (y >= cur->top && y < cur->bottom && x >= cur->left && x < cur->right) {
+ return true;
+ }
+ cur++;
+ }
+ return false;
+}
+
void Region::clear()
{
mStorage.clear();