Remove unnecessary ternaries

It's simpler to let the boolean get promoted to an integer
This commit is contained in:
Chris Thrasher 2024-09-29 12:05:18 -06:00
parent 053ef0b483
commit ea08388e7a
7 changed files with 10 additions and 10 deletions

View File

@ -683,7 +683,7 @@ void DRMContext::display()
////////////////////////////////////////////////////////////
void DRMContext::setVerticalSyncEnabled(bool enabled)
{
eglCheck(eglSwapInterval(m_display, enabled ? 1 : 0));
eglCheck(eglSwapInterval(m_display, enabled));
}

View File

@ -253,7 +253,7 @@ void EglContext::display()
////////////////////////////////////////////////////////////
void EglContext::setVerticalSyncEnabled(bool enabled)
{
eglCheck(eglSwapInterval(m_display, enabled ? 1 : 0));
eglCheck(eglSwapInterval(m_display, enabled));
}

View File

@ -120,14 +120,14 @@ bool CursorImpl::loadFromPixelsMonochrome(const std::uint8_t* pixels, Vector2u s
const std::size_t bitIndex = i % 8;
// Turn on pixel that are not transparent
const std::uint8_t opacity = pixels[pixelIndex * 4 + 3] > 0 ? 1 : 0;
const std::uint8_t opacity = pixels[pixelIndex * 4 + 3] > 0;
mask[byteIndex] |= static_cast<std::uint8_t>(opacity << bitIndex);
// Choose between black/background & white/foreground color for each pixel,
// based on the pixel color intensity: on average, if a channel is "active"
// at 50%, the bit is white.
const int intensity = (pixels[pixelIndex * 4 + 0] + pixels[pixelIndex * 4 + 1] + pixels[pixelIndex * 4 + 2]) / 3;
const std::uint8_t bit = intensity > 128 ? 1 : 0;
const std::uint8_t bit = intensity > 128;
data[byteIndex] |= static_cast<std::uint8_t>(bit << bitIndex);
}
}

View File

@ -263,15 +263,15 @@ void GlxContext::setVerticalSyncEnabled(bool enabled)
// which would require us to link in an additional library
if (SF_GLAD_GLX_EXT_swap_control)
{
glXSwapIntervalEXT(m_display.get(), m_pbuffer ? m_pbuffer : m_window, enabled ? 1 : 0);
glXSwapIntervalEXT(m_display.get(), m_pbuffer ? m_pbuffer : m_window, enabled);
}
else if (SF_GLAD_GLX_MESA_swap_control)
{
result = glXSwapIntervalMESA(enabled ? 1 : 0);
result = glXSwapIntervalMESA(enabled);
}
else if (SF_GLAD_GLX_SGI_swap_control)
{
result = glXSwapIntervalSGI(enabled ? 1 : 0);
result = glXSwapIntervalSGI(enabled);
}
else
{

View File

@ -1019,7 +1019,7 @@ void WindowImplX11::setIcon(Vector2u size, const std::uint8_t* pixels)
{
if (i * 8 + k < size.x)
{
const std::uint8_t opacity = (pixels[(i * 8 + k + j * size.x) * 4 + 3] > 0) ? 1 : 0;
const std::uint8_t opacity = pixels[(i * 8 + k + j * size.x) * 4 + 3] > 0;
maskPixels[i + j * pitch] |= static_cast<std::uint8_t>(opacity << k);
}
}

View File

@ -237,7 +237,7 @@ void WglContext::setVerticalSyncEnabled(bool enabled)
if (SF_GLAD_WGL_EXT_swap_control)
{
if (wglSwapIntervalEXT(enabled ? 1 : 0) == FALSE)
if (wglSwapIntervalEXT(enabled) == FALSE)
err() << "Setting vertical sync failed: " << getErrorString(GetLastError()) << std::endl;
}
else

View File

@ -146,7 +146,7 @@ void SFContext::display()
void SFContext::setVerticalSyncEnabled(bool enabled)
{
const AutoreleasePool pool;
const GLint swapInterval = enabled ? 1 : 0;
const GLint swapInterval = enabled;
[m_context setValues:&swapInterval forParameter:NSOpenGLCPSwapInterval];
}