C++ warning fixes

Signed-off-by: Alexander Borsuk <me@alex.bio>
This commit is contained in:
Alexander Borsuk
2025-08-01 13:33:12 +02:00
committed by Konstantin Pastbin
parent a28d5d15ce
commit 2aaf37e9ee
15 changed files with 35 additions and 34 deletions

View File

@@ -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<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.
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;
// yAdvance is always zero for horizontal text layouts.

View File

@@ -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<UChar32>(codepoint), scripts.data(), scripts.max_size(), &icu_error);
size_t const count = uscript_getScriptExtensions(static_cast<UChar32>(codepoint), scripts.data(),
static_cast<int32_t>(scripts.max_size()), &icu_error);
if (U_FAILURE(icu_error))
{
LOG(LWARNING, ("uscript_getScriptExtensions failed with error", icu_error));

View File

@@ -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<uint32_t>(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<uint32_t>(m_mesh->m_indices.size() * sizeof(uint16_t)),
m_mesh->m_indices.data(), gl_const::GLStaticDraw);
GLFunctions::glBindBuffer(0, gl_const::GLElementArrayBuffer);
}

View File

@@ -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<MTLRenderCommandEncoder> encoder = GetCommandEncoder();
[encoder setViewport:{static_cast<double>(x), static_cast<double>(y), static_cast<double>(w), static_cast<double>(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<MTLRenderCommandEncoder> 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<uint32_t>(m_renderPassDescriptor.colorAttachments[0].texture.width);
auto const rpHeight = static_cast<uint32_t>(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}];
}

View File

@@ -110,7 +110,7 @@ public:
void UpdateIndexBuffer(ref_ptr<dp::GraphicsContext> context) override
{
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, ());
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<uint32_t>(m_geometryBuffers.size()), buffers.data(),
offsets.data());
}
void UpdateBufferInternal(ref_ptr<dp::GraphicsContext> context, VkBuffer buffer, VkAccessFlagBits bufferAccessMask,