diff options
author | Mike Reed <reed@google.com> | 2018-02-13 12:48:57 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-02-13 18:14:20 +0000 |
commit | 655bf8f022a31b8a8624838d267b0e9cab0d8ef8 (patch) | |
tree | 51dadae4ad48b7dc3ab605342989ab70aaf103ac /include/core/SkRect.h | |
parent | 0c6ea6c77ad39042759d781e65e3474ebc4ff7ee (diff) |
saturate IPoint math, handle NaN in isEmpty
Bug: skia:7507
Change-Id: Ibdb40584effdea70e6499eab1bb64bb4b2260d06
Reviewed-on: https://skia-review.googlesource.com/106972
Commit-Queue: Mike Reed <reed@google.com>
Commit-Queue: Mike Klein <mtklein@chromium.org>
Reviewed-by: Mike Klein <mtklein@chromium.org>
Diffstat (limited to 'include/core/SkRect.h')
-rw-r--r-- | include/core/SkRect.h | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/include/core/SkRect.h b/include/core/SkRect.h index 5673980d49..ff7715853a 100644 --- a/include/core/SkRect.h +++ b/include/core/SkRect.h @@ -849,12 +849,18 @@ struct SK_API SkRect { } /** Returns true if fLeft is equal to or greater than fRight, or if fTop is equal - to or greater than fBottom. Call sort() to reverse rectangles with negative - width() or height(). - - @return true if width() or height() are zero or negative - */ - bool isEmpty() const { return fLeft >= fRight || fTop >= fBottom; } + * to or greater than fBottom. Call sort() to reverse rectangles with negative + * width() or height(). + * + * This function also returns true if any of the values are NaN. + * + * @return true if width() or height() are zero or negative + */ + bool isEmpty() const { + // We write it as the NOT of a non-empty rect, so we will return true if any values + // are NaN. + return !(fLeft < fRight && fTop < fBottom); + } /** Returns true if fLeft is equal to or less than fRight, or if fTop is equal to or less than fBottom. Call sort() to reverse rectangles with negative |