diff --git a/libs/drape/glyph_manager.cpp b/libs/drape/glyph_manager.cpp index c475677f9..e939a52b1 100644 --- a/libs/drape/glyph_manager.cpp +++ b/libs/drape/glyph_manager.cpp @@ -240,9 +240,9 @@ FreetypeError constexpr g_FT_Errors[] = auto const & currPos = glyphPos[i]; auto const & metrics = m_fontFace->glyph->metrics; - auto const xOffset = (currPos.x_offset + static_cast(metrics.horiBearingX)) >> 6; + auto const xOffset = static_cast((currPos.x_offset + metrics.horiBearingX) >> 6); // The original Drape code expects a bottom, not a top offset in its calculations. - auto const yOffset = (currPos.y_offset + static_cast(metrics.horiBearingY) - metrics.height) >> 6; + auto const yOffset = static_cast((currPos.y_offset + metrics.horiBearingY - metrics.height) >> 6); int32_t const xAdvance = currPos.x_advance >> 6; // yAdvance is always zero for horizontal text layouts. diff --git a/libs/drape/harfbuzz_shaping.cpp b/libs/drape/harfbuzz_shaping.cpp index 153a8088c..b3211a52e 100644 --- a/libs/drape/harfbuzz_shaping.cpp +++ b/libs/drape/harfbuzz_shaping.cpp @@ -25,8 +25,8 @@ size_t GetScriptExtensions(char32_t codepoint, TScriptsArray & scripts) { // Fill scripts with the script extensions. UErrorCode icu_error = U_ZERO_ERROR; - size_t const count = - uscript_getScriptExtensions(static_cast(codepoint), scripts.data(), scripts.max_size(), &icu_error); + size_t const count = uscript_getScriptExtensions(static_cast(codepoint), scripts.data(), + static_cast(scripts.max_size()), &icu_error); if (U_FAILURE(icu_error)) { LOG(LWARNING, ("uscript_getScriptExtensions failed with error", icu_error)); diff --git a/libs/drape/mesh_object.cpp b/libs/drape/mesh_object.cpp index 9211a0d43..554075b30 100644 --- a/libs/drape/mesh_object.cpp +++ b/libs/drape/mesh_object.cpp @@ -52,7 +52,8 @@ public: { m_indexBuffer = GLFunctions::glGenBuffer(); GLFunctions::glBindBuffer(m_indexBuffer, gl_const::GLElementArrayBuffer); - GLFunctions::glBufferData(gl_const::GLElementArrayBuffer, m_mesh->m_indices.size() * sizeof(uint16_t), + GLFunctions::glBufferData(gl_const::GLElementArrayBuffer, + static_cast(m_mesh->m_indices.size() * sizeof(uint16_t)), m_mesh->m_indices.data(), gl_const::GLStaticDraw); } @@ -113,7 +114,8 @@ public: CHECK(!m_mesh->m_indices.empty(), ()); CHECK(m_indexBuffer, ("Index buffer was not created")); GLFunctions::glBindBuffer(m_indexBuffer, gl_const::GLElementArrayBuffer); - GLFunctions::glBufferData(gl_const::GLElementArrayBuffer, m_mesh->m_indices.size() * sizeof(uint16_t), + GLFunctions::glBufferData(gl_const::GLElementArrayBuffer, + static_cast(m_mesh->m_indices.size() * sizeof(uint16_t)), m_mesh->m_indices.data(), gl_const::GLStaticDraw); GLFunctions::glBindBuffer(0, gl_const::GLElementArrayBuffer); } diff --git a/libs/drape/metal/metal_base_context.mm b/libs/drape/metal/metal_base_context.mm index a15cf1bf0..e89bd97a3 100644 --- a/libs/drape/metal/metal_base_context.mm +++ b/libs/drape/metal/metal_base_context.mm @@ -259,8 +259,7 @@ void MetalBaseContext::Clear(uint32_t clearBits, uint32_t storeBits) void MetalBaseContext::SetViewport(uint32_t x, uint32_t y, uint32_t w, uint32_t h) { id encoder = GetCommandEncoder(); - [encoder setViewport:{static_cast(x), static_cast(y), static_cast(w), static_cast(h), - 0.0, 1.0}]; + [encoder setViewport:MTLViewport(x, y, w, h, 0.0, 1.0)]; [encoder setScissorRect:{x, y, w, h}]; } @@ -269,12 +268,16 @@ void MetalBaseContext::SetScissor(uint32_t x, uint32_t y, uint32_t w, uint32_t h id encoder = GetCommandEncoder(); if (m_renderPassDescriptor.colorAttachments[0].texture != nil) { - uint32_t const rpWidth = m_renderPassDescriptor.colorAttachments[0].texture.width; - uint32_t const rpHeight = m_renderPassDescriptor.colorAttachments[0].texture.height; - if (x < 0) x = 0; - if (y < 0) y = 0; - if (x + w > rpWidth) w = rpWidth - x; - if (y + h > rpHeight) h = rpHeight - y; + auto const rpWidth = static_cast(m_renderPassDescriptor.colorAttachments[0].texture.width); + auto const rpHeight = static_cast(m_renderPassDescriptor.colorAttachments[0].texture.height); + if (x < 0) + x = 0; + if (y < 0) + y = 0; + if (x + w > rpWidth) + w = rpWidth - x; + if (y + h > rpHeight) + h = rpHeight - y; [encoder setScissorRect:{x, y, w, h}]; } diff --git a/libs/drape/vulkan/vulkan_mesh_object_impl.cpp b/libs/drape/vulkan/vulkan_mesh_object_impl.cpp index cd2955a88..c137d686e 100644 --- a/libs/drape/vulkan/vulkan_mesh_object_impl.cpp +++ b/libs/drape/vulkan/vulkan_mesh_object_impl.cpp @@ -110,7 +110,7 @@ public: void UpdateIndexBuffer(ref_ptr context) override { CHECK(!m_mesh->m_indices.empty(), ()); - auto const sizeInBytes = m_mesh->m_indices.size() * sizeof(uint16_t); + auto const sizeInBytes = static_cast(m_mesh->m_indices.size() * sizeof(uint16_t)); CHECK(m_indexBuffer.m_buffer != VK_NULL_HANDLE, ()); UpdateBufferInternal(context, m_indexBuffer.m_buffer, VK_ACCESS_INDEX_READ_BIT, m_mesh->m_indices.data(), @@ -169,7 +169,8 @@ private: buffers.emplace_back(m_geometryBuffers[i].m_buffer); offsets.emplace_back(0); } - vkCmdBindVertexBuffers(commandBuffer, 0, m_geometryBuffers.size(), buffers.data(), offsets.data()); + vkCmdBindVertexBuffers(commandBuffer, 0, static_cast(m_geometryBuffers.size()), buffers.data(), + offsets.data()); } void UpdateBufferInternal(ref_ptr context, VkBuffer buffer, VkAccessFlagBits bufferAccessMask, diff --git a/libs/drape_frontend/gui/ruler_helper.cpp b/libs/drape_frontend/gui/ruler_helper.cpp index a4235fb76..a5c515a41 100644 --- a/libs/drape_frontend/gui/ruler_helper.cpp +++ b/libs/drape_frontend/gui/ruler_helper.cpp @@ -72,7 +72,7 @@ RulerHelper::RulerHelper() void RulerHelper::Update(ScreenBase const & screen) { m2::PointD pivot = screen.PixelRect().Center(); - int const minPxWidth = std::lround(kMinPixelWidth * df::VisualParams::Instance().GetVisualScale()); + long const minPxWidth = std::lround(kMinPixelWidth * df::VisualParams::Instance().GetVisualScale()); m2::PointD pt1 = screen.PtoG(pivot); m2::PointD pt0 = screen.PtoG(pivot - m2::PointD(minPxWidth, 0)); diff --git a/libs/drape_frontend/traffic_renderer.cpp b/libs/drape_frontend/traffic_renderer.cpp index 4fb566921..40edb4e8b 100644 --- a/libs/drape_frontend/traffic_renderer.cpp +++ b/libs/drape_frontend/traffic_renderer.cpp @@ -306,7 +306,7 @@ bool TrafficRenderer::CanBeRenderedAsLine(RoadClass const & roadClass, int zoomL if (it == lineDrawerEnd) return false; - width = std::max(1l, std::lround(TrafficRenderer::GetPixelWidthInternal(roadClass, zoomLevel))); + width = std::max(1, static_cast(std::lround(TrafficRenderer::GetPixelWidthInternal(roadClass, zoomLevel)))); return width <= dp::SupportManager::Instance().GetMaxLineWidth(); } } // namespace df diff --git a/libs/drape_frontend/visual_params.cpp b/libs/drape_frontend/visual_params.cpp index 2c00cb2bc..250c795d8 100644 --- a/libs/drape_frontend/visual_params.cpp +++ b/libs/drape_frontend/visual_params.cpp @@ -180,7 +180,7 @@ int GetTileScaleBase(m2::RectD const & r) { double const sz = std::max(r.SizeX(), r.SizeY()); ASSERT_GREATER(sz, 0., ("Rect should not be a point:", r)); - return std::max(1l, std::lround(std::log2(mercator::Bounds::kRangeX / sz))); + return std::max(1, static_cast(std::lround(std::log2(mercator::Bounds::kRangeX / sz)))); } double GetTileScaleBase(double drawScale) diff --git a/libs/ge0/url_generator.cpp b/libs/ge0/url_generator.cpp index c2e1d31f9..52e8d6de2 100644 --- a/libs/ge0/url_generator.cpp +++ b/libs/ge0/url_generator.cpp @@ -158,7 +158,7 @@ int LatToInt(double lat, int maxValue) // 000111111222222...LLLLLMMMM double const x = (lat + 90.0) / 180.0 * maxValue; - return x < 0 ? 0 : (x > maxValue ? maxValue : std::lround(x)); + return x < 0 ? 0 : (x > maxValue ? maxValue : static_cast(std::lround(x))); } // Make lon in [-180, 180) diff --git a/libs/geometry/screenbase.cpp b/libs/geometry/screenbase.cpp index a9db15944..d5b6673a6 100644 --- a/libs/geometry/screenbase.cpp +++ b/libs/geometry/screenbase.cpp @@ -230,12 +230,12 @@ void ScreenBase::SetAngle(double angle) int ScreenBase::GetWidth() const { - return std::lround(m_PixelRect.SizeX()); + return static_cast(std::lround(m_PixelRect.SizeX())); } int ScreenBase::GetHeight() const { - return std::lround(m_PixelRect.SizeY()); + return static_cast(std::lround(m_PixelRect.SizeY())); } ScreenBase::MatrixT ScreenBase::CalcTransform(m2::PointD const & oldPt1, m2::PointD const & oldPt2, diff --git a/libs/indexer/scales.cpp b/libs/indexer/scales.cpp index 9c89c69a7..25bcbb4e9 100644 --- a/libs/indexer/scales.cpp +++ b/libs/indexer/scales.cpp @@ -33,12 +33,12 @@ double GetScaleLevelD(m2::RectD const & r) int GetScaleLevel(double ratio) { - return std::lround(GetScaleLevelD(ratio)); + return static_cast(std::lround(GetScaleLevelD(ratio))); } int GetScaleLevel(m2::RectD const & r) { - return std::lround(GetScaleLevelD(r)); + return static_cast(std::lround(GetScaleLevelD(r))); } namespace diff --git a/libs/platform/measurement_utils.cpp b/libs/platform/measurement_utils.cpp index 94000e157..f0b1474ee 100644 --- a/libs/platform/measurement_utils.cpp +++ b/libs/platform/measurement_utils.cpp @@ -198,7 +198,7 @@ double MpsToUnits(double metersPerSecond, Units units) UNREACHABLE(); } -int FormatSpeed(double metersPerSecond, Units units) +long FormatSpeed(double metersPerSecond, Units units) { return std::lround(MpsToUnits(metersPerSecond, units)); } @@ -214,8 +214,8 @@ std::string FormatOsmLink(double lat, double lon, int zoom) // Same as (lon + 180) / 360 * 1UL << 32, but without warnings. double constexpr factor = (1 << 30) / 90.0; - uint32_t const x = std::lround((lon + 180.0) * factor); - uint32_t const y = std::lround((lat + 90.0) * factor * 2.0); + auto const x = static_cast(std::lround((lon + 180.0) * factor)); + auto const y = static_cast(std::lround((lat + 90.0) * factor * 2.0)); uint64_t const code = bits::BitwiseMerge(y, x); std::string osmUrl = "https://osm.org/go/"; diff --git a/libs/platform/measurement_utils.hpp b/libs/platform/measurement_utils.hpp index 6c512df46..9334ae6b3 100644 --- a/libs/platform/measurement_utils.hpp +++ b/libs/platform/measurement_utils.hpp @@ -70,7 +70,7 @@ double ToSpeedKmPH(double speed, Units units); double MpsToUnits(double metersPerSecond, Units units); /// @return Speed value in km/h for Metric and in mph for Imperial. -int FormatSpeed(double metersPerSecond, Units units); +long FormatSpeed(double metersPerSecond, Units units); /// @return Speed value string (without suffix) in km/h for Metric and in mph for Imperial. std::string FormatSpeedNumeric(double metersPerSecond, Units units); diff --git a/libs/routing/turns_tts_text_i18n.cpp b/libs/routing/turns_tts_text_i18n.cpp index cf4966e16..e5ec839f2 100644 --- a/libs/routing/turns_tts_text_i18n.cpp +++ b/libs/routing/turns_tts_text_i18n.cpp @@ -35,7 +35,7 @@ bool EndsInAcronymOrNum(strings::UniString const & myUniStr) bool allUppercaseNum = true; strings::UniString lowerStr = strings::MakeLowerCase(myUniStr); - for (int i = myUniStr.size() - 1; i > 0; i--) + for (long i = myUniStr.size() - 1; i > 0; i--) { // if we've reached a space, we're done here if (myUniStr[i] == ' ') diff --git a/libs/search/ranking_info.cpp b/libs/search/ranking_info.cpp index 60492cbc0..e8c75f6fc 100644 --- a/libs/search/ranking_info.cpp +++ b/libs/search/ranking_info.cpp @@ -29,11 +29,6 @@ double constexpr kCategoriesFalseCats = -1.0000000; double constexpr kDistanceToPivot = -0.48; double constexpr kWalkingDistanceM = 5000.0; -double constexpr AbsPenaltyPerKm() -{ - return -kDistanceToPivot * 1000.0 / RankingInfo::kMaxDistMeters; -} - // These constants are very important and checked in Famous_Cities_Rank test. double constexpr kRank = 0.23; double constexpr kPopularity = 0.42;