aboutsummaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorGravatar Jim Van Verth <jvanverth@google.com>2018-02-26 13:54:34 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-02-26 20:02:38 +0000
commita947e29bfda69618723341f3487076c3256cfffc (patch)
tree65117ad34586c4e246ccc65dd7c7aa37ac7a9b06 /include
parent1693d43f37ee17d647eccc3533ceb695aef1e338 (diff)
Add some additional checks for shadow generation
Change-Id: I4dae4173ad879827e4e1fa3ad12aa0447d1df252 Reviewed-on: https://skia-review.googlesource.com/110360 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Jim Van Verth <jvanverth@google.com>
Diffstat (limited to 'include')
-rw-r--r--include/core/SkPoint3.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/include/core/SkPoint3.h b/include/core/SkPoint3.h
index d4a2023082..41206f33b1 100644
--- a/include/core/SkPoint3.h
+++ b/include/core/SkPoint3.h
@@ -107,6 +107,24 @@ struct SK_API SkPoint3 {
fZ -= v.fZ;
}
+ /** Returns true if fX, fY, and fZ are measurable values.
+
+ @return true for values other than infinities and NaN
+ */
+ bool isFinite() const {
+ SkScalar accum = 0;
+ accum *= fX;
+ accum *= fY;
+ accum *= fZ;
+
+ // accum is either NaN or it is finite (zero).
+ SkASSERT(0 == accum || SkScalarIsNaN(accum));
+
+ // value==value will be true iff value is not NaN
+ // TODO: is it faster to say !accum or accum==accum?
+ return !SkScalarIsNaN(accum);
+ }
+
/** Returns the dot product of a and b, treating them as 3D vectors
*/
static SkScalar DotProduct(const SkPoint3& a, const SkPoint3& b) {