mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-19 13:03:36 +00:00
committed by
Konstantin Pastbin
parent
a28d5d15ce
commit
2aaf37e9ee
@@ -240,9 +240,9 @@ FreetypeError constexpr g_FT_Errors[] =
|
|||||||
auto const & currPos = glyphPos[i];
|
auto const & currPos = glyphPos[i];
|
||||||
|
|
||||||
auto const & metrics = m_fontFace->glyph->metrics;
|
auto const & metrics = m_fontFace->glyph->metrics;
|
||||||
auto const xOffset = (currPos.x_offset + static_cast<int32_t>(metrics.horiBearingX)) >> 6;
|
auto const xOffset = static_cast<int32_t>((currPos.x_offset + metrics.horiBearingX) >> 6);
|
||||||
// The original Drape code expects a bottom, not a top offset in its calculations.
|
// The original Drape code expects a bottom, not a top offset in its calculations.
|
||||||
auto const yOffset = (currPos.y_offset + static_cast<int32_t>(metrics.horiBearingY) - metrics.height) >> 6;
|
auto const yOffset = static_cast<int32_t>((currPos.y_offset + metrics.horiBearingY - metrics.height) >> 6);
|
||||||
int32_t const xAdvance = currPos.x_advance >> 6;
|
int32_t const xAdvance = currPos.x_advance >> 6;
|
||||||
// yAdvance is always zero for horizontal text layouts.
|
// yAdvance is always zero for horizontal text layouts.
|
||||||
|
|
||||||
|
|||||||
@@ -25,8 +25,8 @@ size_t GetScriptExtensions(char32_t codepoint, TScriptsArray & scripts)
|
|||||||
{
|
{
|
||||||
// Fill scripts with the script extensions.
|
// Fill scripts with the script extensions.
|
||||||
UErrorCode icu_error = U_ZERO_ERROR;
|
UErrorCode icu_error = U_ZERO_ERROR;
|
||||||
size_t const count =
|
size_t const count = uscript_getScriptExtensions(static_cast<UChar32>(codepoint), scripts.data(),
|
||||||
uscript_getScriptExtensions(static_cast<UChar32>(codepoint), scripts.data(), scripts.max_size(), &icu_error);
|
static_cast<int32_t>(scripts.max_size()), &icu_error);
|
||||||
if (U_FAILURE(icu_error))
|
if (U_FAILURE(icu_error))
|
||||||
{
|
{
|
||||||
LOG(LWARNING, ("uscript_getScriptExtensions failed with error", icu_error));
|
LOG(LWARNING, ("uscript_getScriptExtensions failed with error", icu_error));
|
||||||
|
|||||||
@@ -52,7 +52,8 @@ public:
|
|||||||
{
|
{
|
||||||
m_indexBuffer = GLFunctions::glGenBuffer();
|
m_indexBuffer = GLFunctions::glGenBuffer();
|
||||||
GLFunctions::glBindBuffer(m_indexBuffer, gl_const::GLElementArrayBuffer);
|
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<uint32_t>(m_mesh->m_indices.size() * sizeof(uint16_t)),
|
||||||
m_mesh->m_indices.data(), gl_const::GLStaticDraw);
|
m_mesh->m_indices.data(), gl_const::GLStaticDraw);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -113,7 +114,8 @@ public:
|
|||||||
CHECK(!m_mesh->m_indices.empty(), ());
|
CHECK(!m_mesh->m_indices.empty(), ());
|
||||||
CHECK(m_indexBuffer, ("Index buffer was not created"));
|
CHECK(m_indexBuffer, ("Index buffer was not created"));
|
||||||
GLFunctions::glBindBuffer(m_indexBuffer, gl_const::GLElementArrayBuffer);
|
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<uint32_t>(m_mesh->m_indices.size() * sizeof(uint16_t)),
|
||||||
m_mesh->m_indices.data(), gl_const::GLStaticDraw);
|
m_mesh->m_indices.data(), gl_const::GLStaticDraw);
|
||||||
GLFunctions::glBindBuffer(0, gl_const::GLElementArrayBuffer);
|
GLFunctions::glBindBuffer(0, gl_const::GLElementArrayBuffer);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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)
|
void MetalBaseContext::SetViewport(uint32_t x, uint32_t y, uint32_t w, uint32_t h)
|
||||||
{
|
{
|
||||||
id<MTLRenderCommandEncoder> encoder = GetCommandEncoder();
|
id<MTLRenderCommandEncoder> encoder = GetCommandEncoder();
|
||||||
[encoder setViewport:{static_cast<double>(x), static_cast<double>(y), static_cast<double>(w), static_cast<double>(h),
|
[encoder setViewport:MTLViewport(x, y, w, h, 0.0, 1.0)];
|
||||||
0.0, 1.0}];
|
|
||||||
[encoder setScissorRect:{x, y, w, h}];
|
[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<MTLRenderCommandEncoder> encoder = GetCommandEncoder();
|
id<MTLRenderCommandEncoder> encoder = GetCommandEncoder();
|
||||||
if (m_renderPassDescriptor.colorAttachments[0].texture != nil)
|
if (m_renderPassDescriptor.colorAttachments[0].texture != nil)
|
||||||
{
|
{
|
||||||
uint32_t const rpWidth = m_renderPassDescriptor.colorAttachments[0].texture.width;
|
auto const rpWidth = static_cast<uint32_t>(m_renderPassDescriptor.colorAttachments[0].texture.width);
|
||||||
uint32_t const rpHeight = m_renderPassDescriptor.colorAttachments[0].texture.height;
|
auto const rpHeight = static_cast<uint32_t>(m_renderPassDescriptor.colorAttachments[0].texture.height);
|
||||||
if (x < 0) x = 0;
|
if (x < 0)
|
||||||
if (y < 0) y = 0;
|
x = 0;
|
||||||
if (x + w > rpWidth) w = rpWidth - x;
|
if (y < 0)
|
||||||
if (y + h > rpHeight) h = rpHeight - y;
|
y = 0;
|
||||||
|
if (x + w > rpWidth)
|
||||||
|
w = rpWidth - x;
|
||||||
|
if (y + h > rpHeight)
|
||||||
|
h = rpHeight - y;
|
||||||
|
|
||||||
[encoder setScissorRect:{x, y, w, h}];
|
[encoder setScissorRect:{x, y, w, h}];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ public:
|
|||||||
void UpdateIndexBuffer(ref_ptr<dp::GraphicsContext> context) override
|
void UpdateIndexBuffer(ref_ptr<dp::GraphicsContext> context) override
|
||||||
{
|
{
|
||||||
CHECK(!m_mesh->m_indices.empty(), ());
|
CHECK(!m_mesh->m_indices.empty(), ());
|
||||||
auto const sizeInBytes = m_mesh->m_indices.size() * sizeof(uint16_t);
|
auto const sizeInBytes = static_cast<uint32_t>(m_mesh->m_indices.size() * sizeof(uint16_t));
|
||||||
CHECK(m_indexBuffer.m_buffer != VK_NULL_HANDLE, ());
|
CHECK(m_indexBuffer.m_buffer != VK_NULL_HANDLE, ());
|
||||||
|
|
||||||
UpdateBufferInternal(context, m_indexBuffer.m_buffer, VK_ACCESS_INDEX_READ_BIT, m_mesh->m_indices.data(),
|
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);
|
buffers.emplace_back(m_geometryBuffers[i].m_buffer);
|
||||||
offsets.emplace_back(0);
|
offsets.emplace_back(0);
|
||||||
}
|
}
|
||||||
vkCmdBindVertexBuffers(commandBuffer, 0, m_geometryBuffers.size(), buffers.data(), offsets.data());
|
vkCmdBindVertexBuffers(commandBuffer, 0, static_cast<uint32_t>(m_geometryBuffers.size()), buffers.data(),
|
||||||
|
offsets.data());
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateBufferInternal(ref_ptr<dp::GraphicsContext> context, VkBuffer buffer, VkAccessFlagBits bufferAccessMask,
|
void UpdateBufferInternal(ref_ptr<dp::GraphicsContext> context, VkBuffer buffer, VkAccessFlagBits bufferAccessMask,
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ RulerHelper::RulerHelper()
|
|||||||
void RulerHelper::Update(ScreenBase const & screen)
|
void RulerHelper::Update(ScreenBase const & screen)
|
||||||
{
|
{
|
||||||
m2::PointD pivot = screen.PixelRect().Center();
|
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 pt1 = screen.PtoG(pivot);
|
||||||
m2::PointD pt0 = screen.PtoG(pivot - m2::PointD(minPxWidth, 0));
|
m2::PointD pt0 = screen.PtoG(pivot - m2::PointD(minPxWidth, 0));
|
||||||
|
|
||||||
|
|||||||
@@ -306,7 +306,7 @@ bool TrafficRenderer::CanBeRenderedAsLine(RoadClass const & roadClass, int zoomL
|
|||||||
if (it == lineDrawerEnd)
|
if (it == lineDrawerEnd)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
width = std::max(1l, std::lround(TrafficRenderer::GetPixelWidthInternal(roadClass, zoomLevel)));
|
width = std::max(1, static_cast<int>(std::lround(TrafficRenderer::GetPixelWidthInternal(roadClass, zoomLevel))));
|
||||||
return width <= dp::SupportManager::Instance().GetMaxLineWidth();
|
return width <= dp::SupportManager::Instance().GetMaxLineWidth();
|
||||||
}
|
}
|
||||||
} // namespace df
|
} // namespace df
|
||||||
|
|||||||
@@ -180,7 +180,7 @@ int GetTileScaleBase(m2::RectD const & r)
|
|||||||
{
|
{
|
||||||
double const sz = std::max(r.SizeX(), r.SizeY());
|
double const sz = std::max(r.SizeX(), r.SizeY());
|
||||||
ASSERT_GREATER(sz, 0., ("Rect should not be a point:", r));
|
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<int>(std::lround(std::log2(mercator::Bounds::kRangeX / sz))));
|
||||||
}
|
}
|
||||||
|
|
||||||
double GetTileScaleBase(double drawScale)
|
double GetTileScaleBase(double drawScale)
|
||||||
|
|||||||
@@ -158,7 +158,7 @@ int LatToInt(double lat, int maxValue)
|
|||||||
// 000111111222222...LLLLLMMMM
|
// 000111111222222...LLLLLMMMM
|
||||||
|
|
||||||
double const x = (lat + 90.0) / 180.0 * maxValue;
|
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<int>(std::lround(x)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make lon in [-180, 180)
|
// Make lon in [-180, 180)
|
||||||
|
|||||||
@@ -230,12 +230,12 @@ void ScreenBase::SetAngle(double angle)
|
|||||||
|
|
||||||
int ScreenBase::GetWidth() const
|
int ScreenBase::GetWidth() const
|
||||||
{
|
{
|
||||||
return std::lround(m_PixelRect.SizeX());
|
return static_cast<int>(std::lround(m_PixelRect.SizeX()));
|
||||||
}
|
}
|
||||||
|
|
||||||
int ScreenBase::GetHeight() const
|
int ScreenBase::GetHeight() const
|
||||||
{
|
{
|
||||||
return std::lround(m_PixelRect.SizeY());
|
return static_cast<int>(std::lround(m_PixelRect.SizeY()));
|
||||||
}
|
}
|
||||||
|
|
||||||
ScreenBase::MatrixT ScreenBase::CalcTransform(m2::PointD const & oldPt1, m2::PointD const & oldPt2,
|
ScreenBase::MatrixT ScreenBase::CalcTransform(m2::PointD const & oldPt1, m2::PointD const & oldPt2,
|
||||||
|
|||||||
@@ -33,12 +33,12 @@ double GetScaleLevelD(m2::RectD const & r)
|
|||||||
|
|
||||||
int GetScaleLevel(double ratio)
|
int GetScaleLevel(double ratio)
|
||||||
{
|
{
|
||||||
return std::lround(GetScaleLevelD(ratio));
|
return static_cast<int>(std::lround(GetScaleLevelD(ratio)));
|
||||||
}
|
}
|
||||||
|
|
||||||
int GetScaleLevel(m2::RectD const & r)
|
int GetScaleLevel(m2::RectD const & r)
|
||||||
{
|
{
|
||||||
return std::lround(GetScaleLevelD(r));
|
return static_cast<int>(std::lround(GetScaleLevelD(r)));
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
|
|||||||
@@ -198,7 +198,7 @@ double MpsToUnits(double metersPerSecond, Units units)
|
|||||||
UNREACHABLE();
|
UNREACHABLE();
|
||||||
}
|
}
|
||||||
|
|
||||||
int FormatSpeed(double metersPerSecond, Units units)
|
long FormatSpeed(double metersPerSecond, Units units)
|
||||||
{
|
{
|
||||||
return std::lround(MpsToUnits(metersPerSecond, 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.
|
// Same as (lon + 180) / 360 * 1UL << 32, but without warnings.
|
||||||
double constexpr factor = (1 << 30) / 90.0;
|
double constexpr factor = (1 << 30) / 90.0;
|
||||||
uint32_t const x = std::lround((lon + 180.0) * factor);
|
auto const x = static_cast<uint32_t>(std::lround((lon + 180.0) * factor));
|
||||||
uint32_t const y = std::lround((lat + 90.0) * factor * 2.0);
|
auto const y = static_cast<uint32_t>(std::lround((lat + 90.0) * factor * 2.0));
|
||||||
uint64_t const code = bits::BitwiseMerge(y, x);
|
uint64_t const code = bits::BitwiseMerge(y, x);
|
||||||
std::string osmUrl = "https://osm.org/go/";
|
std::string osmUrl = "https://osm.org/go/";
|
||||||
|
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ double ToSpeedKmPH(double speed, Units units);
|
|||||||
double MpsToUnits(double metersPerSecond, Units units);
|
double MpsToUnits(double metersPerSecond, Units units);
|
||||||
|
|
||||||
/// @return Speed value in km/h for Metric and in mph for Imperial.
|
/// @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.
|
/// @return Speed value string (without suffix) in km/h for Metric and in mph for Imperial.
|
||||||
std::string FormatSpeedNumeric(double metersPerSecond, Units units);
|
std::string FormatSpeedNumeric(double metersPerSecond, Units units);
|
||||||
|
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ bool EndsInAcronymOrNum(strings::UniString const & myUniStr)
|
|||||||
|
|
||||||
bool allUppercaseNum = true;
|
bool allUppercaseNum = true;
|
||||||
strings::UniString lowerStr = strings::MakeLowerCase(myUniStr);
|
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 we've reached a space, we're done here
|
||||||
if (myUniStr[i] == ' ')
|
if (myUniStr[i] == ' ')
|
||||||
|
|||||||
@@ -29,11 +29,6 @@ double constexpr kCategoriesFalseCats = -1.0000000;
|
|||||||
double constexpr kDistanceToPivot = -0.48;
|
double constexpr kDistanceToPivot = -0.48;
|
||||||
double constexpr kWalkingDistanceM = 5000.0;
|
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.
|
// These constants are very important and checked in Famous_Cities_Rank test.
|
||||||
double constexpr kRank = 0.23;
|
double constexpr kRank = 0.23;
|
||||||
double constexpr kPopularity = 0.42;
|
double constexpr kPopularity = 0.42;
|
||||||
|
|||||||
Reference in New Issue
Block a user