Fix ALL compile warnings
All warnings/errors fixed for GCC & Clang
Change-Id: I2ece3a136a5ae97a9acc3069537ed986238b5fd3
diff --git a/libs/hwui/PathTessellator.cpp b/libs/hwui/PathTessellator.cpp
index 804ec41..209341c 100644
--- a/libs/hwui/PathTessellator.cpp
+++ b/libs/hwui/PathTessellator.cpp
@@ -90,7 +90,7 @@
*
* NOTE: assumes angles between normals 90 degrees or less
*/
-inline static vec2 totalOffsetFromNormals(const vec2& normalA, const vec2& normalB) {
+inline static Vector2 totalOffsetFromNormals(const Vector2& normalA, const Vector2& normalB) {
return (normalA + normalB) / (1 + fabs(normalA.dot(normalB)));
}
@@ -129,7 +129,7 @@
float halfStrokeWidth;
float maxAlpha;
- inline void scaleOffsetForStrokeWidth(vec2& offset) const {
+ inline void scaleOffsetForStrokeWidth(Vector2& offset) const {
if (halfStrokeWidth == 0.0f) {
// hairline - compensate for scale
offset.x *= 0.5f * inverseScaleX;
@@ -143,9 +143,8 @@
* NOTE: the input will not always be a normal, especially for sharp edges - it should be the
* result of totalOffsetFromNormals (see documentation there)
*/
- inline vec2 deriveAAOffset(const vec2& offset) const {
- return vec2(offset.x * 0.5f * inverseScaleX,
- offset.y * 0.5f * inverseScaleY);
+ inline Vector2 deriveAAOffset(const Vector2& offset) const {
+ return (Vector2){offset.x * 0.5f * inverseScaleX, offset.y * 0.5f * inverseScaleY};
}
/**
@@ -208,16 +207,14 @@
int currentIndex = 0;
const Vertex* last = &(perimeter[perimeter.size() - 1]);
const Vertex* current = &(perimeter[0]);
- vec2 lastNormal(current->y - last->y,
- last->x - current->x);
+ Vector2 lastNormal = {current->y - last->y, last->x - current->x};
lastNormal.normalize();
for (unsigned int i = 0; i < perimeter.size(); i++) {
const Vertex* next = &(perimeter[i + 1 >= perimeter.size() ? 0 : i + 1]);
- vec2 nextNormal(next->y - current->y,
- current->x - next->x);
+ Vector2 nextNormal = {next->y - current->y, current->x - next->x};
nextNormal.normalize();
- vec2 totalOffset = totalOffsetFromNormals(lastNormal, nextNormal);
+ Vector2 totalOffset = totalOffsetFromNormals(lastNormal, nextNormal);
paintInfo.scaleOffsetForStrokeWidth(totalOffset);
Vertex::set(&buffer[currentIndex++],
@@ -241,13 +238,14 @@
}
static inline void storeBeginEnd(const PaintInfo& paintInfo, const Vertex& center,
- const vec2& normal, Vertex* buffer, int& currentIndex, bool begin) {
- vec2 strokeOffset = normal;
+ const Vector2& normal, Vertex* buffer, int& currentIndex, bool begin) {
+ Vector2 strokeOffset = normal;
paintInfo.scaleOffsetForStrokeWidth(strokeOffset);
- vec2 referencePoint(center.x, center.y);
+ Vector2 referencePoint = {center.x, center.y};
if (paintInfo.cap == SkPaint::kSquare_Cap) {
- referencePoint += vec2(-strokeOffset.y, strokeOffset.x) * (begin ? -1 : 1);
+ Vector2 rotated = {-strokeOffset.y, strokeOffset.x};
+ referencePoint += rotated * (begin ? -1 : 1);
}
Vertex::set(&buffer[currentIndex++], referencePoint + strokeOffset);
@@ -288,14 +286,14 @@
}
beginTheta += dTheta;
- vec2 beginRadialOffset(cos(beginTheta), sin(beginTheta));
+ Vector2 beginRadialOffset = {cos(beginTheta), sin(beginTheta)};
paintInfo.scaleOffsetForStrokeWidth(beginRadialOffset);
Vertex::set(&buffer[capOffset],
vertices[0].x + beginRadialOffset.x,
vertices[0].y + beginRadialOffset.y);
endTheta += dTheta;
- vec2 endRadialOffset(cos(endTheta), sin(endTheta));
+ Vector2 endRadialOffset = {cos(endTheta), sin(endTheta)};
paintInfo.scaleOffsetForStrokeWidth(endRadialOffset);
Vertex::set(&buffer[allocSize - 1 - capOffset],
vertices[lastIndex].x + endRadialOffset.x,
@@ -306,22 +304,20 @@
int currentIndex = extra;
const Vertex* last = &(vertices[0]);
const Vertex* current = &(vertices[1]);
- vec2 lastNormal(current->y - last->y,
- last->x - current->x);
+ Vector2 lastNormal = {current->y - last->y, last->x - current->x};
lastNormal.normalize();
storeBeginEnd(paintInfo, vertices[0], lastNormal, buffer, currentIndex, true);
for (unsigned int i = 1; i < vertices.size() - 1; i++) {
const Vertex* next = &(vertices[i + 1]);
- vec2 nextNormal(next->y - current->y,
- current->x - next->x);
+ Vector2 nextNormal = {next->y - current->y, current->x - next->x};
nextNormal.normalize();
- vec2 strokeOffset = totalOffsetFromNormals(lastNormal, nextNormal);
+ Vector2 strokeOffset = totalOffsetFromNormals(lastNormal, nextNormal);
paintInfo.scaleOffsetForStrokeWidth(strokeOffset);
- vec2 center(current->x, current->y);
+ Vector2 center = {current->x, current->y};
Vertex::set(&buffer[currentIndex++], center + strokeOffset);
Vertex::set(&buffer[currentIndex++], center - strokeOffset);
@@ -353,18 +349,16 @@
int currentIndex = 0;
const Vertex* last = &(perimeter[perimeter.size() - 1]);
const Vertex* current = &(perimeter[0]);
- vec2 lastNormal(current->y - last->y,
- last->x - current->x);
+ Vector2 lastNormal = {current->y - last->y, last->x - current->x};
lastNormal.normalize();
for (unsigned int i = 0; i < perimeter.size(); i++) {
const Vertex* next = &(perimeter[i + 1 >= perimeter.size() ? 0 : i + 1]);
- vec2 nextNormal(next->y - current->y,
- current->x - next->x);
+ Vector2 nextNormal = {next->y - current->y, current->x - next->x};
nextNormal.normalize();
// AA point offset from original point is that point's normal, such that each side is offset
// by .5 pixels
- vec2 totalOffset = paintInfo.deriveAAOffset(totalOffsetFromNormals(lastNormal, nextNormal));
+ Vector2 totalOffset = paintInfo.deriveAAOffset(totalOffsetFromNormals(lastNormal, nextNormal));
AlphaVertex::set(&buffer[currentIndex++],
current->x + totalOffset.x,
@@ -407,7 +401,7 @@
* getStrokeVerticesFromUnclosedVerticesAA() below.
*/
inline static void storeCapAA(const PaintInfo& paintInfo, const Vector<Vertex>& vertices,
- AlphaVertex* buffer, bool isFirst, vec2 normal, int offset) {
+ AlphaVertex* buffer, bool isFirst, Vector2 normal, int offset) {
const int extra = paintInfo.capExtraDivisions();
const int extraOffset = (extra + 1) / 2;
const int capIndex = isFirst
@@ -416,27 +410,28 @@
if (isFirst) normal *= -1;
// TODO: this normal should be scaled by radialScale if extra != 0, see totalOffsetFromNormals()
- vec2 AAOffset = paintInfo.deriveAAOffset(normal);
+ Vector2 AAOffset = paintInfo.deriveAAOffset(normal);
- vec2 strokeOffset = normal;
+ Vector2 strokeOffset = normal;
paintInfo.scaleOffsetForStrokeWidth(strokeOffset);
- vec2 outerOffset = strokeOffset + AAOffset;
- vec2 innerOffset = strokeOffset - AAOffset;
+ Vector2 outerOffset = strokeOffset + AAOffset;
+ Vector2 innerOffset = strokeOffset - AAOffset;
- vec2 capAAOffset;
+ Vector2 capAAOffset = {0, 0};
if (paintInfo.cap != SkPaint::kRound_Cap) {
// if the cap is square or butt, the inside primary cap vertices will be inset in two
// directions - both normal to the stroke, and parallel to it.
- capAAOffset = vec2(-AAOffset.y, AAOffset.x);
+ capAAOffset = (Vector2){-AAOffset.y, AAOffset.x};
}
// determine referencePoint, the center point for the 4 primary cap vertices
const Vertex* point = isFirst ? vertices.begin() : (vertices.end() - 1);
- vec2 referencePoint(point->x, point->y);
+ 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)
- referencePoint += vec2(-strokeOffset.y, strokeOffset.x);
+ Vector2 rotated = {-strokeOffset.y, strokeOffset.x};
+ referencePoint += rotated;
}
AlphaVertex::set(&buffer[capIndex + 0],
@@ -469,7 +464,7 @@
for (int i = 0; i < extra; i++) {
theta += dTheta;
- vec2 radialOffset(cos(theta), sin(theta));
+ Vector2 radialOffset = {cos(theta), sin(theta)};
// scale to compensate for pinching at sharp angles, see totalOffsetFromNormals()
radialOffset *= radialScale;
@@ -592,8 +587,7 @@
const Vertex* last = &(vertices[0]);
const Vertex* current = &(vertices[1]);
- vec2 lastNormal(current->y - last->y,
- last->x - current->x);
+ Vector2 lastNormal = {current->y - last->y, last->x - current->x};
lastNormal.normalize();
// TODO: use normal from bezier traversal for cap, instead of from vertices
@@ -601,16 +595,15 @@
for (unsigned int i = 1; i < vertices.size() - 1; i++) {
const Vertex* next = &(vertices[i + 1]);
- vec2 nextNormal(next->y - current->y,
- current->x - next->x);
+ Vector2 nextNormal = {next->y - current->y, current->x - next->x};
nextNormal.normalize();
- vec2 totalOffset = totalOffsetFromNormals(lastNormal, nextNormal);
- vec2 AAOffset = paintInfo.deriveAAOffset(totalOffset);
+ Vector2 totalOffset = totalOffsetFromNormals(lastNormal, nextNormal);
+ Vector2 AAOffset = paintInfo.deriveAAOffset(totalOffset);
- vec2 innerOffset = totalOffset;
+ Vector2 innerOffset = totalOffset;
paintInfo.scaleOffsetForStrokeWidth(innerOffset);
- vec2 outerOffset = innerOffset + AAOffset;
+ Vector2 outerOffset = innerOffset + AAOffset;
innerOffset -= AAOffset;
AlphaVertex::set(&buffer[currentAAOuterIndex++],
@@ -662,21 +655,19 @@
const Vertex* last = &(perimeter[perimeter.size() - 1]);
const Vertex* current = &(perimeter[0]);
- vec2 lastNormal(current->y - last->y,
- last->x - current->x);
+ Vector2 lastNormal = {current->y - last->y, last->x - current->x};
lastNormal.normalize();
for (unsigned int i = 0; i < perimeter.size(); i++) {
const Vertex* next = &(perimeter[i + 1 >= perimeter.size() ? 0 : i + 1]);
- vec2 nextNormal(next->y - current->y,
- current->x - next->x);
+ Vector2 nextNormal = {next->y - current->y, current->x - next->x};
nextNormal.normalize();
- vec2 totalOffset = totalOffsetFromNormals(lastNormal, nextNormal);
- vec2 AAOffset = paintInfo.deriveAAOffset(totalOffset);
+ Vector2 totalOffset = totalOffsetFromNormals(lastNormal, nextNormal);
+ Vector2 AAOffset = paintInfo.deriveAAOffset(totalOffset);
- vec2 innerOffset = totalOffset;
+ Vector2 innerOffset = totalOffset;
paintInfo.scaleOffsetForStrokeWidth(innerOffset);
- vec2 outerOffset = innerOffset + AAOffset;
+ Vector2 outerOffset = innerOffset + AAOffset;
innerOffset -= AAOffset;
AlphaVertex::set(&buffer[currentAAOuterIndex++],