aboutsummaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorGravatar Florin Malita <fmalita@chromium.org>2018-02-20 11:44:43 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-02-20 17:57:53 +0000
commiteb420457fd80f1b449b1ba94d5fb740f6aa3103f (patch)
tree3fd5dbee296fda65f2a7bc1352b168eb8cce1a0b /include
parent535ba8d2b862a364f7f8009d6e79cd41519f5643 (diff)
Add SkRect::contains(SkScalar x, SkScalar y)
Similar to its SkIRect counterpart. Change-Id: I6872694d8602ed4181a1a15b4cd1c2c32aeab3f9 Reviewed-on: https://skia-review.googlesource.com/108506 Reviewed-by: Cary Clark <caryclark@google.com> Reviewed-by: Florin Malita <fmalita@chromium.org> Commit-Queue: Florin Malita <fmalita@chromium.org>
Diffstat (limited to 'include')
-rw-r--r--include/core/SkRect.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/include/core/SkRect.h b/include/core/SkRect.h
index ff7715853a..7f1eff0690 100644
--- a/include/core/SkRect.h
+++ b/include/core/SkRect.h
@@ -1423,6 +1423,17 @@ public:
fBottom = SkMaxScalar(fBottom, r.bottom());
}
+ /** Returns true if: fLeft <= x < fRight && fTop <= y < fBottom.
+ Returns false if SkRect is empty.
+
+ @param x test SkPoint x-coordinate
+ @param y test SkPoint y-coordinate
+ @return true if (x, y) is inside SkRect
+ */
+ bool contains(SkScalar x, SkScalar y) const {
+ return x >= fLeft && x < fRight && y >= fTop && y < fBottom;
+ }
+
/** Returns true if SkRect contains r.
Returns false if SkRect is empty or r is empty.