From fe041b80caca953d5ffbea19b5d2a36484d0286a Mon Sep 17 00:00:00 2001 From: Tadej Novak Date: Sun, 29 Aug 2021 22:53:42 +0200 Subject: [PATCH] [msvc] Fix compilation errors and warnings (#141) --- .../mbgl/style/expression/interpolator.hpp | 8 +- include/mbgl/tile/tile_id.hpp | 5 +- .../src/mbgl/storage/mbtiles_file_source.cpp | 5 + .../src/mbgl/storage/offline_database.cpp | 2 +- platform/qt/src/http_request.cpp | 4 +- platform/qt/src/qmapboxgl.cpp | 4 +- platform/qt/src/qt_conversion.hpp | 2 +- platform/qt/src/qt_image.cpp | 2 +- platform/qt/src/sqlite3.cpp | 6 +- platform/qt/src/string_stdlib.cpp | 4 +- platform/qt/src/utf.cpp | 2 +- src/mbgl/annotation/annotation_manager.cpp | 25 ++-- src/mbgl/geometry/dem_data.cpp | 4 +- src/mbgl/gfx/context.hpp | 2 +- src/mbgl/gl/context.cpp | 8 +- src/mbgl/gl/context.hpp | 10 +- src/mbgl/gl/enum.cpp | 4 +- src/mbgl/gl/offscreen_texture.cpp | 2 +- src/mbgl/gl/value.cpp | 2 +- src/mbgl/gl/value.hpp | 2 +- src/mbgl/gl/vertex_array.cpp | 2 +- src/mbgl/layout/circle_layout.hpp | 2 +- src/mbgl/layout/symbol_layout.cpp | 4 +- src/mbgl/layout/symbol_projection.cpp | 12 +- src/mbgl/map/transform_state.cpp | 2 +- src/mbgl/renderer/buckets/debug_bucket.cpp | 4 +- src/mbgl/renderer/buckets/fill_bucket.cpp | 8 +- .../buckets/fill_extrusion_bucket.cpp | 12 +- src/mbgl/renderer/buckets/heatmap_bucket.cpp | 2 +- .../renderer/buckets/hillshade_bucket.cpp | 2 +- src/mbgl/renderer/buckets/line_bucket.cpp | 2 +- src/mbgl/renderer/buckets/raster_bucket.cpp | 2 +- src/mbgl/renderer/buckets/symbol_bucket.cpp | 4 +- .../render_location_indicator_layer.cpp | 2 +- .../renderer/layers/render_raster_layer.cpp | 2 +- src/mbgl/renderer/paint_parameters.cpp | 2 +- src/mbgl/renderer/render_orchestrator.cpp | 4 +- src/mbgl/renderer/renderer_impl.cpp | 2 +- .../style/layers/location_indicator_layer.cpp | 2 +- .../location_indicator_layer_properties.hpp | 12 +- .../style/layers/symbol_layer_properties.hpp | 44 +++---- src/mbgl/style/light_impl.hpp | 2 +- src/mbgl/text/quads.cpp | 4 +- src/mbgl/util/tile_coordinate.hpp | 4 +- test/map/map.test.cpp | 2 +- test/map/map_snapshotter.test.cpp | 2 +- test/style/property_expression.test.cpp | 18 +-- test/text/get_anchors.test.cpp | 20 ++-- test/text/glyph_manager.test.cpp | 2 +- test/text/quads.test.cpp | 112 +++++++++--------- test/util/memory.test.cpp | 4 +- 51 files changed, 206 insertions(+), 195 deletions(-) diff --git a/include/mbgl/style/expression/interpolator.hpp b/include/mbgl/style/expression/interpolator.hpp index 62b48c175..bd68e5c2f 100644 --- a/include/mbgl/style/expression/interpolator.hpp +++ b/include/mbgl/style/expression/interpolator.hpp @@ -15,12 +15,12 @@ public: double base; double interpolationFactor(const Range& inputLevels, const double input) const { - return util::interpolationFactor(base, + return util::interpolationFactor(static_cast(base), Range { static_cast(inputLevels.min), static_cast(inputLevels.max) }, - input); + static_cast(input)); } bool operator==(const ExponentialInterpolator& rhs) const { @@ -33,12 +33,12 @@ public: CubicBezierInterpolator(double x1_, double y1_, double x2_, double y2_) : ub(x1_, y1_, x2_, y2_) {} double interpolationFactor(const Range& inputLevels, const double input) const { - return ub.solve(util::interpolationFactor(1.0, + return ub.solve(util::interpolationFactor(1.0f, Range { static_cast(inputLevels.min), static_cast(inputLevels.max) }, - input), + static_cast(input)), 1e-6); } diff --git a/include/mbgl/tile/tile_id.hpp b/include/mbgl/tile/tile_id.hpp index c3bdbea5c..837857b69 100644 --- a/include/mbgl/tile/tile_id.hpp +++ b/include/mbgl/tile/tile_id.hpp @@ -2,6 +2,7 @@ #include +#include #include #include #include @@ -199,7 +200,7 @@ inline OverscaledTileID OverscaledTileID::unwrapTo(int16_t newWrap) const { } inline UnwrappedTileID::UnwrappedTileID(uint8_t z_, int64_t x_, int64_t y_) - : wrap((x_ < 0 ? x_ - (1ll << z_) + 1 : x_) / (1ll << z_)), + : wrap(static_cast((x_ < 0 ? x_ - (1ll << z_) + 1 : x_) / (1ll << z_))), canonical( z_, static_cast(x_ - wrap * (1ll << z_)), @@ -247,7 +248,7 @@ inline OverscaledTileID UnwrappedTileID::overscaleTo(const uint8_t overscaledZ) } inline float UnwrappedTileID::pixelsToTileUnits(const float pixelValue, const float zoom) const { - return pixelValue * (util::EXTENT / (util::tileSize * std::pow(2, zoom - canonical.z))); + return pixelValue * (static_cast(util::EXTENT) / (static_cast(util::tileSize) * std::pow(2.f, zoom - canonical.z))); } } // namespace mbgl diff --git a/platform/default/src/mbgl/storage/mbtiles_file_source.cpp b/platform/default/src/mbgl/storage/mbtiles_file_source.cpp index 1b0c96c2c..076a151ab 100644 --- a/platform/default/src/mbgl/storage/mbtiles_file_source.cpp +++ b/platform/default/src/mbgl/storage/mbtiles_file_source.cpp @@ -15,7 +15,12 @@ #include #include + +#if defined(__QT__) && defined(_WIN32) && !defined(__GNUC__) +#include +#else #include +#endif namespace { //TODO: replace by mbgl::util::MBTILES_PROTOCOL diff --git a/platform/default/src/mbgl/storage/offline_database.cpp b/platform/default/src/mbgl/storage/offline_database.cpp index c035df299..c8f547d03 100644 --- a/platform/default/src/mbgl/storage/offline_database.cpp +++ b/platform/default/src/mbgl/storage/offline_database.cpp @@ -137,7 +137,7 @@ void OfflineDatabase::handleError(const char* action) { handleError(ex, action); } catch (const util::IOException& ex) { handleError(ex, action); - } catch (const MapboxTileLimitExceededException& ex) { + } catch (const MapboxTileLimitExceededException&) { throw; // This is ours and must be handled on client side. } catch (const std::runtime_error& ex) { handleError(ex, action); diff --git a/platform/qt/src/http_request.cpp b/platform/qt/src/http_request.cpp index cb64fc517..014a75162 100644 --- a/platform/qt/src/http_request.cpp +++ b/platform/qt/src/http_request.cpp @@ -31,7 +31,7 @@ HTTPRequest::~HTTPRequest() QUrl HTTPRequest::requestUrl() const { - return QUrl::fromPercentEncoding(QByteArray(m_resource.url.data(), m_resource.url.size())); + return QUrl::fromPercentEncoding(QByteArray(m_resource.url.data(), static_cast(m_resource.url.size()))); } QNetworkRequest HTTPRequest::networkRequest() const @@ -44,7 +44,7 @@ QNetworkRequest HTTPRequest::networkRequest() const if (m_resource.priorEtag) { const auto etag = m_resource.priorEtag; - req.setRawHeader("If-None-Match", QByteArray(etag->data(), etag->size())); + req.setRawHeader("If-None-Match", QByteArray(etag->data(), static_cast(etag->size()))); } else if (m_resource.priorModified) { req.setRawHeader("If-Modified-Since", util::rfc1123(*m_resource.priorModified).c_str()); } diff --git a/platform/qt/src/qmapboxgl.cpp b/platform/qt/src/qmapboxgl.cpp index 29f40c428..4ea257150 100644 --- a/platform/qt/src/qmapboxgl.cpp +++ b/platform/qt/src/qmapboxgl.cpp @@ -1450,7 +1450,7 @@ QVector QMapboxGL::layerIds() const const auto &layers = d_ptr->mapObj->getStyle().getLayers(); QVector layerIds; - layerIds.reserve(layers.size()); + layerIds.reserve(static_cast(layers.size())); for (const mbgl::style::Layer *layer : layers) { layerIds.append(QString::fromStdString(layer->getID())); @@ -1543,7 +1543,7 @@ QVariant QVariantFromValue(const mbgl::Value &value) { return QColor(value_.r, value_.g, value_.b, value_.a); }, [&](const std::vector &vector) { QVariantList list; - list.reserve(vector.size()); + list.reserve(static_cast(vector.size())); for (const auto &value_ : vector) { list.push_back(QVariantFromValue(value_)); } diff --git a/platform/qt/src/qt_conversion.hpp b/platform/qt/src/qt_conversion.hpp index 34d2dcce8..397cf5cca 100644 --- a/platform/qt/src/qt_conversion.hpp +++ b/platform/qt/src/qt_conversion.hpp @@ -31,7 +31,7 @@ public: } static QVariant arrayMember(const QVariant& value, std::size_t i) { - return value.toList()[i]; + return value.toList()[static_cast(i)]; } static bool isObject(const QVariant& value) { diff --git a/platform/qt/src/qt_image.cpp b/platform/qt/src/qt_image.cpp index 4cec62aa8..59816a655 100644 --- a/platform/qt/src/qt_image.cpp +++ b/platform/qt/src/qt_image.cpp @@ -37,7 +37,7 @@ PremultipliedImage decodeImage(const std::string& string) { #endif QImage image = - QImage::fromData(data, size) + QImage::fromData(data, static_cast(size)) .rgbSwapped() .convertToFormat(QImage::Format_ARGB32_Premultiplied); diff --git a/platform/qt/src/sqlite3.cpp b/platform/qt/src/sqlite3.cpp index ed4e7b9e7..2c1ccc879 100644 --- a/platform/qt/src/sqlite3.cpp +++ b/platform/qt/src/sqlite3.cpp @@ -295,7 +295,7 @@ void Query::bind(int offset, const char* value, std::size_t length, bool /* reta } // Field numbering starts at 0. - stmt.impl->query.bindValue(offset - 1, QString(QByteArray(value, length)), QSql::In); + stmt.impl->query.bindValue(offset - 1, QString(QByteArray(value, static_cast(length))), QSql::In); checkQueryError(stmt.impl->query); } @@ -313,8 +313,8 @@ void Query::bindBlob(int offset, const void* value_, std::size_t length, bool re } // Field numbering starts at 0. - stmt.impl->query.bindValue(offset - 1, retain ? QByteArray(value, length) : - QByteArray::fromRawData(value, length), QSql::In | QSql::Binary); + stmt.impl->query.bindValue(offset - 1, retain ? QByteArray(value, static_cast(length)) : + QByteArray::fromRawData(value, static_cast(length)), QSql::In | QSql::Binary); checkQueryError(stmt.impl->query); } diff --git a/platform/qt/src/string_stdlib.cpp b/platform/qt/src/string_stdlib.cpp index 334091223..570fc1dc1 100644 --- a/platform/qt/src/string_stdlib.cpp +++ b/platform/qt/src/string_stdlib.cpp @@ -9,13 +9,13 @@ namespace mbgl { namespace platform { std::string uppercase(const std::string& str) { - auto upper = QString::fromUtf8(str.data(), str.length()).toUpper().toUtf8(); + auto upper = QString::fromUtf8(str.data(), static_cast(str.length())).toUpper().toUtf8(); return std::string(upper.constData(), upper.size()); } std::string lowercase(const std::string& str) { - auto lower = QString::fromUtf8(str.data(), str.length()).toLower().toUtf8(); + auto lower = QString::fromUtf8(str.data(), static_cast(str.length())).toLower().toUtf8(); return std::string(lower.constData(), lower.size()); } diff --git a/platform/qt/src/utf.cpp b/platform/qt/src/utf.cpp index 069c7bca3..a16feaca8 100644 --- a/platform/qt/src/utf.cpp +++ b/platform/qt/src/utf.cpp @@ -6,7 +6,7 @@ namespace mbgl { namespace util { std::u16string convertUTF8ToUTF16(std::string const& utf8) { - auto utf16 = QString::fromUtf8(utf8.data(), utf8.length()); + auto utf16 = QString::fromUtf8(utf8.data(), static_cast(utf8.length())); // Newers Qt have QString::toStdU16String(), but this is how it is // implemented. Do it here to keep compatibility with older versions. diff --git a/src/mbgl/annotation/annotation_manager.cpp b/src/mbgl/annotation/annotation_manager.cpp index b5dfea8e1..b890a24c3 100644 --- a/src/mbgl/annotation/annotation_manager.cpp +++ b/src/mbgl/annotation/annotation_manager.cpp @@ -17,6 +17,11 @@ // Note: LayerManager::annotationsEnabled is defined // at compile time, so that linker (with LTO on) is able // to optimize out the unreachable code. +#define CHECK_ANNOTATIONS_ENABLED_AND_RETURN_NOARG() \ +if (!LayerManager::annotationsEnabled) { \ + assert(false); \ + return; \ +} #define CHECK_ANNOTATIONS_ENABLED_AND_RETURN(result) \ if (!LayerManager::annotationsEnabled) { \ assert(false); \ @@ -38,12 +43,12 @@ AnnotationManager::AnnotationManager(Style& style_) AnnotationManager::~AnnotationManager() = default; void AnnotationManager::setStyle(Style& style_) { - CHECK_ANNOTATIONS_ENABLED_AND_RETURN(); + CHECK_ANNOTATIONS_ENABLED_AND_RETURN_NOARG(); style = style_; } void AnnotationManager::onStyleLoaded() { - CHECK_ANNOTATIONS_ENABLED_AND_RETURN(); + CHECK_ANNOTATIONS_ENABLED_AND_RETURN_NOARG(); updateStyle(); } @@ -68,7 +73,7 @@ bool AnnotationManager::updateAnnotation(const AnnotationID& id, const Annotatio } void AnnotationManager::removeAnnotation(const AnnotationID& id) { - CHECK_ANNOTATIONS_ENABLED_AND_RETURN(); + CHECK_ANNOTATIONS_ENABLED_AND_RETURN_NOARG(); std::lock_guard lock(mutex); remove(id); dirty = true; @@ -134,13 +139,13 @@ void AnnotationManager::update(const AnnotationID& id, const FillAnnotation& ann } void AnnotationManager::remove(const AnnotationID& id) { - CHECK_ANNOTATIONS_ENABLED_AND_RETURN(); + CHECK_ANNOTATIONS_ENABLED_AND_RETURN_NOARG(); if (symbolAnnotations.find(id) != symbolAnnotations.end()) { symbolTree.remove(symbolAnnotations.at(id)); symbolAnnotations.erase(id); } else if (shapeAnnotations.find(id) != shapeAnnotations.end()) { auto it = shapeAnnotations.find(id); - *style.get().impl->removeLayer(it->second->layerID); + (void)*style.get().impl->removeLayer(it->second->layerID); shapeAnnotations.erase(it); } else { assert(false); // Should never happen @@ -211,7 +216,7 @@ void AnnotationManager::updateStyle() { } void AnnotationManager::updateData() { - CHECK_ANNOTATIONS_ENABLED_AND_RETURN(); + CHECK_ANNOTATIONS_ENABLED_AND_RETURN_NOARG(); std::lock_guard lock(mutex); if (dirty) { for (auto& tile : tiles) { @@ -222,14 +227,14 @@ void AnnotationManager::updateData() { } void AnnotationManager::addTile(AnnotationTile& tile) { - CHECK_ANNOTATIONS_ENABLED_AND_RETURN(); + CHECK_ANNOTATIONS_ENABLED_AND_RETURN_NOARG(); std::lock_guard lock(mutex); tiles.insert(&tile); tile.setData(getTileData(tile.id.canonical)); } void AnnotationManager::removeTile(AnnotationTile& tile) { - CHECK_ANNOTATIONS_ENABLED_AND_RETURN(); + CHECK_ANNOTATIONS_ENABLED_AND_RETURN_NOARG(); std::lock_guard lock(mutex); tiles.erase(&tile); } @@ -241,7 +246,7 @@ static std::string prefixedImageID(const std::string& id) { } void AnnotationManager::addImage(std::unique_ptr image) { - CHECK_ANNOTATIONS_ENABLED_AND_RETURN(); + CHECK_ANNOTATIONS_ENABLED_AND_RETURN_NOARG(); std::lock_guard lock(mutex); const std::string id = prefixedImageID(image->getID()); images.erase(id); @@ -251,7 +256,7 @@ void AnnotationManager::addImage(std::unique_ptr image) { } void AnnotationManager::removeImage(const std::string& id_) { - CHECK_ANNOTATIONS_ENABLED_AND_RETURN(); + CHECK_ANNOTATIONS_ENABLED_AND_RETURN_NOARG(); std::lock_guard lock(mutex); const std::string id = prefixedImageID(id_); images.erase(id); diff --git a/src/mbgl/geometry/dem_data.cpp b/src/mbgl/geometry/dem_data.cpp index 79998a9c4..dcfc3ec60 100644 --- a/src/mbgl/geometry/dem_data.cpp +++ b/src/mbgl/geometry/dem_data.cpp @@ -90,9 +90,9 @@ int32_t DEMData::get(const int32_t x, const int32_t y) const { const std::array& DEMData::getUnpackVector() const { // https://www.mapbox.com/help/access-elevation-data/#mapbox-terrain-rgb - static const std::array unpackMapbox = {{ 6553.6, 25.6, 0.1, 10000.0 }}; + static const std::array unpackMapbox = {{ 6553.6f, 25.6f, 0.1f, 10000.0f }}; // https://aws.amazon.com/public-datasets/terrain/ - static const std::array unpackTerrarium = {{ 256.0, 1.0, 1.0 / 256.0, 32768.0 }}; + static const std::array unpackTerrarium = {{ 256.0f, 1.0f, 1.0f / 256.0f, 32768.0f }}; return encoding == Tileset::DEMEncoding::Terrarium ? unpackTerrarium : unpackMapbox; } diff --git a/src/mbgl/gfx/context.hpp b/src/mbgl/gfx/context.hpp index 75670c4c5..4be292911 100644 --- a/src/mbgl/gfx/context.hpp +++ b/src/mbgl/gfx/context.hpp @@ -87,7 +87,7 @@ public: virtual const RenderingStats& renderingStats() const = 0; -#if not defined(NDEBUG) +#if !defined(NDEBUG) public: virtual void visualizeStencilBuffer() = 0; virtual void visualizeDepthBuffer(float depthRangeSize) = 0; diff --git a/src/mbgl/gl/context.cpp b/src/mbgl/gl/context.cpp index 4ae114e05..3384ae23e 100644 --- a/src/mbgl/gl/context.cpp +++ b/src/mbgl/gl/context.cpp @@ -316,7 +316,7 @@ std::unique_ptr Context::readFramebuffer(const Size size, const gfx:: return data; } -#if not MBGL_USE_GLES2 +#if !MBGL_USE_GLES2 void Context::drawPixels(const Size size, const void* data, gfx::TexturePixelType format) { pixelStoreUnpack = { 1 }; // TODO @@ -486,7 +486,7 @@ void Context::setDirtyState() { activeTextureUnit.setDirty(); pixelStorePack.setDirty(); pixelStoreUnpack.setDirty(); -#if not MBGL_USE_GLES2 +#if !MBGL_USE_GLES2 pointSize.setDirty(); pixelZoom.setDirty(); rasterPos.setDirty(); @@ -610,7 +610,7 @@ void Context::draw(const gfx::DrawMode& drawMode, std::size_t indexLength) { switch (drawMode.type) { case gfx::DrawModeType::Points: -#if not MBGL_USE_GLES2 +#if !MBGL_USE_GLES2 // In OpenGL ES 2, the point size is set in the vertex shader. pointSize = drawMode.size; #endif // MBGL_USE_GLES2 @@ -725,7 +725,7 @@ void Context::reduceMemoryUsage() { MBGL_CHECK_ERROR(glFinish()); } -#if not defined(NDEBUG) +#if !defined(NDEBUG) void Context::visualizeStencilBuffer() { #if not MBGL_USE_GLES2 setStencilMode(gfx::StencilMode::disabled()); diff --git a/src/mbgl/gl/context.hpp b/src/mbgl/gl/context.hpp index c16fc6cb9..ec0f4c1e2 100644 --- a/src/mbgl/gl/context.hpp +++ b/src/mbgl/gl/context.hpp @@ -74,7 +74,7 @@ public: return { size, readFramebuffer(size, format, flip) }; } -#if not MBGL_USE_GLES2 +#if !MBGL_USE_GLES2 template void drawPixels(const Image& image) { auto format = image.channels == 4 ? gfx::TexturePixelType::RGBA : gfx::TexturePixelType::Alpha; @@ -154,7 +154,7 @@ public: State pixelStorePack; State pixelStoreUnpack; -#if not MBGL_USE_GLES2 +#if !MBGL_USE_GLES2 State pixelZoom; State rasterPos; State pixelTransferDepth; @@ -183,7 +183,7 @@ private: State cullFace; State cullFaceSide; State cullFaceWinding; -#if not MBGL_USE_GLES2 +#if !MBGL_USE_GLES2 State pointSize; #endif // MBGL_USE_GLES2 @@ -198,7 +198,7 @@ private: UniqueFramebuffer createFramebuffer(); std::unique_ptr readFramebuffer(Size, gfx::TexturePixelType, bool flip); -#if not MBGL_USE_GLES2 +#if !MBGL_USE_GLES2 void drawPixels(Size size, const void* data, gfx::TexturePixelType); #endif // MBGL_USE_GLES2 @@ -227,7 +227,7 @@ public: // For testing bool disableVAOExtension = false; -#if not defined(NDEBUG) +#if !defined(NDEBUG) public: void visualizeStencilBuffer() override; void visualizeDepthBuffer(float depthRangeSize) override; diff --git a/src/mbgl/gl/enum.cpp b/src/mbgl/gl/enum.cpp index 5f8cd77ad..df1368eb2 100644 --- a/src/mbgl/gl/enum.cpp +++ b/src/mbgl/gl/enum.cpp @@ -286,7 +286,7 @@ platform::GLenum Enum::to(const gfx::TextureChannel template <> gfx::RenderbufferPixelType Enum::from(const platform::GLint value) { switch (value) { -#if not MBGL_USE_GLES2 +#if !MBGL_USE_GLES2 case GL_RGBA8: return gfx::RenderbufferPixelType::RGBA; case GL_DEPTH_COMPONENT: return gfx::RenderbufferPixelType::Depth; case GL_DEPTH24_STENCIL8: return gfx::RenderbufferPixelType::DepthStencil; @@ -302,7 +302,7 @@ gfx::RenderbufferPixelType Enum::from(const platform template <> platform::GLenum Enum::to(const gfx::RenderbufferPixelType value) { switch (value) { -#if not MBGL_USE_GLES2 +#if !MBGL_USE_GLES2 case gfx::RenderbufferPixelType::RGBA: return GL_RGBA8; case gfx::RenderbufferPixelType::Depth: return GL_DEPTH_COMPONENT; case gfx::RenderbufferPixelType::DepthStencil: return GL_DEPTH24_STENCIL8; diff --git a/src/mbgl/gl/offscreen_texture.cpp b/src/mbgl/gl/offscreen_texture.cpp index cba697558..303df0379 100644 --- a/src/mbgl/gl/offscreen_texture.cpp +++ b/src/mbgl/gl/offscreen_texture.cpp @@ -60,7 +60,7 @@ bool OffscreenTexture::isRenderable() { try { getResource().bind(); return true; - } catch (const std::runtime_error& ex) { + } catch (const std::runtime_error&) { return false; } } diff --git a/src/mbgl/gl/value.cpp b/src/mbgl/gl/value.cpp index 51f76e174..c935ca368 100644 --- a/src/mbgl/gl/value.cpp +++ b/src/mbgl/gl/value.cpp @@ -533,7 +533,7 @@ PixelStoreUnpack::Type PixelStoreUnpack::Get() { return value; } -#if not MBGL_USE_GLES2 +#if !MBGL_USE_GLES2 const constexpr PointSize::Type PointSize::Default; diff --git a/src/mbgl/gl/value.hpp b/src/mbgl/gl/value.hpp index 5bd2132ec..a634bc335 100644 --- a/src/mbgl/gl/value.hpp +++ b/src/mbgl/gl/value.hpp @@ -283,7 +283,7 @@ struct PixelStoreUnpack { static Type Get(); }; -#if not MBGL_USE_GLES2 +#if !MBGL_USE_GLES2 struct PointSize { using Type = float; diff --git a/src/mbgl/gl/vertex_array.cpp b/src/mbgl/gl/vertex_array.cpp index e82e6e976..168080a05 100644 --- a/src/mbgl/gl/vertex_array.cpp +++ b/src/mbgl/gl/vertex_array.cpp @@ -16,7 +16,7 @@ void VertexArray::bind(Context& context, // NOLINTNEXTLINE(bugprone-too-small-loop-variable) for (AttributeLocation location = 0; location < bindings.size(); ++location) { if (state->bindings.size() <= location) { - state->bindings.emplace_back(context, AttributeLocation(location)); + state->bindings.emplace_back(context, std::move(AttributeLocation(location))); } state->bindings[location] = bindings[location]; } diff --git a/src/mbgl/layout/circle_layout.hpp b/src/mbgl/layout/circle_layout.hpp index 9c5834326..620e04542 100644 --- a/src/mbgl/layout/circle_layout.hpp +++ b/src/mbgl/layout/circle_layout.hpp @@ -130,7 +130,7 @@ private: auto& segment = segments.back(); assert(segment.vertexLength <= std::numeric_limits::max()); - uint16_t index = segment.vertexLength; + auto index = static_cast(segment.vertexLength); // 1, 2, 3 // 1, 4, 3 diff --git a/src/mbgl/layout/symbol_layout.cpp b/src/mbgl/layout/symbol_layout.cpp index b35719b98..8281d33f1 100644 --- a/src/mbgl/layout/symbol_layout.cpp +++ b/src/mbgl/layout/symbol_layout.cpp @@ -974,7 +974,7 @@ size_t SymbolLayout::addSymbol(SymbolBucket::Buffer& buffer, // coordinate in this polygon. auto& segment = buffer.segments.back(); assert(segment.vertexLength <= std::numeric_limits::max()); - uint16_t index = segment.vertexLength; + auto index = static_cast(segment.vertexLength); // coordinates (2 triangles) buffer.vertices.emplace_back(SymbolSDFIconProgram::layoutVertex(labelAnchor.point, @@ -1092,7 +1092,7 @@ void SymbolLayout::addToDebugBuffers(SymbolBucket& bucket) { } auto& segment = collisionBuffer.segments.back(); - uint16_t index = segment.vertexLength; + auto index = static_cast(segment.vertexLength); collisionBuffer.vertices.emplace_back(CollisionBoxProgram::layoutVertex(anchor, symbolInstance.anchor.point, tl)); collisionBuffer.vertices.emplace_back(CollisionBoxProgram::layoutVertex(anchor, symbolInstance.anchor.point, tr)); diff --git a/src/mbgl/layout/symbol_projection.cpp b/src/mbgl/layout/symbol_projection.cpp index fef602aa4..bc9198d80 100644 --- a/src/mbgl/layout/symbol_projection.cpp +++ b/src/mbgl/layout/symbol_projection.cpp @@ -169,10 +169,10 @@ namespace mbgl { // The label needs to be flipped to keep text upright. // Iterate in the reverse direction. dir *= -1; - angle = M_PI; + angle = static_cast(M_PI); } - if (dir < 0) angle += M_PI; + if (dir < 0) angle += static_cast(M_PI); int32_t currentIndex = dir > 0 ? anchorSegment : anchorSegment + 1; @@ -248,10 +248,10 @@ namespace mbgl { const float firstGlyphOffset = symbol.glyphOffsets.front(); const float lastGlyphOffset = symbol.glyphOffsets.back();; - optional firstPlacedGlyph = placeGlyphAlongLine(fontScale * firstGlyphOffset, lineOffsetX, lineOffsetY, flip, anchorPoint, tileAnchorPoint, symbol.segment, symbol.line, symbol.tileDistances, labelPlaneMatrix, returnTileDistance); + optional firstPlacedGlyph = placeGlyphAlongLine(fontScale * firstGlyphOffset, lineOffsetX, lineOffsetY, flip, anchorPoint, tileAnchorPoint, static_cast(symbol.segment), symbol.line, symbol.tileDistances, labelPlaneMatrix, returnTileDistance); if (!firstPlacedGlyph) return {}; - optional lastPlacedGlyph = placeGlyphAlongLine(fontScale * lastGlyphOffset, lineOffsetX, lineOffsetY, flip, anchorPoint, tileAnchorPoint, symbol.segment, symbol.line, symbol.tileDistances, labelPlaneMatrix, returnTileDistance); + optional lastPlacedGlyph = placeGlyphAlongLine(fontScale * lastGlyphOffset, lineOffsetX, lineOffsetY, flip, anchorPoint, tileAnchorPoint, static_cast(symbol.segment), symbol.line, symbol.tileDistances, labelPlaneMatrix, returnTileDistance); if (!lastPlacedGlyph) return {}; return std::make_pair(*firstPlacedGlyph, *lastPlacedGlyph); @@ -316,7 +316,7 @@ namespace mbgl { for (size_t glyphIndex = 1; glyphIndex < symbol.glyphOffsets.size() - 1; glyphIndex++) { const float glyphOffsetX = symbol.glyphOffsets[glyphIndex]; // Since first and last glyph fit on the line, we're sure that the rest of the glyphs can be placed - auto placedGlyph = placeGlyphAlongLine(glyphOffsetX * fontScale, lineOffsetX, lineOffsetY, flip, projectedAnchorPoint, symbol.anchorPoint, symbol.segment, symbol.line, symbol.tileDistances, labelPlaneMatrix, false); + auto placedGlyph = placeGlyphAlongLine(glyphOffsetX * fontScale, lineOffsetX, lineOffsetY, flip, projectedAnchorPoint, symbol.anchorPoint, static_cast(symbol.segment), symbol.line, symbol.tileDistances, labelPlaneMatrix, false); if (placedGlyph) { placedGlyphs.push_back(*placedGlyph); } else { @@ -344,7 +344,7 @@ namespace mbgl { } } const float glyphOffsetX = symbol.glyphOffsets.front(); - optional singleGlyph = placeGlyphAlongLine(fontScale * glyphOffsetX, lineOffsetX, lineOffsetY, flip, projectedAnchorPoint, symbol.anchorPoint, symbol.segment, + optional singleGlyph = placeGlyphAlongLine(fontScale * glyphOffsetX, lineOffsetX, lineOffsetY, flip, projectedAnchorPoint, symbol.anchorPoint, static_cast(symbol.segment), symbol.line, symbol.tileDistances, labelPlaneMatrix, false); if (!singleGlyph) return PlacementResult::NotEnoughRoom; diff --git a/src/mbgl/map/transform_state.cpp b/src/mbgl/map/transform_state.cpp index d9acecf88..ce502b6da 100644 --- a/src/mbgl/map/transform_state.cpp +++ b/src/mbgl/map/transform_state.cpp @@ -698,7 +698,7 @@ TileCoordinate TransformState::screenCoordinateToTileCoordinate(const ScreenCoor LatLng TransformState::screenCoordinateToLatLng(const ScreenCoordinate& point, LatLng::WrapMode wrapMode) const { auto coord = screenCoordinateToTileCoordinate(point, 0); - return Projection::unproject(coord.p, 1 / util::tileSize, wrapMode); + return Projection::unproject(coord.p, 1. / util::tileSize, wrapMode); } mat4 TransformState::coordinatePointMatrix(const mat4& projMatrix) const { diff --git a/src/mbgl/renderer/buckets/debug_bucket.cpp b/src/mbgl/renderer/buckets/debug_bucket.cpp index 701a347f4..6bc2d811f 100644 --- a/src/mbgl/renderer/buckets/debug_bucket.cpp +++ b/src/mbgl/renderer/buckets/debug_bucket.cpp @@ -40,8 +40,8 @@ DebugBucket::DebugBucket(const OverscaledTileID& id, vertices.emplace_back(FillProgram::layoutVertex(p)); if (prev) { - indices.emplace_back(vertices.elements() - 2, - vertices.elements() - 1); + indices.emplace_back(static_cast(vertices.elements() - 2), + static_cast(vertices.elements() - 1)); } prev = p; diff --git a/src/mbgl/renderer/buckets/fill_bucket.cpp b/src/mbgl/renderer/buckets/fill_bucket.cpp index 8a66486a5..0d9d5c2be 100644 --- a/src/mbgl/renderer/buckets/fill_bucket.cpp +++ b/src/mbgl/renderer/buckets/fill_bucket.cpp @@ -75,14 +75,14 @@ void FillBucket::addFeature(const GeometryTileFeature& feature, auto& lineSegment = lineSegments.back(); assert(lineSegment.vertexLength <= std::numeric_limits::max()); - uint16_t lineIndex = lineSegment.vertexLength; + const auto lineIndex = static_cast(lineSegment.vertexLength); vertices.emplace_back(FillProgram::layoutVertex(ring[0])); - lines.emplace_back(lineIndex + nVertices - 1, lineIndex); + lines.emplace_back(static_cast(lineIndex + nVertices - 1), lineIndex); for (std::size_t i = 1; i < nVertices; i++) { vertices.emplace_back(FillProgram::layoutVertex(ring[i])); - lines.emplace_back(lineIndex + i - 1, lineIndex + i); + lines.emplace_back(static_cast(lineIndex + i - 1), static_cast(lineIndex + i)); } lineSegment.vertexLength += nVertices; @@ -100,7 +100,7 @@ void FillBucket::addFeature(const GeometryTileFeature& feature, auto& triangleSegment = triangleSegments.back(); assert(triangleSegment.vertexLength <= std::numeric_limits::max()); - uint16_t triangleIndex = triangleSegment.vertexLength; + const auto triangleIndex = static_cast(triangleSegment.vertexLength); for (std::size_t i = 0; i < nIndicies; i += 3) { triangles.emplace_back(triangleIndex + indices[i], diff --git a/src/mbgl/renderer/buckets/fill_extrusion_bucket.cpp b/src/mbgl/renderer/buckets/fill_extrusion_bucket.cpp index 46724e31e..408510f8d 100644 --- a/src/mbgl/renderer/buckets/fill_extrusion_bucket.cpp +++ b/src/mbgl/renderer/buckets/fill_extrusion_bucket.cpp @@ -83,7 +83,7 @@ void FillExtrusionBucket::addFeature(const GeometryTileFeature& feature, auto& triangleSegment = triangleSegments.back(); assert(triangleSegment.vertexLength <= std::numeric_limits::max()); - uint16_t triangleIndex = triangleSegment.vertexLength; + auto triangleIndex = static_cast(triangleSegment.vertexLength); assert(triangleIndex + (5 * (totalVertices - 1) + 1) <= std::numeric_limits::max()); @@ -100,7 +100,7 @@ void FillExtrusionBucket::addFeature(const GeometryTileFeature& feature, const auto& p1 = ring[i]; vertices.emplace_back( - FillExtrusionProgram::layoutVertex(p1, 0, 0, 1, 1, edgeDistance)); + FillExtrusionProgram::layoutVertex(p1, 0, 0, 1, 1, static_cast(edgeDistance))); flatIndices.emplace_back(triangleIndex); triangleIndex++; @@ -117,16 +117,16 @@ void FillExtrusionBucket::addFeature(const GeometryTileFeature& feature, } vertices.emplace_back( - FillExtrusionProgram::layoutVertex(p1, perp.x, perp.y, 0, 0, edgeDistance)); + FillExtrusionProgram::layoutVertex(p1, perp.x, perp.y, 0, 0, static_cast(edgeDistance))); vertices.emplace_back( - FillExtrusionProgram::layoutVertex(p1, perp.x, perp.y, 0, 1, edgeDistance)); + FillExtrusionProgram::layoutVertex(p1, perp.x, perp.y, 0, 1, static_cast(edgeDistance))); edgeDistance += dist; vertices.emplace_back( - FillExtrusionProgram::layoutVertex(p2, perp.x, perp.y, 0, 0, edgeDistance)); + FillExtrusionProgram::layoutVertex(p2, perp.x, perp.y, 0, 0, static_cast(edgeDistance))); vertices.emplace_back( - FillExtrusionProgram::layoutVertex(p2, perp.x, perp.y, 0, 1, edgeDistance)); + FillExtrusionProgram::layoutVertex(p2, perp.x, perp.y, 0, 1, static_cast(edgeDistance))); // ┌──────┐ // │ 0 1 │ Counter-Clockwise winding order. diff --git a/src/mbgl/renderer/buckets/heatmap_bucket.cpp b/src/mbgl/renderer/buckets/heatmap_bucket.cpp index 31c4bc0e9..6689d759d 100644 --- a/src/mbgl/renderer/buckets/heatmap_bucket.cpp +++ b/src/mbgl/renderer/buckets/heatmap_bucket.cpp @@ -78,7 +78,7 @@ void HeatmapBucket::addFeature(const GeometryTileFeature& feature, auto& segment = segments.back(); assert(segment.vertexLength <= std::numeric_limits::max()); - uint16_t index = segment.vertexLength; + const auto index = static_cast(segment.vertexLength); // 1, 2, 3 // 1, 4, 3 diff --git a/src/mbgl/renderer/buckets/hillshade_bucket.cpp b/src/mbgl/renderer/buckets/hillshade_bucket.cpp index cf9cc61e4..a2a3db8d1 100644 --- a/src/mbgl/renderer/buckets/hillshade_bucket.cpp +++ b/src/mbgl/renderer/buckets/hillshade_bucket.cpp @@ -100,7 +100,7 @@ void HillshadeBucket::setMask(TileMask&& mask_) { auto& segment = segments.back(); assert(segment.vertexLength <= std::numeric_limits::max()); - const uint16_t offset = segment.vertexLength; + const auto offset = static_cast(segment.vertexLength); // 0, 1, 2 // 1, 2, 3 diff --git a/src/mbgl/renderer/buckets/line_bucket.cpp b/src/mbgl/renderer/buckets/line_bucket.cpp index 256ce35eb..5f198da1a 100644 --- a/src/mbgl/renderer/buckets/line_bucket.cpp +++ b/src/mbgl/renderer/buckets/line_bucket.cpp @@ -441,7 +441,7 @@ void LineBucket::addGeometry(const GeometryCoordinates& coordinates, auto& segment = segments.back(); assert(segment.vertexLength <= std::numeric_limits::max()); - uint16_t index = segment.vertexLength; + const auto index = static_cast(segment.vertexLength); for (const auto& triangle : triangleStore) { triangles.emplace_back(index + triangle.a, index + triangle.b, index + triangle.c); diff --git a/src/mbgl/renderer/buckets/raster_bucket.cpp b/src/mbgl/renderer/buckets/raster_bucket.cpp index 859ee8d2a..a877e6e17 100644 --- a/src/mbgl/renderer/buckets/raster_bucket.cpp +++ b/src/mbgl/renderer/buckets/raster_bucket.cpp @@ -92,7 +92,7 @@ void RasterBucket::setMask(TileMask&& mask_) { auto& segment = segments.back(); assert(segment.vertexLength <= std::numeric_limits::max()); - const uint16_t offset = segment.vertexLength; + const auto offset = static_cast(segment.vertexLength); // 0, 1, 2 // 1, 2, 3 diff --git a/src/mbgl/renderer/buckets/symbol_bucket.cpp b/src/mbgl/renderer/buckets/symbol_bucket.cpp index cbdb4bf2e..b8a135dc2 100644 --- a/src/mbgl/renderer/buckets/symbol_bucket.cpp +++ b/src/mbgl/renderer/buckets/symbol_bucket.cpp @@ -209,8 +209,8 @@ bool SymbolBucket::hasTextCollisionCircleData() const { void addPlacedSymbol(gfx::IndexVector& triangles, const PlacedSymbol& placedSymbol) { auto endIndex = placedSymbol.vertexStartIndex + placedSymbol.glyphOffsets.size() * 4; for (auto vertexIndex = placedSymbol.vertexStartIndex; vertexIndex < endIndex; vertexIndex += 4) { - triangles.emplace_back(vertexIndex + 0, vertexIndex + 1, vertexIndex + 2); - triangles.emplace_back(vertexIndex + 1, vertexIndex + 2, vertexIndex + 3); + triangles.emplace_back(static_cast(vertexIndex + 0), static_cast(vertexIndex + 1), static_cast(vertexIndex + 2)); + triangles.emplace_back(static_cast(vertexIndex + 1), static_cast(vertexIndex + 2), static_cast(vertexIndex + 3)); } } diff --git a/src/mbgl/renderer/layers/render_location_indicator_layer.cpp b/src/mbgl/renderer/layers/render_location_indicator_layer.cpp index 28228e60d..c203741ff 100644 --- a/src/mbgl/renderer/layers/render_location_indicator_layer.cpp +++ b/src/mbgl/renderer/layers/render_location_indicator_layer.cpp @@ -472,7 +472,7 @@ protected: void updateRadius(const mbgl::LocationIndicatorRenderParameters& params) { const TransformState& s = *params.state; - const unsigned long numVtxCircumference = circle.size() - 1; + const auto numVtxCircumference = static_cast(circle.size() - 1); const float bearingStep = 360.0f / float(numVtxCircumference - 1); // first and last points are the same const mapbox::cheap_ruler::point centerPoint(params.puckPosition.longitude(), params.puckPosition.latitude()); Point center = project(params.puckPosition, s); diff --git a/src/mbgl/renderer/layers/render_raster_layer.cpp b/src/mbgl/renderer/layers/render_raster_layer.cpp index 188ec79e6..9dc6f9624 100644 --- a/src/mbgl/renderer/layers/render_raster_layer.cpp +++ b/src/mbgl/renderer/layers/render_raster_layer.cpp @@ -52,7 +52,7 @@ bool RenderRasterLayer::hasCrossfade() const { static float saturationFactor(float saturation) { if (saturation > 0) { - return 1 - 1 / (1.001 - saturation); + return 1.f - 1.f / (1.001f - saturation); } else { return -saturation; } diff --git a/src/mbgl/renderer/paint_parameters.cpp b/src/mbgl/renderer/paint_parameters.cpp index 3b7f12f77..a2886e454 100644 --- a/src/mbgl/renderer/paint_parameters.cpp +++ b/src/mbgl/renderer/paint_parameters.cpp @@ -23,7 +23,7 @@ TransformParameters::TransformParameters(const TransformState& state_) // to a tenth of the far value, so as not to waste depth buffer precision on // very close empty space, for layer types (fill-extrusion) that use the // depth buffer to emulate real-world space. - state.getProjMatrix(nearClippedProjMatrix, 0.1 * state.getCameraToCenterDistance()); + state.getProjMatrix(nearClippedProjMatrix, static_cast(0.1 * state.getCameraToCenterDistance())); } PaintParameters::PaintParameters(gfx::Context& context_, diff --git a/src/mbgl/renderer/render_orchestrator.cpp b/src/mbgl/renderer/render_orchestrator.cpp index d7f13695d..82d9dc941 100644 --- a/src/mbgl/renderer/render_orchestrator.cpp +++ b/src/mbgl/renderer/render_orchestrator.cpp @@ -322,7 +322,7 @@ std::unique_ptr RenderOrchestrator::createRenderTree( if (zoomFitsLayer) { sourceNeedsRendering = true; renderItemsEmplaceHint = - layerRenderItems.emplace_hint(renderItemsEmplaceHint, layer, source, index); + layerRenderItems.emplace_hint(renderItemsEmplaceHint, layer, source, static_cast(index)); } } } @@ -339,7 +339,7 @@ std::unique_ptr RenderOrchestrator::createRenderTree( // items. } } - renderItemsEmplaceHint = layerRenderItems.emplace_hint(renderItemsEmplaceHint, layer, nullptr, index); + renderItemsEmplaceHint = layerRenderItems.emplace_hint(renderItemsEmplaceHint, layer, nullptr, static_cast(index)); } } source->update(sourceImpl, diff --git a/src/mbgl/renderer/renderer_impl.cpp b/src/mbgl/renderer/renderer_impl.cpp index aeba4b5ee..e76ab7425 100644 --- a/src/mbgl/renderer/renderer_impl.cpp +++ b/src/mbgl/renderer/renderer_impl.cpp @@ -184,7 +184,7 @@ void Renderer::Impl::render(const RenderTree& renderTree) { } } -#if not defined(NDEBUG) +#if !defined(NDEBUG) if (parameters.debugOptions & MapDebugOptions::StencilClip) { // Render tile clip boundaries, using stencil buffer to calculate fill color. parameters.context.visualizeStencilBuffer(); diff --git a/src/mbgl/style/layers/location_indicator_layer.cpp b/src/mbgl/style/layers/location_indicator_layer.cpp index b3590d78e..c50db5bbd 100644 --- a/src/mbgl/style/layers/location_indicator_layer.cpp +++ b/src/mbgl/style/layers/location_indicator_layer.cpp @@ -301,7 +301,7 @@ TransitionOptions LocationIndicatorLayer::getLocationTransition() const { } PropertyValue LocationIndicatorLayer::getDefaultPerspectiveCompensation() { - return {0.85}; + return {0.85f}; } const PropertyValue& LocationIndicatorLayer::getPerspectiveCompensation() const { diff --git a/src/mbgl/style/layers/location_indicator_layer_properties.hpp b/src/mbgl/style/layers/location_indicator_layer_properties.hpp index 065cbe064..db3ac0e75 100644 --- a/src/mbgl/style/layers/location_indicator_layer_properties.hpp +++ b/src/mbgl/style/layers/location_indicator_layer_properties.hpp @@ -32,7 +32,7 @@ struct TopImage : LayoutProperty { }; struct AccuracyRadius : PaintProperty { - static float defaultValue() { return 0; } + static float defaultValue() { return 0.f; } }; struct AccuracyRadiusBorderColor : PaintProperty { @@ -48,11 +48,11 @@ struct Bearing : PaintProperty { }; struct BearingImageSize : PaintProperty { - static float defaultValue() { return 1; } + static float defaultValue() { return 1.f; } }; struct ImageTiltDisplacement : PaintProperty { - static float defaultValue() { return 0; } + static float defaultValue() { return 0.f; } }; struct Location : PaintProperty> { @@ -60,15 +60,15 @@ struct Location : PaintProperty> { }; struct PerspectiveCompensation : PaintProperty { - static float defaultValue() { return 0.85; } + static float defaultValue() { return 0.85f; } }; struct ShadowImageSize : PaintProperty { - static float defaultValue() { return 1; } + static float defaultValue() { return 1.f; } }; struct TopImageSize : PaintProperty { - static float defaultValue() { return 1; } + static float defaultValue() { return 1.f; } }; class LocationIndicatorLayoutProperties : public Properties< diff --git a/src/mbgl/style/layers/symbol_layer_properties.hpp b/src/mbgl/style/layers/symbol_layer_properties.hpp index 655258997..a27f89c75 100644 --- a/src/mbgl/style/layers/symbol_layer_properties.hpp +++ b/src/mbgl/style/layers/symbol_layer_properties.hpp @@ -53,7 +53,7 @@ struct IconOptional : LayoutProperty { struct IconPadding : LayoutProperty { static constexpr const char *name() { return "icon-padding"; } - static float defaultValue() { return 2; } + static float defaultValue() { return 2.f; } }; struct IconPitchAlignment : LayoutProperty { @@ -63,7 +63,7 @@ struct IconPitchAlignment : LayoutProperty { struct IconRotate : DataDrivenLayoutProperty { static constexpr const char *name() { return "icon-rotate"; } - static float defaultValue() { return 0; } + static float defaultValue() { return 0.f; } }; struct IconRotationAlignment : LayoutProperty { @@ -73,7 +73,7 @@ struct IconRotationAlignment : LayoutProperty { struct IconSize : DataDrivenLayoutProperty { static constexpr const char *name() { return "icon-size"; } - static float defaultValue() { return 1; } + static float defaultValue() { return 1.f; } }; struct IconTextFit : LayoutProperty { @@ -83,7 +83,7 @@ struct IconTextFit : LayoutProperty { struct IconTextFitPadding : LayoutProperty> { static constexpr const char *name() { return "icon-text-fit-padding"; } - static std::array defaultValue() { return {{0, 0, 0, 0}}; } + static std::array defaultValue() { return {{0.f, 0.f, 0.f, 0.f}}; } }; struct SymbolAvoidEdges : LayoutProperty { @@ -98,12 +98,12 @@ struct SymbolPlacement : LayoutProperty { struct SymbolSortKey : DataDrivenLayoutProperty { static constexpr const char *name() { return "symbol-sort-key"; } - static float defaultValue() { return 0; } + static float defaultValue() { return 0.f; } }; struct SymbolSpacing : LayoutProperty { static constexpr const char *name() { return "symbol-spacing"; } - static float defaultValue() { return 250; } + static float defaultValue() { return 250.f; } }; struct SymbolZOrder : LayoutProperty { @@ -148,22 +148,22 @@ struct TextKeepUpright : LayoutProperty { struct TextLetterSpacing : DataDrivenLayoutProperty { static constexpr const char *name() { return "text-letter-spacing"; } - static float defaultValue() { return 0; } + static float defaultValue() { return 0.f; } }; struct TextLineHeight : LayoutProperty { static constexpr const char *name() { return "text-line-height"; } - static float defaultValue() { return 1.2; } + static float defaultValue() { return 1.2f; } }; struct TextMaxAngle : LayoutProperty { static constexpr const char *name() { return "text-max-angle"; } - static float defaultValue() { return 45; } + static float defaultValue() { return 45.f; } }; struct TextMaxWidth : DataDrivenLayoutProperty { static constexpr const char *name() { return "text-max-width"; } - static float defaultValue() { return 10; } + static float defaultValue() { return 10.f; } }; struct TextOffset : DataDrivenLayoutProperty> { @@ -178,7 +178,7 @@ struct TextOptional : LayoutProperty { struct TextPadding : LayoutProperty { static constexpr const char *name() { return "text-padding"; } - static float defaultValue() { return 2; } + static float defaultValue() { return 2.f; } }; struct TextPitchAlignment : LayoutProperty { @@ -188,12 +188,12 @@ struct TextPitchAlignment : LayoutProperty { struct TextRadialOffset : DataDrivenLayoutProperty { static constexpr const char *name() { return "text-radial-offset"; } - static float defaultValue() { return 0; } + static float defaultValue() { return 0.f; } }; struct TextRotate : DataDrivenLayoutProperty { static constexpr const char *name() { return "text-rotate"; } - static float defaultValue() { return 0; } + static float defaultValue() { return 0.f; } }; struct TextRotationAlignment : LayoutProperty { @@ -203,7 +203,7 @@ struct TextRotationAlignment : LayoutProperty { struct TextSize : DataDrivenLayoutProperty { static constexpr const char *name() { return "text-size"; } - static float defaultValue() { return 16; } + static float defaultValue() { return 16.f; } }; struct TextTransform : DataDrivenLayoutProperty { @@ -226,7 +226,7 @@ struct IconColor : DataDrivenPaintProperty { - static float defaultValue() { return 0; } + static float defaultValue() { return 0.f; } }; struct IconHaloColor : DataDrivenPaintProperty { @@ -234,15 +234,15 @@ struct IconHaloColor : DataDrivenPaintProperty { - static float defaultValue() { return 0; } + static float defaultValue() { return 0.f; } }; struct IconOpacity : DataDrivenPaintProperty { - static float defaultValue() { return 1; } + static float defaultValue() { return 1.f; } }; struct IconTranslate : PaintProperty> { - static std::array defaultValue() { return {{0, 0}}; } + static std::array defaultValue() { return {{0.f, 0.f}}; } }; struct IconTranslateAnchor : PaintProperty { @@ -257,7 +257,7 @@ struct TextColor : DataDrivenPaintProperty { - static float defaultValue() { return 0; } + static float defaultValue() { return 0.f; } }; struct TextHaloColor : DataDrivenPaintProperty { @@ -265,15 +265,15 @@ struct TextHaloColor : DataDrivenPaintProperty { - static float defaultValue() { return 0; } + static float defaultValue() { return 0.f; } }; struct TextOpacity : DataDrivenPaintProperty { - static float defaultValue() { return 1; } + static float defaultValue() { return 1.f; } }; struct TextTranslate : PaintProperty> { - static std::array defaultValue() { return {{0, 0}}; } + static std::array defaultValue() { return {{0.f, 0.f}}; } }; struct TextTranslateAnchor : PaintProperty { diff --git a/src/mbgl/style/light_impl.hpp b/src/mbgl/style/light_impl.hpp index 33db64ae3..db75db84f 100644 --- a/src/mbgl/style/light_impl.hpp +++ b/src/mbgl/style/light_impl.hpp @@ -32,7 +32,7 @@ struct LightAnchor : LightProperty { struct LightPosition : LightProperty { static Position defaultValue() { - std::array default_ = { { 1.15, 210, 30 } }; + std::array default_ = { { 1.15f, 210.f, 30.f } }; return Position{ { default_ } }; } }; diff --git a/src/mbgl/text/quads.cpp b/src/mbgl/text/quads.cpp index 26b26c556..a289ac511 100644 --- a/src/mbgl/text/quads.cpp +++ b/src/mbgl/text/quads.cpp @@ -276,11 +276,11 @@ SymbolQuads getGlyphQuads(const Shaping& shapedText, // for when glyph is rotated and translated. const Point center{-halfAdvance, halfAdvance - Shaping::yOffset}; - const float verticalRotation = -M_PI_2; + const float verticalRotation = static_cast(-M_PI_2); // xHalfWidhtOffsetcorrection is a difference between full-width and half-width // advance, should be 0 for full-width glyphs and will pull up half-width glyphs. - const float xHalfWidhtOffsetcorrection = util::ONE_EM / 2 - halfAdvance; + const float xHalfWidhtOffsetcorrection = util::ONE_EM / 2.f - halfAdvance; const float yImageOffsetCorrection = positionedGlyph.imageID ? xHalfWidhtOffsetcorrection : 0.0f; const Point xOffsetCorrection{5.0f - Shaping::yOffset - xHalfWidhtOffsetcorrection, -yImageOffsetCorrection}; diff --git a/src/mbgl/util/tile_coordinate.hpp b/src/mbgl/util/tile_coordinate.hpp index 6d7880494..23f03a152 100644 --- a/src/mbgl/util/tile_coordinate.hpp +++ b/src/mbgl/util/tile_coordinate.hpp @@ -37,10 +37,10 @@ public: const double scale = std::pow(2.0, tileID.canonical.z); auto zoomed = TileCoordinate { point, 0 }.zoomTo(tileID.canonical.z); return { - int16_t(util::clamp((zoomed.p.x - tileID.canonical.x - tileID.wrap * scale) * util::EXTENT, + int16_t(util::clamp(static_cast(zoomed.p.x - tileID.canonical.x - tileID.wrap * scale) * util::EXTENT, std::numeric_limits::min(), std::numeric_limits::max())), - int16_t(util::clamp((zoomed.p.y - tileID.canonical.y) * util::EXTENT, + int16_t(util::clamp(static_cast(zoomed.p.y - tileID.canonical.y) * util::EXTENT, std::numeric_limits::min(), std::numeric_limits::max())) }; diff --git a/test/map/map.test.cpp b/test/map/map.test.cpp index 531ffa75a..9243002fc 100644 --- a/test/map/map.test.cpp +++ b/test/map/map.test.cpp @@ -1300,7 +1300,7 @@ TEST(Map, PrefetchDeltaOverrideCustomSource) { }; auto layer = test.map.getStyle().removeLayer("custom"); - std::move(test.map.getStyle().removeSource("custom")); + test.map.getStyle().removeSource("custom"); test.map.getStyle().addLayer(std::move(layer)); test.map.getStyle().addSource(makeCustomSource()); test.runLoop.run(); diff --git a/test/map/map_snapshotter.test.cpp b/test/map/map_snapshotter.test.cpp index 9d8eae889..a23d2bbc6 100644 --- a/test/map/map_snapshotter.test.cpp +++ b/test/map/map_snapshotter.test.cpp @@ -119,7 +119,7 @@ TEST(MapSnapshotter, TEST_REQUIRES_SERVER(runtimeStyling)) { observer.didFinishLoadingStyleCallback = [&snapshotter, &runLoop] { auto fillLayer = std::make_unique("green_fill", "mapbox"); fillLayer->setSourceLayer("water"); - fillLayer->setFillColor(Color(0.25, 0.88, 0.82, 1.0)); + fillLayer->setFillColor(Color(0.25f, 0.88f, 0.82f, 1.0f)); snapshotter.getStyle().addLayer(std::move(fillLayer)); snapshotter.snapshot([&runLoop](std::exception_ptr ptr, mbgl::PremultipliedImage image, diff --git a/test/style/property_expression.test.cpp b/test/style/property_expression.test.cpp index faa59025b..5932ade91 100644 --- a/test/style/property_expression.test.cpp +++ b/test/style/property_expression.test.cpp @@ -45,15 +45,15 @@ auto createOverride(expression::type::Type exprType, } TEST(PropertyExpression, Constant) { - EXPECT_EQ(2.0f, evaluate(PropertyValue(2.0), 0)); - EXPECT_EQ(3.8f, evaluate(PropertyValue(3.8), 0)); - EXPECT_EQ(22.0f, evaluate(PropertyValue(22.0), 0)); - EXPECT_EQ(2.0f, evaluate(PropertyValue(2.0), 4)); - EXPECT_EQ(3.8f, evaluate(PropertyValue(3.8), 4)); - EXPECT_EQ(22.0f, evaluate(PropertyValue(22.0), 4)); - EXPECT_EQ(2.0f, evaluate(PropertyValue(2.0), 22)); - EXPECT_EQ(3.8f, evaluate(PropertyValue(3.8), 22)); - EXPECT_EQ(22.0f, evaluate(PropertyValue(22.0), 22)); + EXPECT_EQ(2.0f, evaluate(PropertyValue(2.0f), 0)); + EXPECT_EQ(3.8f, evaluate(PropertyValue(3.8f), 0)); + EXPECT_EQ(22.0f, evaluate(PropertyValue(22.0f), 0)); + EXPECT_EQ(2.0f, evaluate(PropertyValue(2.0f), 4)); + EXPECT_EQ(3.8f, evaluate(PropertyValue(3.8f), 4)); + EXPECT_EQ(22.0f, evaluate(PropertyValue(22.0f), 4)); + EXPECT_EQ(2.0f, evaluate(PropertyValue(2.0f), 22)); + EXPECT_EQ(3.8f, evaluate(PropertyValue(3.8f), 22)); + EXPECT_EQ(22.0f, evaluate(PropertyValue(22.0f), 22)); } TEST(PropertyExpression, Expression) { diff --git a/test/text/get_anchors.test.cpp b/test/text/get_anchors.test.cpp index 84dea4394..856c24cd6 100644 --- a/test/text/get_anchors.test.cpp +++ b/test/text/get_anchors.test.cpp @@ -35,7 +35,7 @@ const float overscaling = 1.0f; TEST(getAnchors, NonContinuedLineShortLabels) { const Anchors anchors = getAnchors( - nonContinuedLine, bigSpacing, M_PI, textLeft, textRight, iconLeft, iconRight, glyphSize, boxScale, overscaling); + nonContinuedLine, bigSpacing, static_cast(M_PI), textLeft, textRight, iconLeft, iconRight, glyphSize, boxScale, overscaling); const Anchors expected_anchors = {Anchor(1.0f, 2.0f, 1.570796371f, 1u), Anchor(1.0f, 5.0f, 1.570796371f, 4u), Anchor(1.0f, 8.0f, 1.570796371f, 7u)}; @@ -46,7 +46,7 @@ TEST(getAnchors, NonContinuedLineShortLabels) { TEST(getAnchors, NonContinuedLineLongLabels) { const Anchors anchors = getAnchors(nonContinuedLine, smallSpacing, - M_PI, + static_cast(M_PI), textLeft, textRight, iconLeft, @@ -63,7 +63,7 @@ TEST(getAnchors, NonContinuedLineLongLabels) { TEST(getAnchors, ContinuedLineShortLabels) { const Anchors anchors = getAnchors( - continuedLine, bigSpacing, M_PI, textLeft, textRight, iconLeft, iconRight, glyphSize, boxScale, overscaling); + continuedLine, bigSpacing, static_cast(M_PI), textLeft, textRight, iconLeft, iconRight, glyphSize, boxScale, overscaling); const Anchors expected_anchors = {Anchor(1.0f, 2.0f, 1.570796371f, 1u), Anchor(1.0f, 5.0f, 1.570796371f, 4u), Anchor(1.0f, 8.0f, 1.570796371f, 7u)}; @@ -73,7 +73,7 @@ TEST(getAnchors, ContinuedLineShortLabels) { TEST(getAnchors, ContinuedLineLongLabels) { const Anchors anchors = getAnchors( - continuedLine, smallSpacing, M_PI, textLeft, textRight, iconLeft, iconRight, glyphSize, boxScale, overscaling); + continuedLine, smallSpacing, static_cast(M_PI), textLeft, textRight, iconLeft, iconRight, glyphSize, boxScale, overscaling); const Anchors expected_anchors = {Anchor(1.0f, 1.0f, 1.570796371f, 1u), Anchor(1.0f, 4.0f, 1.570796371f, 3u), Anchor(1.0f, 6.0f, 1.570796371f, 6u)}; @@ -83,10 +83,10 @@ TEST(getAnchors, ContinuedLineLongLabels) { TEST(getAnchors, OverscaledAnchorsInParent) { const Anchors anchors = getAnchors( - nonContinuedLine, bigSpacing, M_PI, textLeft, textRight, iconLeft, iconRight, glyphSize, boxScale, overscaling); + nonContinuedLine, bigSpacing, static_cast(M_PI), textLeft, textRight, iconLeft, iconRight, glyphSize, boxScale, overscaling); const Anchors childAnchors = getAnchors(nonContinuedLine, bigSpacing / 2, - M_PI, + static_cast(M_PI), textLeft, textRight, iconLeft, @@ -102,7 +102,7 @@ TEST(getAnchors, OverscaledAnchorsInParent) { TEST(getAnchors, UseMidpointForShortLine) { const GeometryCoordinates shortLine = {Point{1, 1}, Point{1, 3}}; const Anchors anchors = getAnchors( - shortLine, smallSpacing, M_PI, textLeft, textRight, iconLeft, iconRight, glyphSize, boxScale, overscaling); + shortLine, smallSpacing, static_cast(M_PI), textLeft, textRight, iconLeft, iconRight, glyphSize, boxScale, overscaling); const Anchors expected_anchors = {Anchor(1.0f, 2.0f, 1.570796371f, 0u)}; EXPECT_EQ(anchors, expected_anchors); @@ -111,20 +111,20 @@ TEST(getAnchors, UseMidpointForShortLine) { TEST(getAnchors, GetCenterAnchor) { const GeometryCoordinates line = { Point{1, 1}, Point{1, 3}, Point{3, 6}, Point{4, 7}}; - const auto anchor = getCenterAnchor(line, M_PI, textLeft, textRight, iconLeft, iconRight, glyphSize, boxScale); + const auto anchor = getCenterAnchor(line, static_cast(M_PI), textLeft, textRight, iconLeft, iconRight, glyphSize, boxScale); EXPECT_TRUE(anchor); EXPECT_EQ(*anchor, Anchor(2.0f, 4.0f, .982793748f, 1u)); } TEST(getAnchors, GetCenterAnchorOutsideTileBounds) { const GeometryCoordinates line = {Point{-10, -10}, Point{5, 5}}; - const auto anchor = getCenterAnchor(line, M_PI, textLeft, textRight, iconLeft, iconRight, glyphSize, boxScale); + const auto anchor = getCenterAnchor(line, static_cast(M_PI), textLeft, textRight, iconLeft, iconRight, glyphSize, boxScale); EXPECT_TRUE(anchor); EXPECT_EQ(*anchor, Anchor(-3.0f, -3.0f, .785398185f, 0u)); } TEST(getAnchors, GetCenterAnchorFailMaxAngle) { const GeometryCoordinates line = {Point{1, 1}, Point{1, 3}, Point{3, 3}}; - const auto anchor = getCenterAnchor(line, M_PI / 4, textLeft, textRight, iconLeft, iconRight, glyphSize, boxScale); + const auto anchor = getCenterAnchor(line, static_cast(M_PI) / 4, textLeft, textRight, iconLeft, iconRight, glyphSize, boxScale); EXPECT_FALSE(anchor); } diff --git a/test/text/glyph_manager.test.cpp b/test/text/glyph_manager.test.cpp index 1e9aef38e..56af4ae6a 100644 --- a/test/text/glyph_manager.test.cpp +++ b/test/text/glyph_manager.test.cpp @@ -255,7 +255,7 @@ TEST(GlyphManager, LoadLocalCJKGlyph) { TEST(GlyphManager, LoadLocalCJKGlyphAfterLoadingRangeFromURL) { GlyphManagerTest test; - int firstGlyphResponse = false; + bool firstGlyphResponse = false; test.fileSource.glyphsResponse = [&] (const Resource&) { firstGlyphResponse = true; diff --git a/test/text/quads.test.cpp b/test/text/quads.test.cpp index a95379a5d..f4ce9cb0a 100644 --- a/test/text/quads.test.cpp +++ b/test/text/quads.test.cpp @@ -86,13 +86,13 @@ TEST(getIconQuads, style) { ASSERT_EQ(quads.size(), 1); const auto& quad = quads[0]; - EXPECT_FLOAT_EQ(quad.tl.x, -64.4444427); + EXPECT_FLOAT_EQ(quad.tl.x, -64.4444427f); EXPECT_FLOAT_EQ(quad.tl.y, 0); - EXPECT_FLOAT_EQ(quad.tr.x, 24.4444427); + EXPECT_FLOAT_EQ(quad.tr.x, 24.4444427f); EXPECT_FLOAT_EQ(quad.tr.y, 0); - EXPECT_FLOAT_EQ(quad.bl.x, -64.4444427); + EXPECT_FLOAT_EQ(quad.bl.x, -64.4444427f); EXPECT_FLOAT_EQ(quad.bl.y, 20); - EXPECT_FLOAT_EQ(quad.br.x, 24.4444427); + EXPECT_FLOAT_EQ(quad.br.x, 24.4444427f); EXPECT_FLOAT_EQ(quad.br.y, 20); } @@ -105,13 +105,13 @@ TEST(getIconQuads, style) { ASSERT_EQ(quads.size(), 1); const auto& quad = quads[0]; - EXPECT_FLOAT_EQ(quad.tl.x, -32.2222214); + EXPECT_FLOAT_EQ(quad.tl.x, -32.2222214f); EXPECT_FLOAT_EQ(quad.tl.y, -5); - EXPECT_FLOAT_EQ(quad.tr.x, 12.2222214); + EXPECT_FLOAT_EQ(quad.tr.x, 12.2222214f); EXPECT_FLOAT_EQ(quad.tr.y, -5); - EXPECT_FLOAT_EQ(quad.bl.x, -32.2222214); + EXPECT_FLOAT_EQ(quad.bl.x, -32.2222214f); EXPECT_FLOAT_EQ(quad.bl.y, 15); - EXPECT_FLOAT_EQ(quad.br.x, 12.2222214); + EXPECT_FLOAT_EQ(quad.br.x, 12.2222214f); EXPECT_FLOAT_EQ(quad.br.y, 15); } @@ -124,13 +124,13 @@ TEST(getIconQuads, style) { ASSERT_EQ(quads.size(), 1); const auto& quad = quads[0]; - EXPECT_FLOAT_EQ(quad.tl.x, -43.3333321); + EXPECT_FLOAT_EQ(quad.tl.x, -43.3333321f); EXPECT_FLOAT_EQ(quad.tl.y, -5); - EXPECT_FLOAT_EQ(quad.tr.x, 23.3333321); + EXPECT_FLOAT_EQ(quad.tr.x, 23.3333321f); EXPECT_FLOAT_EQ(quad.tr.y, -5); - EXPECT_FLOAT_EQ(quad.bl.x, -43.3333321); + EXPECT_FLOAT_EQ(quad.bl.x, -43.3333321f); EXPECT_FLOAT_EQ(quad.bl.y, 15); - EXPECT_FLOAT_EQ(quad.br.x, 23.3333321); + EXPECT_FLOAT_EQ(quad.br.x, 23.3333321f); EXPECT_FLOAT_EQ(quad.br.y, 15); } @@ -144,13 +144,13 @@ TEST(getIconQuads, style) { const auto& quad = quads[0]; EXPECT_FLOAT_EQ(quad.tl.x, -30); - EXPECT_FLOAT_EQ(quad.tl.y, -12.2222214); + EXPECT_FLOAT_EQ(quad.tl.y, -12.2222214f); EXPECT_FLOAT_EQ(quad.tr.x, -10); - EXPECT_FLOAT_EQ(quad.tr.y, -12.2222214); + EXPECT_FLOAT_EQ(quad.tr.y, -12.2222214f); EXPECT_FLOAT_EQ(quad.bl.x, -30); - EXPECT_FLOAT_EQ(quad.bl.y, 32.2222214); + EXPECT_FLOAT_EQ(quad.bl.y, 32.2222214f); EXPECT_FLOAT_EQ(quad.br.x, -10); - EXPECT_FLOAT_EQ(quad.br.y, 32.2222214); + EXPECT_FLOAT_EQ(quad.br.y, 32.2222214f); } // height x textSize @@ -164,13 +164,13 @@ TEST(getIconQuads, style) { const auto& quad = quads[0]; EXPECT_FLOAT_EQ(quad.tl.x, -20); - EXPECT_FLOAT_EQ(quad.tl.y, -6.11111069); + EXPECT_FLOAT_EQ(quad.tl.y, -6.11111069f); EXPECT_FLOAT_EQ(quad.tr.x, 0); - EXPECT_FLOAT_EQ(quad.tr.y, -6.11111069); + EXPECT_FLOAT_EQ(quad.tr.y, -6.11111069f); EXPECT_FLOAT_EQ(quad.bl.x, -20); - EXPECT_FLOAT_EQ(quad.bl.y, 16.1111107); + EXPECT_FLOAT_EQ(quad.bl.y, 16.1111107f); EXPECT_FLOAT_EQ(quad.br.x, 0); - EXPECT_FLOAT_EQ(quad.br.y, 16.1111107); + EXPECT_FLOAT_EQ(quad.br.y, 16.1111107f); } // height x textSize + padding @@ -183,13 +183,13 @@ TEST(getIconQuads, style) { const auto& quad = quads[0]; EXPECT_FLOAT_EQ(quad.tl.x, -20); - EXPECT_FLOAT_EQ(quad.tl.y, -11.666666); + EXPECT_FLOAT_EQ(quad.tl.y, -11.666666f); EXPECT_FLOAT_EQ(quad.tr.x, 0); - EXPECT_FLOAT_EQ(quad.tr.y, -11.666666); + EXPECT_FLOAT_EQ(quad.tr.y, -11.666666f); EXPECT_FLOAT_EQ(quad.bl.x, -20); - EXPECT_FLOAT_EQ(quad.bl.y, 21.666666); + EXPECT_FLOAT_EQ(quad.bl.y, 21.666666f); EXPECT_FLOAT_EQ(quad.br.x, 0); - EXPECT_FLOAT_EQ(quad.br.y, 21.666666); + EXPECT_FLOAT_EQ(quad.br.y, 21.666666f); } // both @@ -201,14 +201,14 @@ TEST(getIconQuads, style) { ASSERT_EQ(quads.size(), 1); const auto& quad = quads[0]; - EXPECT_FLOAT_EQ(quad.tl.x, -64.4444427); - EXPECT_FLOAT_EQ(quad.tl.y, -12.2222214); - EXPECT_FLOAT_EQ(quad.tr.x, 24.4444427); - EXPECT_FLOAT_EQ(quad.tr.y, -12.2222214); - EXPECT_FLOAT_EQ(quad.bl.x, -64.4444427); - EXPECT_FLOAT_EQ(quad.bl.y, 32.2222214); - EXPECT_FLOAT_EQ(quad.br.x, 24.4444427); - EXPECT_FLOAT_EQ(quad.br.y, 32.2222214); + EXPECT_FLOAT_EQ(quad.tl.x, -64.4444427f); + EXPECT_FLOAT_EQ(quad.tl.y, -12.2222214f); + EXPECT_FLOAT_EQ(quad.tr.x, 24.4444427f); + EXPECT_FLOAT_EQ(quad.tr.y, -12.2222214f); + EXPECT_FLOAT_EQ(quad.bl.x, -64.4444427f); + EXPECT_FLOAT_EQ(quad.bl.y, 32.2222214f); + EXPECT_FLOAT_EQ(quad.br.x, 24.4444427f); + EXPECT_FLOAT_EQ(quad.br.y, 32.2222214f); } // both x textSize @@ -220,14 +220,14 @@ TEST(getIconQuads, style) { ASSERT_EQ(quads.size(), 1); const auto& quad = quads[0]; - EXPECT_FLOAT_EQ(quad.tl.x, -32.2222214); - EXPECT_FLOAT_EQ(quad.tl.y, -6.11111069); - EXPECT_FLOAT_EQ(quad.tr.x, 12.2222214); - EXPECT_FLOAT_EQ(quad.tr.y, -6.11111069); - EXPECT_FLOAT_EQ(quad.bl.x, -32.2222214); - EXPECT_FLOAT_EQ(quad.bl.y, 16.1111107); - EXPECT_FLOAT_EQ(quad.br.x, 12.2222214); - EXPECT_FLOAT_EQ(quad.br.y, 16.1111107); + EXPECT_FLOAT_EQ(quad.tl.x, -32.2222214f); + EXPECT_FLOAT_EQ(quad.tl.y, -6.11111069f); + EXPECT_FLOAT_EQ(quad.tr.x, 12.2222214f); + EXPECT_FLOAT_EQ(quad.tr.y, -6.11111069f); + EXPECT_FLOAT_EQ(quad.bl.x, -32.2222214f); + EXPECT_FLOAT_EQ(quad.bl.y, 16.1111107f); + EXPECT_FLOAT_EQ(quad.br.x, 12.2222214f); + EXPECT_FLOAT_EQ(quad.br.y, 16.1111107f); } // both x textSize + padding @@ -239,14 +239,14 @@ TEST(getIconQuads, style) { ASSERT_EQ(quads.size(), 1); const auto& quad = quads[0]; - EXPECT_FLOAT_EQ(quad.tl.x, -43.3333321); - EXPECT_FLOAT_EQ(quad.tl.y, -11.666666); - EXPECT_FLOAT_EQ(quad.tr.x, 23.3333321); - EXPECT_FLOAT_EQ(quad.tr.y, -11.666666); - EXPECT_FLOAT_EQ(quad.bl.x, -43.3333321); - EXPECT_FLOAT_EQ(quad.bl.y, 21.666666); - EXPECT_FLOAT_EQ(quad.br.x, 23.3333321); - EXPECT_FLOAT_EQ(quad.br.y, 21.666666); + EXPECT_FLOAT_EQ(quad.tl.x, -43.3333321f); + EXPECT_FLOAT_EQ(quad.tl.y, -11.666666f); + EXPECT_FLOAT_EQ(quad.tr.x, 23.3333321f); + EXPECT_FLOAT_EQ(quad.tr.y, -11.666666f); + EXPECT_FLOAT_EQ(quad.bl.x, -43.3333321f); + EXPECT_FLOAT_EQ(quad.bl.y, 21.666666f); + EXPECT_FLOAT_EQ(quad.br.x, 23.3333321f); + EXPECT_FLOAT_EQ(quad.br.y, 21.666666f); } // both x textSize + padding t/r/b/l @@ -260,13 +260,13 @@ TEST(getIconQuads, style) { ASSERT_EQ(quads.size(), 1); const auto& quad = quads[0]; - EXPECT_FLOAT_EQ(quad.tl.x, -48.3333321); - EXPECT_FLOAT_EQ(quad.tl.y, -6.66666603); - EXPECT_FLOAT_EQ(quad.tr.x, 18.3333321); - EXPECT_FLOAT_EQ(quad.tr.y, -6.66666603); - EXPECT_FLOAT_EQ(quad.bl.x, -48.3333321); - EXPECT_FLOAT_EQ(quad.bl.y, 26.666666); - EXPECT_FLOAT_EQ(quad.br.x, 18.3333321); - EXPECT_FLOAT_EQ(quad.br.y, 26.666666); + EXPECT_FLOAT_EQ(quad.tl.x, -48.3333321f); + EXPECT_FLOAT_EQ(quad.tl.y, -6.66666603f); + EXPECT_FLOAT_EQ(quad.tr.x, 18.3333321f); + EXPECT_FLOAT_EQ(quad.tr.y, -6.66666603f); + EXPECT_FLOAT_EQ(quad.bl.x, -48.3333321f); + EXPECT_FLOAT_EQ(quad.bl.y, 26.666666f); + EXPECT_FLOAT_EQ(quad.br.x, 18.3333321f); + EXPECT_FLOAT_EQ(quad.br.y, 26.666666f); } } diff --git a/test/util/memory.test.cpp b/test/util/memory.test.cpp index 8ed1c0a44..40dbad34f 100644 --- a/test/util/memory.test.cpp +++ b/test/util/memory.test.cpp @@ -161,14 +161,14 @@ TEST(Memory, Footprint) { std::vector> maps; unsigned runs = 15; - long vectorInitialRSS = mbgl::test::getCurrentRSS(); + size_t vectorInitialRSS = mbgl::test::getCurrentRSS(); for (unsigned i = 0; i < runs; ++i) { maps.emplace_back(std::make_unique(test, "maptiler://maps/streets")); } double vectorFootprint = (mbgl::test::getCurrentRSS() - vectorInitialRSS) / double(runs); - long rasterInitialRSS = mbgl::test::getCurrentRSS(); + size_t rasterInitialRSS = mbgl::test::getCurrentRSS(); for (unsigned i = 0; i < runs; ++i) { maps.emplace_back(std::make_unique(test, "maptiler://maps/hybrid")); }