diff options
author | Thiago Marcos P. Santos <tmpsantos@gmail.com> | 2020-03-20 12:38:09 +0200 |
---|---|---|
committer | Thiago Marcos P. Santos <tmpsantos@gmail.com> | 2020-03-30 23:37:44 +0300 |
commit | 65f4df5190d764a12a2c8054bfce2838545917e7 (patch) | |
tree | 4b0ae8b13e19d88af1b6e3c7ae2c05d41069723c /src | |
parent | 5fa7ff3b63226bda5fe18a89794c76e86f81c4f8 (diff) | |
download | qtlocation-mapboxgl-65f4df5190d764a12a2c8054bfce2838545917e7.tar.gz |
[core] Fix google-readability-casting errors
As reported by clang-tidy-8.
Diffstat (limited to 'src')
-rw-r--r-- | src/mbgl/layout/clip_lines.cpp | 24 | ||||
-rw-r--r-- | src/mbgl/renderer/layers/render_hillshade_layer.cpp | 2 | ||||
-rw-r--r-- | src/mbgl/renderer/tile_pyramid.cpp | 10 | ||||
-rw-r--r-- | src/mbgl/style/conversion/filter.cpp | 2 | ||||
-rw-r--r-- | src/mbgl/util/tile_cover_impl.cpp | 10 |
5 files changed, 29 insertions, 19 deletions
diff --git a/src/mbgl/layout/clip_lines.cpp b/src/mbgl/layout/clip_lines.cpp index 05af5ef7b1..022c296e19 100644 --- a/src/mbgl/layout/clip_lines.cpp +++ b/src/mbgl/layout/clip_lines.cpp @@ -24,19 +24,23 @@ GeometryCollection clipLines(const GeometryCollection &lines, continue; } else if (p0.x < x1) { p0 = {x1, - static_cast<int16_t>(std::round(p0.y + (p1.y - p0.y) * ((float)(x1 - p0.x) / (p1.x - p0.x))))}; + static_cast<int16_t>( + std::round(p0.y + (p1.y - p0.y) * (static_cast<float>(x1 - p0.x) / (p1.x - p0.x))))}; } else if (p1.x < x1) { p1 = {x1, - static_cast<int16_t>(std::round(p0.y + (p1.y - p0.y) * ((float)(x1 - p0.x) / (p1.x - p0.x))))}; + static_cast<int16_t>( + std::round(p0.y + (p1.y - p0.y) * (static_cast<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>(std::round(p0.x + (p1.x - p0.x) * ((float)(y1 - p0.y) / (p1.y - p0.y)))), + p0 = {static_cast<int16_t>( + std::round(p0.x + (p1.x - p0.x) * (static_cast<float>(y1 - p0.y) / (p1.y - p0.y)))), y1}; } else if (p1.y < y1) { - p1 = {static_cast<int16_t>(std::round(p0.x + (p1.x - p0.x) * ((float)(y1 - p0.y) / (p1.y - p0.y)))), + p1 = {static_cast<int16_t>( + std::round(p0.x + (p1.x - p0.x) * (static_cast<float>(y1 - p0.y) / (p1.y - p0.y)))), y1}; } @@ -44,19 +48,23 @@ GeometryCollection clipLines(const GeometryCollection &lines, continue; } else if (p0.x >= x2) { p0 = {x2, - static_cast<int16_t>(std::round(p0.y + (p1.y - p0.y) * ((float)(x2 - p0.x) / (p1.x - p0.x))))}; + static_cast<int16_t>( + std::round(p0.y + (p1.y - p0.y) * (static_cast<float>(x2 - p0.x) / (p1.x - p0.x))))}; } else if (p1.x >= x2) { p1 = {x2, - static_cast<int16_t>(std::round(p0.y + (p1.y - p0.y) * ((float)(x2 - p0.x) / (p1.x - p0.x))))}; + static_cast<int16_t>( + std::round(p0.y + (p1.y - p0.y) * (static_cast<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>(std::round(p0.x + (p1.x - p0.x) * ((float)(y2 - p0.y) / (p1.y - p0.y)))), + p0 = {static_cast<int16_t>( + std::round(p0.x + (p1.x - p0.x) * (static_cast<float>(y2 - p0.y) / (p1.y - p0.y)))), y2}; } else if (p1.y >= y2) { - p1 = {static_cast<int16_t>(std::round(p0.x + (p1.x - p0.x) * ((float)(y2 - p0.y) / (p1.y - p0.y)))), + p1 = {static_cast<int16_t>( + std::round(p0.x + (p1.x - p0.x) * (static_cast<float>(y2 - p0.y) / (p1.y - p0.y)))), y2}; } diff --git a/src/mbgl/renderer/layers/render_hillshade_layer.cpp b/src/mbgl/renderer/layers/render_hillshade_layer.cpp index bf899221f8..5c4d4f1d95 100644 --- a/src/mbgl/renderer/layers/render_hillshade_layer.cpp +++ b/src/mbgl/renderer/layers/render_hillshade_layer.cpp @@ -36,7 +36,7 @@ RenderHillshadeLayer::~RenderHillshadeLayer() = default; const std::array<float, 2> RenderHillshadeLayer::getLatRange(const UnwrappedTileID& id) { const LatLng latlng0 = LatLng(id); const LatLng latlng1 = LatLng(UnwrappedTileID(id.canonical.z, id.canonical.x, id.canonical.y + 1)); - return {{ (float)latlng0.latitude(), (float)latlng1.latitude() }}; + return {{static_cast<float>(latlng0.latitude()), static_cast<float>(latlng1.latitude())}}; } const std::array<float, 2> RenderHillshadeLayer::getLight(const PaintParameters& parameters) { diff --git a/src/mbgl/renderer/tile_pyramid.cpp b/src/mbgl/renderer/tile_pyramid.cpp index fc59634723..f7f02f5582 100644 --- a/src/mbgl/renderer/tile_pyramid.cpp +++ b/src/mbgl/renderer/tile_pyramid.cpp @@ -145,7 +145,8 @@ void TilePyramid::update(const std::vector<Immutable<style::LayerProperties>>& l // tiles are used from the cache, but not created. optional<util::TileRange> tileRange = {}; if (bounds) { - tileRange = util::TileRange::fromLatLngBounds(*bounds, zoomRange.min, std::min(tileZoom, (int32_t)zoomRange.max)); + tileRange = util::TileRange::fromLatLngBounds( + *bounds, zoomRange.min, std::min(tileZoom, static_cast<int32_t>(zoomRange.max))); } auto createTileFn = [&](const OverscaledTileID& tileID) -> Tile* { if (tileRange && !tileRange->contains(tileID.canonical)) { @@ -196,10 +197,9 @@ void TilePyramid::update(const std::vector<Immutable<style::LayerProperties>>& l if (type != SourceType::Annotations) { size_t conservativeCacheSize = - std::max((float)parameters.transformState.getSize().width / tileSize, 1.0f) * - std::max((float)parameters.transformState.getSize().height / tileSize, 1.0f) * - (parameters.transformState.getMaxZoom() - parameters.transformState.getMinZoom() + 1) * - 0.5; + std::max(static_cast<float>(parameters.transformState.getSize().width) / tileSize, 1.0f) * + std::max(static_cast<float>(parameters.transformState.getSize().height) / tileSize, 1.0f) * + (parameters.transformState.getMaxZoom() - parameters.transformState.getMinZoom() + 1) * 0.5; cache.setSize(conservativeCacheSize); } diff --git a/src/mbgl/style/conversion/filter.cpp b/src/mbgl/style/conversion/filter.cpp index d665a4b22e..8c3e925598 100644 --- a/src/mbgl/style/conversion/filter.cpp +++ b/src/mbgl/style/conversion/filter.cpp @@ -254,7 +254,7 @@ optional<mbgl::Value> serializeLegacyFilter(const Convertible& values) { result.emplace_back(NullValue()); } } - return (mbgl::Value)result; + return mbgl::Value(result); } return toValue(values); } diff --git a/src/mbgl/util/tile_cover_impl.cpp b/src/mbgl/util/tile_cover_impl.cpp index e7181eeb5f..f97ddeff48 100644 --- a/src/mbgl/util/tile_cover_impl.cpp +++ b/src/mbgl/util/tile_cover_impl.cpp @@ -113,11 +113,13 @@ void build_bounds_map(PointList& points, uint32_t maxTile, BoundsMap& et, bool c if (to_max.points.size() >= 2) { // Projections may result in values beyond the bounds, clamp to max tile coordinates - const auto y = static_cast<uint32_t>(std::floor(clamp(to_max.points.front().y, 0.0, (double)maxTile))); + const auto y = + static_cast<uint32_t>(std::floor(clamp(to_max.points.front().y, 0.0, static_cast<double>(maxTile)))); et[y].push_back(to_max); } if (to_min.points.size() >= 2) { - const auto y = static_cast<uint32_t>(std::floor(clamp(to_min.points.front().y, 0.0, (double)maxTile))); + const auto y = + static_cast<uint32_t>(std::floor(clamp(to_min.points.front().y, 0.0, static_cast<double>(maxTile)))); et[y].push_back(to_min); } } @@ -218,7 +220,7 @@ struct BuildBoundsMap { bnd.points.insert(bnd.points.end(), 2, point); bnd.winding = false; BoundsMap et; - const auto y = static_cast<uint32_t>(std::floor(clamp(point.y, 0.0, (double)(1 << zoom)))); + const auto y = static_cast<uint32_t>(std::floor(clamp(point.y, 0.0, static_cast<double>(1 << zoom)))); et[y].push_back(bnd); return et; } @@ -233,7 +235,7 @@ struct BuildBoundsMap { } bnd.points.insert(bnd.points.end(), 2, point); bnd.winding = false; - const auto y = static_cast<uint32_t>(std::floor(clamp(point.y, 0.0, (double)(1 << zoom)))); + const auto y = static_cast<uint32_t>(std::floor(clamp(point.y, 0.0, static_cast<double>(1 << zoom)))); et[y].push_back(bnd); } return et; |