[core] Fix performance-type-promotion-in-math-fn errors
As reported by clang-tidy-8.
This commit is contained in:
@@ -23,33 +23,41 @@ GeometryCollection clipLines(const GeometryCollection &lines,
|
||||
if (p0.x < x1 && p1.x < x1) {
|
||||
continue;
|
||||
} else if (p0.x < x1) {
|
||||
p0 = { x1, static_cast<int16_t>(::round(p0.y + (p1.y - p0.y) * ((float)(x1 - p0.x) / (p1.x - p0.x)))) };
|
||||
p0 = {x1,
|
||||
static_cast<int16_t>(std::round(p0.y + (p1.y - p0.y) * ((float)(x1 - p0.x) / (p1.x - p0.x))))};
|
||||
} else if (p1.x < x1) {
|
||||
p1 = { x1, static_cast<int16_t>(::round(p0.y + (p1.y - p0.y) * ((float)(x1 - p0.x) / (p1.x - p0.x)))) };
|
||||
p1 = {x1,
|
||||
static_cast<int16_t>(std::round(p0.y + (p1.y - p0.y) * ((float)(x1 - p0.x) / (p1.x - p0.x))))};
|
||||
}
|
||||
|
||||
if (p0.y < y1 && p1.y < y1) {
|
||||
continue;
|
||||
} else if (p0.y < y1) {
|
||||
p0 = { static_cast<int16_t>(::round(p0.x + (p1.x - p0.x) * ((float)(y1 - p0.y) / (p1.y - p0.y)))), y1 };
|
||||
p0 = {static_cast<int16_t>(std::round(p0.x + (p1.x - p0.x) * ((float)(y1 - p0.y) / (p1.y - p0.y)))),
|
||||
y1};
|
||||
} else if (p1.y < y1) {
|
||||
p1 = { static_cast<int16_t>(::round(p0.x + (p1.x - p0.x) * ((float)(y1 - p0.y) / (p1.y - p0.y)))), y1 };
|
||||
p1 = {static_cast<int16_t>(std::round(p0.x + (p1.x - p0.x) * ((float)(y1 - p0.y) / (p1.y - p0.y)))),
|
||||
y1};
|
||||
}
|
||||
|
||||
if (p0.x >= x2 && p1.x >= x2) {
|
||||
continue;
|
||||
} else if (p0.x >= x2) {
|
||||
p0 = { x2, static_cast<int16_t>(::round(p0.y + (p1.y - p0.y) * ((float)(x2 - p0.x) / (p1.x - p0.x)))) };
|
||||
p0 = {x2,
|
||||
static_cast<int16_t>(std::round(p0.y + (p1.y - p0.y) * ((float)(x2 - p0.x) / (p1.x - p0.x))))};
|
||||
} else if (p1.x >= x2) {
|
||||
p1 = { x2, static_cast<int16_t>(::round(p0.y + (p1.y - p0.y) * ((float)(x2 - p0.x) / (p1.x - p0.x)))) };
|
||||
p1 = {x2,
|
||||
static_cast<int16_t>(std::round(p0.y + (p1.y - p0.y) * ((float)(x2 - p0.x) / (p1.x - p0.x))))};
|
||||
}
|
||||
|
||||
if (p0.y >= y2 && p1.y >= y2) {
|
||||
continue;
|
||||
} else if (p0.y >= y2) {
|
||||
p0 = { static_cast<int16_t>(::round(p0.x + (p1.x - p0.x) * ((float)(y2 - p0.y) / (p1.y - p0.y)))), y2 };
|
||||
p0 = {static_cast<int16_t>(std::round(p0.x + (p1.x - p0.x) * ((float)(y2 - p0.y) / (p1.y - p0.y)))),
|
||||
y2};
|
||||
} else if (p1.y >= y2) {
|
||||
p1 = { static_cast<int16_t>(::round(p0.x + (p1.x - p0.x) * ((float)(y2 - p0.y) / (p1.y - p0.y)))), y2 };
|
||||
p1 = {static_cast<int16_t>(std::round(p0.x + (p1.x - p0.x) * ((float)(y2 - p0.y) / (p1.y - p0.y)))),
|
||||
y2};
|
||||
}
|
||||
|
||||
if (clippedLines.empty() || (!clippedLines.back().empty() && !(p0 == clippedLines.back().back()))) {
|
||||
|
||||
@@ -961,7 +961,7 @@ size_t SymbolLayout::addSymbol(SymbolBucket::Buffer& buffer,
|
||||
|
||||
if (buffer.segments.empty() ||
|
||||
buffer.segments.back().vertexLength + vertexLength > std::numeric_limits<uint16_t>::max() ||
|
||||
fabs(buffer.segments.back().sortKey - sortKey) > std::numeric_limits<float>::epsilon()) {
|
||||
std::fabs(buffer.segments.back().sortKey - sortKey) > std::numeric_limits<float>::epsilon()) {
|
||||
buffer.segments.emplace_back(buffer.vertices.elements(), buffer.triangles.elements(), 0ul, 0ul, sortKey);
|
||||
}
|
||||
|
||||
|
||||
@@ -281,8 +281,8 @@ SymbolInstanceReferences SymbolBucket::getSortedSymbols(const float angle) const
|
||||
const float cos = std::cos(angle);
|
||||
|
||||
std::sort(result.begin(), result.end(), [sin, cos](const SymbolInstance& a, const SymbolInstance& b) {
|
||||
const auto aRotated = ::lround(sin * a.anchor.point.x + cos * a.anchor.point.y);
|
||||
const auto bRotated = ::lround(sin * b.anchor.point.x + cos * b.anchor.point.y);
|
||||
const auto aRotated = std::lround(sin * a.anchor.point.x + cos * a.anchor.point.y);
|
||||
const auto bRotated = std::lround(sin * b.anchor.point.x + cos * b.anchor.point.y);
|
||||
if (aRotated != bRotated) {
|
||||
return aRotated < bRotated;
|
||||
}
|
||||
|
||||
@@ -264,7 +264,7 @@ void TilePyramid::handleWrapJump(float lng) {
|
||||
|
||||
const float lngDifference = lng - prevLng;
|
||||
const float worldDifference = lngDifference / 360;
|
||||
const int wrapDelta = ::round(worldDifference);
|
||||
const int wrapDelta = std::round(worldDifference);
|
||||
prevLng = lng;
|
||||
|
||||
if (wrapDelta) {
|
||||
|
||||
@@ -76,8 +76,7 @@ CrossTileSymbolLayerIndex::CrossTileSymbolLayerIndex(uint32_t& maxCrossTileID_)
|
||||
* so that they match the new wrapped version of the map.
|
||||
*/
|
||||
void CrossTileSymbolLayerIndex::handleWrapJump(float newLng) {
|
||||
|
||||
const int wrapDelta = ::round((newLng - lng) / 360);
|
||||
const int wrapDelta = std::round((newLng - lng) / 360);
|
||||
if (wrapDelta != 0) {
|
||||
std::map<uint8_t, std::map<OverscaledTileID,TileLayerIndex>> newIndexes;
|
||||
for (auto& zoomIndex : indexes) {
|
||||
|
||||
@@ -61,7 +61,7 @@ static Anchors resample(const GeometryCoordinates& line,
|
||||
if (x >= 0 && x < util::EXTENT && y >= 0 && y < util::EXTENT &&
|
||||
markedDistance - halfLabelLength >= 0.0f &&
|
||||
markedDistance + halfLabelLength <= lineLength) {
|
||||
Anchor anchor(::round(x), ::round(y), angle, i);
|
||||
Anchor anchor(std::round(x), std::round(y), angle, i);
|
||||
|
||||
if (!angleWindowSize || checkMaxAngle(line, anchor, labelLength, angleWindowSize, maxAngle)) {
|
||||
anchors.push_back(anchor);
|
||||
@@ -104,7 +104,7 @@ Anchors getAnchors(const GeometryCoordinates& line,
|
||||
|
||||
const float angleWindowSize = getAngleWindowSize(textLeft, textRight, glyphSize, boxScale);
|
||||
|
||||
const float shapedLabelLength = fmax(textRight - textLeft, iconRight - iconLeft);
|
||||
const float shapedLabelLength = std::fmax(textRight - textLeft, iconRight - iconLeft);
|
||||
const float labelLength = shapedLabelLength * boxScale;
|
||||
|
||||
// Is the line continued from outside the tile boundary?
|
||||
@@ -143,8 +143,8 @@ optional<Anchor> getCenterAnchor(const GeometryCoordinates& line,
|
||||
}
|
||||
|
||||
const float angleWindowSize = getAngleWindowSize(textLeft, textRight, glyphSize, boxScale);
|
||||
const float labelLength = fmax(textRight - textLeft, iconRight - iconLeft) * boxScale;
|
||||
|
||||
const float labelLength = std::fmax(textRight - textLeft, iconRight - iconLeft) * boxScale;
|
||||
|
||||
float prevDistance = 0;
|
||||
const float centerDistance = getLineLength(line) / 2;
|
||||
|
||||
@@ -161,7 +161,7 @@ optional<Anchor> getCenterAnchor(const GeometryCoordinates& line,
|
||||
x = util::interpolate(float(a.x), float(b.x), t),
|
||||
y = util::interpolate(float(a.y), float(b.y), t);
|
||||
|
||||
Anchor anchor(::round(x), ::round(y), util::angle_to(b, a), i);
|
||||
Anchor anchor(std::round(x), std::round(y), util::angle_to(b, a), i);
|
||||
|
||||
if (!angleWindowSize || checkMaxAngle(line, anchor, labelLength, angleWindowSize, maxAngle)) {
|
||||
return anchor;
|
||||
|
||||
Reference in New Issue
Block a user