mirror of
https://github.com/SFML/SFML.git
synced 2024-11-28 14:21:04 +08:00
Remove unnecessary static_cast
s
This commit is contained in:
parent
bf3fb0bc3e
commit
56f9ee2b40
@ -608,7 +608,7 @@ Glyph Font::loadGlyph(std::uint32_t codePoint, unsigned int characterSize, bool
|
|||||||
glyph.bounds.size = Vector2f(Vector2u(bitmap.width, bitmap.rows));
|
glyph.bounds.size = Vector2f(Vector2u(bitmap.width, bitmap.rows));
|
||||||
|
|
||||||
// Resize the pixel buffer to the new size and fill it with transparent white pixels
|
// Resize the pixel buffer to the new size and fill it with transparent white pixels
|
||||||
m_pixelBuffer.resize(static_cast<std::size_t>(size.x) * static_cast<std::size_t>(size.y) * 4);
|
m_pixelBuffer.resize(std::size_t{size.x} * std::size_t{size.y} * 4);
|
||||||
|
|
||||||
std::uint8_t* current = m_pixelBuffer.data();
|
std::uint8_t* current = m_pixelBuffer.data();
|
||||||
std::uint8_t* end = current + size.x * size.y * 4;
|
std::uint8_t* end = current + size.x * size.y * 4;
|
||||||
|
@ -141,7 +141,7 @@ void Image::resize(Vector2u size, Color color)
|
|||||||
if (size.x && size.y)
|
if (size.x && size.y)
|
||||||
{
|
{
|
||||||
// Create a new pixel buffer first for exception safety's sake
|
// Create a new pixel buffer first for exception safety's sake
|
||||||
std::vector<std::uint8_t> newPixels(static_cast<std::size_t>(size.x) * static_cast<std::size_t>(size.y) * 4);
|
std::vector<std::uint8_t> newPixels(std::size_t{size.x} * std::size_t{size.y} * 4);
|
||||||
|
|
||||||
// Fill it with the specified color
|
// Fill it with the specified color
|
||||||
std::uint8_t* ptr = newPixels.data();
|
std::uint8_t* ptr = newPixels.data();
|
||||||
|
@ -53,7 +53,7 @@
|
|||||||
|
|
||||||
#if defined(SFML_SYSTEM_MACOS) || defined(SFML_SYSTEM_IOS)
|
#if defined(SFML_SYSTEM_MACOS) || defined(SFML_SYSTEM_IOS)
|
||||||
|
|
||||||
#define castToGlHandle(x) reinterpret_cast<GLEXT_GLhandle>(static_cast<std::ptrdiff_t>(x))
|
#define castToGlHandle(x) reinterpret_cast<GLEXT_GLhandle>(std::ptrdiff_t{x})
|
||||||
#define castFromGlHandle(x) static_cast<unsigned int>(reinterpret_cast<std::ptrdiff_t>(x))
|
#define castFromGlHandle(x) static_cast<unsigned int>(reinterpret_cast<std::ptrdiff_t>(x))
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
@ -83,7 +83,7 @@ bool CursorImpl::loadFromPixelsARGB(const std::uint8_t* pixels, Vector2u size, V
|
|||||||
cursorImage->xhot = hotspot.x;
|
cursorImage->xhot = hotspot.x;
|
||||||
cursorImage->yhot = hotspot.y;
|
cursorImage->yhot = hotspot.y;
|
||||||
|
|
||||||
const std::size_t numPixels = static_cast<std::size_t>(size.x) * static_cast<std::size_t>(size.y);
|
const std::size_t numPixels = std::size_t{size.x} * std::size_t{size.y};
|
||||||
for (std::size_t pixelIndex = 0; pixelIndex < numPixels; ++pixelIndex)
|
for (std::size_t pixelIndex = 0; pixelIndex < numPixels; ++pixelIndex)
|
||||||
{
|
{
|
||||||
cursorImage->pixels[pixelIndex] = static_cast<std::uint32_t>(
|
cursorImage->pixels[pixelIndex] = static_cast<std::uint32_t>(
|
||||||
|
@ -974,10 +974,9 @@ void WindowImplX11::setIcon(Vector2u size, const std::uint8_t* pixels)
|
|||||||
// X11 wants BGRA pixels: swap red and blue channels
|
// X11 wants BGRA pixels: swap red and blue channels
|
||||||
// Note: this memory will be freed by X11Ptr<XImage> deleter
|
// Note: this memory will be freed by X11Ptr<XImage> deleter
|
||||||
// NOLINTBEGIN(cppcoreguidelines-no-malloc)
|
// NOLINTBEGIN(cppcoreguidelines-no-malloc)
|
||||||
auto* iconPixels = static_cast<std::uint8_t*>(
|
auto* iconPixels = static_cast<std::uint8_t*>(std::malloc(std::size_t{size.x} * std::size_t{size.y} * 4));
|
||||||
std::malloc(static_cast<std::size_t>(size.x) * static_cast<std::size_t>(size.y) * 4));
|
|
||||||
// NOLINTEND(cppcoreguidelines-no-malloc)
|
// NOLINTEND(cppcoreguidelines-no-malloc)
|
||||||
for (std::size_t i = 0; i < static_cast<std::size_t>(size.x) * static_cast<std::size_t>(size.y); ++i)
|
for (std::size_t i = 0; i < std::size_t{size.x} * std::size_t{size.y}; ++i)
|
||||||
{
|
{
|
||||||
iconPixels[i * 4 + 0] = pixels[i * 4 + 2];
|
iconPixels[i * 4 + 0] = pixels[i * 4 + 2];
|
||||||
iconPixels[i * 4 + 1] = pixels[i * 4 + 1];
|
iconPixels[i * 4 + 1] = pixels[i * 4 + 1];
|
||||||
@ -1052,7 +1051,7 @@ void WindowImplX11::setIcon(Vector2u size, const std::uint8_t* pixels)
|
|||||||
*ptr++ = size.y;
|
*ptr++ = size.y;
|
||||||
#pragma GCC diagnostic pop
|
#pragma GCC diagnostic pop
|
||||||
|
|
||||||
for (std::size_t i = 0; i < static_cast<std::size_t>(size.x) * static_cast<std::size_t>(size.y); ++i)
|
for (std::size_t i = 0; i < std::size_t{size.x} * std::size_t{size.y}; ++i)
|
||||||
{
|
{
|
||||||
*ptr++ = static_cast<unsigned long>(
|
*ptr++ = static_cast<unsigned long>(
|
||||||
(pixels[i * 4 + 2] << 0) | (pixels[i * 4 + 1] << 8) | (pixels[i * 4 + 0] << 16) | (pixels[i * 4 + 3] << 24));
|
(pixels[i * 4 + 2] << 0) | (pixels[i * 4 + 1] << 8) | (pixels[i * 4 + 0] << 16) | (pixels[i * 4 + 3] << 24));
|
||||||
|
Loading…
Reference in New Issue
Block a user