am 91d01e5d: am 0cec5293: am d7580333: Merge "Use std::sort instead of quickSortX" into mnc-dev
* commit '91d01e5d8b9a50ad04f0d0b5d6e35885f5d878a3':
Use std::sort instead of quickSortX
diff --git a/libs/hwui/SpotShadow.cpp b/libs/hwui/SpotShadow.cpp
index db3c2d9..b8c9804 100644
--- a/libs/hwui/SpotShadow.cpp
+++ b/libs/hwui/SpotShadow.cpp
@@ -48,6 +48,7 @@
#define TRANSFORMED_PENUMBRA_ALPHA 1.0f
#define TRANSFORMED_UMBRA_ALPHA 0.0f
+#include <algorithm>
#include <math.h>
#include <stdlib.h>
#include <utils/Log.h>
@@ -145,7 +146,10 @@
* @param pointsLength the number of vertices of the polygon.
*/
void SpotShadow::xsort(Vector2* points, int pointsLength) {
- quicksortX(points, 0, pointsLength - 1);
+ auto cmp = [](const Vector2& a, const Vector2& b) -> bool {
+ return a.x < b.x;
+ };
+ std::sort(points, points + pointsLength, cmp);
}
/**
@@ -273,35 +277,6 @@
}
/**
- * Sort points by x axis
- *
- * @param points points to sort
- * @param low start index
- * @param high end index
- */
-void SpotShadow::quicksortX(Vector2* points, int low, int high) {
- int i = low, j = high;
- int p = low + (high - low) / 2;
- float pivot = points[p].x;
- while (i <= j) {
- while (points[i].x < pivot) {
- i++;
- }
- while (points[j].x > pivot) {
- j--;
- }
-
- if (i <= j) {
- swap(points, i, j);
- i++;
- j--;
- }
- }
- if (low < j) quicksortX(points, low, j);
- if (i < high) quicksortX(points, i, high);
-}
-
-/**
* Test whether a point is inside the polygon.
*
* @param testPoint the point to test