summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThiago Marcos P. Santos <tmpsantos@gmail.com>2020-03-20 12:38:09 +0200
committerThiago Marcos P. Santos <tmpsantos@gmail.com>2020-03-23 12:09:09 +0200
commit37802eec36aae3cb84c7f73a48652d9959489243 (patch)
tree6e5b869babc4e1d23171a9f470b9c822b1c77cae
parent991cfee7df24acf50893c669d3a135e474945e97 (diff)
downloadqtlocation-mapboxgl-37802eec36aae3cb84c7f73a48652d9959489243.tar.gz
[core] Fix performance-type-promotion-in-math-fn errors
As reported by clang-tidy-8.
-rw-r--r--src/mbgl/layout/clip_lines.cpp24
-rw-r--r--src/mbgl/layout/symbol_layout.cpp2
-rw-r--r--src/mbgl/renderer/buckets/symbol_bucket.cpp4
-rw-r--r--src/mbgl/renderer/tile_pyramid.cpp2
-rw-r--r--src/mbgl/text/cross_tile_symbol_index.cpp3
-rw-r--r--src/mbgl/text/get_anchors.cpp10
6 files changed, 26 insertions, 19 deletions
diff --git a/src/mbgl/layout/clip_lines.cpp b/src/mbgl/layout/clip_lines.cpp
index 05b9103f69..05af5ef7b1 100644
--- a/src/mbgl/layout/clip_lines.cpp
+++ b/src/mbgl/layout/clip_lines.cpp
@@ -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()))) {
diff --git a/src/mbgl/layout/symbol_layout.cpp b/src/mbgl/layout/symbol_layout.cpp
index 842f7d40c1..374ab3b659 100644
--- a/src/mbgl/layout/symbol_layout.cpp
+++ b/src/mbgl/layout/symbol_layout.cpp
@@ -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);
}
diff --git a/src/mbgl/renderer/buckets/symbol_bucket.cpp b/src/mbgl/renderer/buckets/symbol_bucket.cpp
index 1858f29801..de32d5ea49 100644
--- a/src/mbgl/renderer/buckets/symbol_bucket.cpp
+++ b/src/mbgl/renderer/buckets/symbol_bucket.cpp
@@ -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;
}
diff --git a/src/mbgl/renderer/tile_pyramid.cpp b/src/mbgl/renderer/tile_pyramid.cpp
index 38d984bec4..fc59634723 100644
--- a/src/mbgl/renderer/tile_pyramid.cpp
+++ b/src/mbgl/renderer/tile_pyramid.cpp
@@ -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) {
diff --git a/src/mbgl/text/cross_tile_symbol_index.cpp b/src/mbgl/text/cross_tile_symbol_index.cpp
index 76697fb62a..1eddc08146 100644
--- a/src/mbgl/text/cross_tile_symbol_index.cpp
+++ b/src/mbgl/text/cross_tile_symbol_index.cpp
@@ -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) {
diff --git a/src/mbgl/text/get_anchors.cpp b/src/mbgl/text/get_anchors.cpp
index 714bc79fea..c8f5f470b4 100644
--- a/src/mbgl/text/get_anchors.cpp
+++ b/src/mbgl/text/get_anchors.cpp
@@ -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;