Replace most usages of utils/Vector.h
Change-Id: I540d1b3523244d6c71fc52d6fb30555271c25644
diff --git a/libs/hwui/PathTessellator.cpp b/libs/hwui/PathTessellator.cpp
index 5294be8..8fa187c 100644
--- a/libs/hwui/PathTessellator.cpp
+++ b/libs/hwui/PathTessellator.cpp
@@ -177,7 +177,8 @@
}
};
-void getFillVerticesFromPerimeter(const Vector<Vertex>& perimeter, VertexBuffer& vertexBuffer) {
+void getFillVerticesFromPerimeter(const std::vector<Vertex>& perimeter,
+ VertexBuffer& vertexBuffer) {
Vertex* buffer = vertexBuffer.alloc<Vertex>(perimeter.size());
int currentIndex = 0;
@@ -201,8 +202,8 @@
* Uses an additional 2 vertices at the end to wrap around, closing the tri-strip
* (for a total of perimeter.size() * 2 + 2 vertices)
*/
-void getStrokeVerticesFromPerimeter(const PaintInfo& paintInfo, const Vector<Vertex>& perimeter,
- VertexBuffer& vertexBuffer) {
+void getStrokeVerticesFromPerimeter(const PaintInfo& paintInfo,
+ const std::vector<Vertex>& perimeter, VertexBuffer& vertexBuffer) {
Vertex* buffer = vertexBuffer.alloc<Vertex>(perimeter.size() * 2 + 2);
int currentIndex = 0;
@@ -260,7 +261,7 @@
* 2 - can zig-zag across 'extra' vertices at either end, to create round caps
*/
void getStrokeVerticesFromUnclosedVertices(const PaintInfo& paintInfo,
- const Vector<Vertex>& vertices, VertexBuffer& vertexBuffer) {
+ const std::vector<Vertex>& vertices, VertexBuffer& vertexBuffer) {
const int extra = paintInfo.capExtraDivisions();
const int allocSize = (vertices.size() + extra) * 2;
Vertex* buffer = vertexBuffer.alloc<Vertex>(allocSize);
@@ -339,8 +340,9 @@
*
* 3 - zig zag back and forth inside the shape to fill it (using perimeter.size() vertices)
*/
-void getFillVerticesFromPerimeterAA(const PaintInfo& paintInfo, const Vector<Vertex>& perimeter,
- VertexBuffer& vertexBuffer, float maxAlpha = 1.0f) {
+void getFillVerticesFromPerimeterAA(const PaintInfo& paintInfo,
+ const std::vector<Vertex>& perimeter, VertexBuffer& vertexBuffer,
+ float maxAlpha = 1.0f) {
AlphaVertex* buffer = vertexBuffer.alloc<AlphaVertex>(perimeter.size() * 3 + 2);
// generate alpha points - fill Alpha vertex gaps in between each point with
@@ -398,7 +400,7 @@
* For explanation of constants and general methodoloyg, see comments for
* getStrokeVerticesFromUnclosedVerticesAA() below.
*/
-inline static void storeCapAA(const PaintInfo& paintInfo, const Vector<Vertex>& vertices,
+inline static void storeCapAA(const PaintInfo& paintInfo, const std::vector<Vertex>& vertices,
AlphaVertex* buffer, bool isFirst, Vector2 normal, int offset) {
const int extra = paintInfo.capExtraDivisions();
const int extraOffset = (extra + 1) / 2;
@@ -423,8 +425,8 @@
}
// determine referencePoint, the center point for the 4 primary cap vertices
- const Vertex* point = isFirst ? vertices.begin() : (vertices.end() - 1);
- Vector2 referencePoint = {point->x, point->y};
+ const Vertex& point = isFirst ? vertices.front() : vertices.back();
+ Vector2 referencePoint = {point.x, point.y};
if (paintInfo.cap == SkPaint::kSquare_Cap) {
// To account for square cap, move the primary cap vertices (that create the AA edge) by the
// stroke offset vector (rotated to be parallel to the stroke)
@@ -569,7 +571,7 @@
= 2 + 6 * pts + 6 * roundDivs
*/
void getStrokeVerticesFromUnclosedVerticesAA(const PaintInfo& paintInfo,
- const Vector<Vertex>& vertices, VertexBuffer& vertexBuffer) {
+ const std::vector<Vertex>& vertices, VertexBuffer& vertexBuffer) {
const int extra = paintInfo.capExtraDivisions();
const int allocSize = 6 * vertices.size() + 2 + 6 * extra;
@@ -642,8 +644,8 @@
}
-void getStrokeVerticesFromPerimeterAA(const PaintInfo& paintInfo, const Vector<Vertex>& perimeter,
- VertexBuffer& vertexBuffer) {
+void getStrokeVerticesFromPerimeterAA(const PaintInfo& paintInfo,
+ const std::vector<Vertex>& perimeter, VertexBuffer& vertexBuffer) {
AlphaVertex* buffer = vertexBuffer.alloc<AlphaVertex>(6 * perimeter.size() + 8);
int offset = 2 * perimeter.size() + 3;
@@ -721,7 +723,7 @@
const PaintInfo paintInfo(paint, transform);
- Vector<Vertex> tempVertices;
+ std::vector<Vertex> tempVertices;
float threshInvScaleX = paintInfo.inverseScaleX;
float threshInvScaleY = paintInfo.inverseScaleY;
if (paintInfo.style == SkPaint::kStroke_Style) {
@@ -816,7 +818,7 @@
}
// calculate outline
- Vector<Vertex> outlineVertices;
+ std::vector<Vertex> outlineVertices;
PathApproximationInfo approximationInfo(paintInfo.inverseScaleX, paintInfo.inverseScaleY,
OUTLINE_REFINE_THRESHOLD);
approximatePathOutlineVertices(path, true, approximationInfo, outlineVertices);
@@ -858,10 +860,8 @@
vertexBuffer.alloc<Vertex>(numLines * lineAllocSize + (numLines - 1) * 2);
}
- Vector<Vertex> tempVertices;
- tempVertices.push();
- tempVertices.push();
- Vertex* tempVerticesData = tempVertices.editArray();
+ std::vector<Vertex> tempVertices(2);
+ Vertex* tempVerticesData = &tempVertices.front();
Rect bounds;
bounds.set(points[0], points[1], points[0], points[1]);
for (int i = 0; i < count; i += 4) {
@@ -897,18 +897,11 @@
///////////////////////////////////////////////////////////////////////////////
bool PathTessellator::approximatePathOutlineVertices(const SkPath& path, float threshold,
- Vector<Vertex>& outputVertices) {
+ std::vector<Vertex>& outputVertices) {
PathApproximationInfo approximationInfo(1.0f, 1.0f, threshold);
return approximatePathOutlineVertices(path, true, approximationInfo, outputVertices);
}
-void pushToVector(Vector<Vertex>& vertices, float x, float y) {
- // TODO: make this not yuck
- vertices.push();
- Vertex* newVertex = &(vertices.editArray()[vertices.size() - 1]);
- Vertex::set(newVertex, x, y);
-}
-
class ClockwiseEnforcer {
public:
void addPoint(const SkPoint& point) {
@@ -924,15 +917,15 @@
lastX = x;
lastY = y;
}
- void reverseVectorIfNotClockwise(Vector<Vertex>& vertices) {
+ void reverseVectorIfNotClockwise(std::vector<Vertex>& vertices) {
if (sum < 0) {
// negative sum implies CounterClockwise
const int size = vertices.size();
for (int i = 0; i < size / 2; i++) {
Vertex tmp = vertices[i];
int k = size - 1 - i;
- vertices.replaceAt(vertices[k], i);
- vertices.replaceAt(tmp, k);
+ vertices[i] = vertices[k];
+ vertices[k] = tmp;
}
}
}
@@ -944,7 +937,7 @@
};
bool PathTessellator::approximatePathOutlineVertices(const SkPath& path, bool forceClose,
- const PathApproximationInfo& approximationInfo, Vector<Vertex>& outputVertices) {
+ const PathApproximationInfo& approximationInfo, std::vector<Vertex>& outputVertices) {
ATRACE_CALL();
// TODO: to support joins other than sharp miter, join vertices should be labelled in the
@@ -956,7 +949,7 @@
while (SkPath::kDone_Verb != (v = iter.next(pts))) {
switch (v) {
case SkPath::kMove_Verb:
- pushToVector(outputVertices, pts[0].x(), pts[0].y());
+ outputVertices.push_back(Vertex{pts[0].x(), pts[0].y()});
ALOGV("Move to pos %f %f", pts[0].x(), pts[0].y());
clockwiseEnforcer.addPoint(pts[0]);
break;
@@ -966,7 +959,7 @@
break;
case SkPath::kLine_Verb:
ALOGV("kLine_Verb %f %f -> %f %f", pts[0].x(), pts[0].y(), pts[1].x(), pts[1].y());
- pushToVector(outputVertices, pts[1].x(), pts[1].y());
+ outputVertices.push_back(Vertex{pts[1].x(), pts[1].y()});
clockwiseEnforcer.addPoint(pts[1]);
break;
case SkPath::kQuad_Verb:
@@ -1017,7 +1010,7 @@
int size = outputVertices.size();
if (size >= 2 && outputVertices[0].x == outputVertices[size - 1].x &&
outputVertices[0].y == outputVertices[size - 1].y) {
- outputVertices.pop();
+ outputVertices.pop_back();
wasClosed = true;
}
@@ -1045,7 +1038,7 @@
float p1x, float p1y, float c1x, float c1y,
float p2x, float p2y, float c2x, float c2y,
const PathApproximationInfo& approximationInfo,
- Vector<Vertex>& outputVertices, int depth) {
+ std::vector<Vertex>& outputVertices, int depth) {
float dx = p2x - p1x;
float dy = p2y - p1y;
float d1 = fabs((c1x - p2x) * dy - (c1y - p2y) * dx);
@@ -1055,7 +1048,7 @@
if (depth >= MAX_DEPTH
|| d * d <= getThreshold(approximationInfo, dx, dy)) {
// below thresh, draw line by adding endpoint
- pushToVector(outputVertices, p2x, p2y);
+ outputVertices.push_back(Vertex{p2x, p2y});
} else {
float p1c1x = (p1x + c1x) * 0.5f;
float p1c1y = (p1y + c1y) * 0.5f;
@@ -1090,7 +1083,7 @@
float bx, float by,
float cx, float cy,
const PathApproximationInfo& approximationInfo,
- Vector<Vertex>& outputVertices, int depth) {
+ std::vector<Vertex>& outputVertices, int depth) {
float dx = bx - ax;
float dy = by - ay;
// d is the cross product of vector (B-A) and (C-B).
@@ -1099,7 +1092,7 @@
if (depth >= MAX_DEPTH
|| d * d <= getThreshold(approximationInfo, dx, dy)) {
// below thresh, draw line by adding endpoint
- pushToVector(outputVertices, bx, by);
+ outputVertices.push_back(Vertex{bx, by});
} else {
float acx = (ax + cx) * 0.5f;
float bcx = (bx + cx) * 0.5f;