summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Tenghui Zhu <ztenghui@google.com> 2015-06-25 21:07:12 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2015-06-25 21:07:14 +0000
commit78db19c25a3a18d9ccf19b91be17e791e4fd782c (patch)
tree47e0b4560005e13735f47749ae516010c2c93bcd
parentfdb70dc4346f801673aa700f3fca2b8cc77b809c (diff)
parentb561f39d01c211425bfefaaa7b31ebe097e7ba79 (diff)
Merge "Limit dotProduct value to 1.0f, so acosf would not return NaN."
-rw-r--r--libs/hwui/ShadowTessellator.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/libs/hwui/ShadowTessellator.cpp b/libs/hwui/ShadowTessellator.cpp
index 93d4b317f03b..c1b0f7ff2365 100644
--- a/libs/hwui/ShadowTessellator.cpp
+++ b/libs/hwui/ShadowTessellator.cpp
@@ -20,6 +20,7 @@
#include <math.h>
#include <utils/Log.h>
#include <utils/Trace.h>
+#include <utils/MathUtils.h>
#include "AmbientShadow.h"
#include "Caches.h"
@@ -264,6 +265,8 @@ int ShadowTessellator::getExtraVertexNumber(const Vector2& vector1,
// acos( ) --- [0, M_PI]
// floor(...) --- [0, EXTRA_VERTEX_PER_PI]
float dotProduct = vector1.dot(vector2);
+ // make sure that dotProduct value is in acsof input range [-1, 1]
+ dotProduct = MathUtils::clamp(dotProduct, -1.0f, 1.0f);
// TODO: Use look up table for the dotProduct to extraVerticesNumber
// computation, if needed.
float angle = acosf(dotProduct);