summaryrefslogtreecommitdiff
path: root/libs/hwui/SpotShadow.cpp
diff options
context:
space:
mode:
author ztenghui <ztenghui@google.com> 2014-04-28 16:43:13 -0700
committer ztenghui <ztenghui@google.com> 2014-04-28 16:43:13 -0700
commit2e023f3827dfc0dfc1ed7c3dd54d02b4a993f0b4 (patch)
treeba319249cf92343e7d7488480a9646a235566ef9 /libs/hwui/SpotShadow.cpp
parent7940dc57e3ffcf9c4a33375215f3a42250fa896c (diff)
Make sure the theta is correctly represented and incoming polygon is CW for shadow.
Now the theta = 0 should be on +x axis. And cos(theta) should correctly represent x value. Without this fix, the poly theta (from atan2) can be wrongly rotated 90 degrees. Also, make sure the incoming polygon is CW for the shadow system. This fix visual artifacts in recent regression for spot shadows. bug:13553955 Change-Id: I9bbf54db094e7f133326da4dae4610962da849c1
Diffstat (limited to 'libs/hwui/SpotShadow.cpp')
-rw-r--r--libs/hwui/SpotShadow.cpp27
1 files changed, 3 insertions, 24 deletions
diff --git a/libs/hwui/SpotShadow.cpp b/libs/hwui/SpotShadow.cpp
index 5fa0ba59efac..3ebe7b4f34e7 100644
--- a/libs/hwui/SpotShadow.cpp
+++ b/libs/hwui/SpotShadow.cpp
@@ -174,10 +174,10 @@ bool SpotShadow::ccw(double ax, double ay, double bx, double by,
int SpotShadow::intersection(const Vector2* poly1, int poly1Length,
Vector2* poly2, int poly2Length) {
#if DEBUG_SHADOW
- if (!isClockwise(poly1, poly1Length)) {
+ if (!ShadowTessellator::isClockwise(poly1, poly1Length)) {
ALOGW("Poly1 is not clockwise! Intersection is wrong!");
}
- if (!isClockwise(poly2, poly2Length)) {
+ if (!ShadowTessellator::isClockwise(poly2, poly2Length)) {
ALOGW("Poly2 is not clockwise! Intersection is wrong!");
}
#endif
@@ -407,33 +407,12 @@ void SpotShadow::makeClockwise(Vector2* polygon, int len) {
if (polygon == 0 || len == 0) {
return;
}
- if (!isClockwise(polygon, len)) {
+ if (!ShadowTessellator::isClockwise(polygon, len)) {
reverse(polygon, len);
}
}
/**
- * Test whether the polygon is order in clockwise.
- *
- * @param polygon the polygon as a Vector2 array
- * @param len the number of points of the polygon
- */
-bool SpotShadow::isClockwise(const Vector2* polygon, int len) {
- double sum = 0;
- double p1x = polygon[len - 1].x;
- double p1y = polygon[len - 1].y;
- for (int i = 0; i < len; i++) {
-
- double p2x = polygon[i].x;
- double p2y = polygon[i].y;
- sum += p1x * p2y - p2x * p1y;
- p1x = p2x;
- p1y = p2y;
- }
- return sum < 0;
-}
-
-/**
* Reverse the polygon
*
* @param polygon the polygon as a Vector2 array