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
diff --git a/libs/hwui/ShadowTessellator.h b/libs/hwui/ShadowTessellator.h
index 05370dd..64e69bc 100644
--- a/libs/hwui/ShadowTessellator.h
+++ b/libs/hwui/ShadowTessellator.h
@@ -80,6 +80,27 @@
static void generateShadowIndices(uint16_t* shadowIndices);
static Vector2 centroid2d(const Vector2* poly, int polyLength);
+
+ static bool isClockwise(const Vector2* polygon, int len);
+
+ /**
+ * Determine whether the path is clockwise, using the control points.
+ *
+ * TODO: Given the skia is using inverted Y coordinate, shadow system needs
+ * to convert to the same coordinate to avoid the extra reverse.
+ *
+ * @param path The path to be examined.
+ */
+ static bool isClockwisePath(const SkPath &path);
+
+ /**
+ * Reverse the vertex array.
+ *
+ * @param polygon The vertex array to be reversed.
+ * @param len The length of the vertex array.
+ */
+ static void reverseVertexArray(Vertex* polygon, int len);
+
}; // ShadowTessellator
}; // namespace uirenderer