summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTenghui Zhu <ztenghui@google.com>2015-06-25 21:45:31 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2015-06-25 21:45:32 +0000
commit5daee1dc27d7b0eadfddefcaf73da229579fd436 (patch)
treed4a0266b5958a240d241a38b778bfc79da45bad0
parentfd70942147edec7eb512c72c3fd0f89a3d7fa646 (diff)
parent1240752c44c21632adaf64f6768669ec6d0ebc8c (diff)
downloadframeworks_base-5daee1dc27d7b0eadfddefcaf73da229579fd436.zip
frameworks_base-5daee1dc27d7b0eadfddefcaf73da229579fd436.tar.gz
frameworks_base-5daee1dc27d7b0eadfddefcaf73da229579fd436.tar.bz2
Merge "Limit dotProduct value to 1.0f, so acosf would not return NaN." into mnc-dev
-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 024ff10..09d1258 100644
--- a/libs/hwui/ShadowTessellator.cpp
+++ b/libs/hwui/ShadowTessellator.cpp
@@ -21,6 +21,7 @@
#include <utils/Log.h>
#include <utils/Trace.h>
#include <utils/Vector.h>
+#include <utils/MathUtils.h>
#include "AmbientShadow.h"
#include "Properties.h"
@@ -172,6 +173,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);