diff --git a/examples/island/Island.cpp b/examples/island/Island.cpp index 3888fdff9..0c05ba7ba 100644 --- a/examples/island/Island.cpp +++ b/examples/island/Island.cpp @@ -344,7 +344,7 @@ float getMoisture(unsigned int x, unsigned int y) //////////////////////////////////////////////////////////// sf::Color colorFromFloats(float r, float g, float b) { - return sf::Color(static_cast(r), static_cast(g), static_cast(b)); + return sf::Color(static_cast(r), static_cast(g), static_cast(b)); } sf::Color getLowlandsTerrainColor(float moisture) @@ -381,9 +381,9 @@ sf::Color getHighlandsTerrainColor(float elevation, float moisture) float factor = std::min((elevation - 0.4f) / 0.1f, 1.f); - color.r = static_cast(lowlandsColor.r * (1.f - factor) + color.r * factor); - color.g = static_cast(lowlandsColor.g * (1.f - factor) + color.g * factor); - color.b = static_cast(lowlandsColor.b * (1.f - factor) + color.b * factor); + color.r = static_cast(lowlandsColor.r * (1.f - factor) + color.r * factor); + color.g = static_cast(lowlandsColor.g * (1.f - factor) + color.g * factor); + color.b = static_cast(lowlandsColor.b * (1.f - factor) + color.b * factor); return color; } @@ -402,9 +402,9 @@ sf::Color getSnowcapTerrainColor(float elevation, float moisture) float factor = std::min((elevation - snowcapHeight) / 0.05f, 1.f); - color.r = static_cast(highlandsColor.r * (1.f - factor) + color.r * factor); - color.g = static_cast(highlandsColor.g * (1.f - factor) + color.g * factor); - color.b = static_cast(highlandsColor.b * (1.f - factor) + color.b * factor); + color.r = static_cast(highlandsColor.r * (1.f - factor) + color.r * factor); + color.g = static_cast(highlandsColor.g * (1.f - factor) + color.g * factor); + color.b = static_cast(highlandsColor.b * (1.f - factor) + color.b * factor); return color; } @@ -417,15 +417,15 @@ sf::Color getSnowcapTerrainColor(float elevation, float moisture) //////////////////////////////////////////////////////////// sf::Color getTerrainColor(float elevation, float moisture) { - sf::Color color = elevation < 0.11f ? sf::Color(0, 0, static_cast(elevation / 0.11f * 74.f + 181.0f)) + sf::Color color = elevation < 0.11f ? sf::Color(0, 0, static_cast(elevation / 0.11f * 74.f + 181.0f)) : elevation < 0.14f - ? sf::Color(static_cast(std::pow((elevation - 0.11f) / 0.03f, 0.3f) * 48.f), - static_cast(std::pow((elevation - 0.11f) / 0.03f, 0.3f) * 48.f), + ? sf::Color(static_cast(std::pow((elevation - 0.11f) / 0.03f, 0.3f) * 48.f), + static_cast(std::pow((elevation - 0.11f) / 0.03f, 0.3f) * 48.f), 255) : elevation < 0.16f - ? sf::Color(static_cast((elevation - 0.14f) * 128.f / 0.02f + 48.f), - static_cast((elevation - 0.14f) * 128.f / 0.02f + 48.f), - static_cast(127.0f + (0.16f - elevation) * 128.f / 0.02f)) + ? sf::Color(static_cast((elevation - 0.14f) * 128.f / 0.02f + 48.f), + static_cast((elevation - 0.14f) * 128.f / 0.02f + 48.f), + static_cast(127.0f + (0.16f - elevation) * 128.f / 0.02f)) : elevation < 0.17f ? sf::Color(240, 230, 140) : elevation < 0.4f ? getLowlandsTerrainColor(moisture) : elevation < snowcapHeight ? getHighlandsTerrainColor(elevation, moisture) diff --git a/examples/shader/Shader.cpp b/examples/shader/Shader.cpp index d73060426..7986b8a38 100644 --- a/examples/shader/Shader.cpp +++ b/examples/shader/Shader.cpp @@ -145,9 +145,9 @@ public: { auto x = x_distribution(rng); auto y = y_distribution(rng); - auto r = static_cast(color_distribution(rng)); - auto g = static_cast(color_distribution(rng)); - auto b = static_cast(color_distribution(rng)); + auto r = static_cast(color_distribution(rng)); + auto g = static_cast(color_distribution(rng)); + auto b = static_cast(color_distribution(rng)); m_points.append(sf::Vertex(sf::Vector2f(x, y), sf::Color(r, g, b))); } diff --git a/examples/voip/Client.cpp b/examples/voip/Client.cpp index 56c376796..5c89ddfe9 100644 --- a/examples/voip/Client.cpp +++ b/examples/voip/Client.cpp @@ -8,8 +8,8 @@ #include -const sf::Uint8 clientAudioData = 1; -const sf::Uint8 clientEndOfStream = 2; +const std::uint8_t clientAudioData = 1; +const std::uint8_t clientEndOfStream = 2; //////////////////////////////////////////////////////////// diff --git a/examples/voip/Server.cpp b/examples/voip/Server.cpp index 3335823f1..c3aa0cc46 100644 --- a/examples/voip/Server.cpp +++ b/examples/voip/Server.cpp @@ -11,8 +11,8 @@ #include -const sf::Uint8 serverAudioData = 1; -const sf::Uint8 serverEndOfStream = 2; +const std::uint8_t serverAudioData = 1; +const std::uint8_t serverEndOfStream = 2; //////////////////////////////////////////////////////////// @@ -119,7 +119,7 @@ private: break; // Extract the message ID - sf::Uint8 id; + std::uint8_t id; packet >> id; if (id == serverAudioData) diff --git a/include/SFML/Config.hpp b/include/SFML/Config.hpp index fee139b82..baa6f545b 100644 --- a/include/SFML/Config.hpp +++ b/include/SFML/Config.hpp @@ -167,9 +167,6 @@ //////////////////////////////////////////////////////////// namespace sf { -// 8 bits integer types -using Uint8 = std::uint8_t; - // 16 bits integer types using Int16 = std::int16_t; using Uint16 = std::uint16_t; diff --git a/include/SFML/Graphics/Color.hpp b/include/SFML/Graphics/Color.hpp index de497347b..ed3670d93 100644 --- a/include/SFML/Graphics/Color.hpp +++ b/include/SFML/Graphics/Color.hpp @@ -58,7 +58,7 @@ public: /// \param alpha Alpha (opacity) component (in the range [0, 255]) /// //////////////////////////////////////////////////////////// - constexpr Color(Uint8 red, Uint8 green, Uint8 blue, Uint8 alpha = 255); + constexpr Color(std::uint8_t red, std::uint8_t green, std::uint8_t blue, std::uint8_t alpha = 255); //////////////////////////////////////////////////////////// /// \brief Construct the color from 32-bit unsigned integer @@ -92,10 +92,10 @@ public: //////////////////////////////////////////////////////////// // Member data //////////////////////////////////////////////////////////// - Uint8 r; //!< Red component - Uint8 g; //!< Green component - Uint8 b; //!< Blue component - Uint8 a; //!< Alpha (opacity) component + std::uint8_t r; //!< Red component + std::uint8_t g; //!< Green component + std::uint8_t b; //!< Blue component + std::uint8_t a; //!< Alpha (opacity) component }; //////////////////////////////////////////////////////////// diff --git a/include/SFML/Graphics/Color.inl b/include/SFML/Graphics/Color.inl index b63898a65..ad24747b9 100644 --- a/include/SFML/Graphics/Color.inl +++ b/include/SFML/Graphics/Color.inl @@ -30,17 +30,21 @@ constexpr Color::Color() : r(0), g(0), b(0), a(255) //////////////////////////////////////////////////////////// -constexpr Color::Color(Uint8 red, Uint8 green, Uint8 blue, Uint8 alpha) : r(red), g(green), b(blue), a(alpha) +constexpr Color::Color(std::uint8_t red, std::uint8_t green, std::uint8_t blue, std::uint8_t alpha) : +r(red), +g(green), +b(blue), +a(alpha) { } //////////////////////////////////////////////////////////// constexpr Color::Color(Uint32 color) : -r(static_cast((color & 0xff000000) >> 24)), -g(static_cast((color & 0x00ff0000) >> 16)), -b(static_cast((color & 0x0000ff00) >> 8)), -a(static_cast(color & 0x000000ff)) +r(static_cast((color & 0xff000000) >> 24)), +g(static_cast((color & 0x00ff0000) >> 16)), +b(static_cast((color & 0x0000ff00) >> 8)), +a(static_cast(color & 0x000000ff)) { } @@ -69,10 +73,10 @@ constexpr bool operator!=(const Color& left, const Color& right) //////////////////////////////////////////////////////////// constexpr Color operator+(const Color& left, const Color& right) { - const auto clampedAdd = [](Uint8 lhs, Uint8 rhs) -> Uint8 + const auto clampedAdd = [](std::uint8_t lhs, std::uint8_t rhs) -> std::uint8_t { const int intResult = static_cast(lhs) + static_cast(rhs); - return static_cast(intResult < 255 ? intResult : 255); + return static_cast(intResult < 255 ? intResult : 255); }; return Color(clampedAdd(left.r, right.r), @@ -85,10 +89,10 @@ constexpr Color operator+(const Color& left, const Color& right) //////////////////////////////////////////////////////////// constexpr Color operator-(const Color& left, const Color& right) { - const auto clampedSub = [](Uint8 lhs, Uint8 rhs) -> Uint8 + const auto clampedSub = [](std::uint8_t lhs, std::uint8_t rhs) -> std::uint8_t { const int intResult = static_cast(lhs) - static_cast(rhs); - return static_cast(intResult > 0 ? intResult : 0); + return static_cast(intResult > 0 ? intResult : 0); }; return Color(clampedSub(left.r, right.r), @@ -101,10 +105,10 @@ constexpr Color operator-(const Color& left, const Color& right) //////////////////////////////////////////////////////////// constexpr Color operator*(const Color& left, const Color& right) { - const auto scaledMul = [](Uint8 lhs, Uint8 rhs) -> Uint8 + const auto scaledMul = [](std::uint8_t lhs, std::uint8_t rhs) -> std::uint8_t { const auto uint16Result = static_cast(static_cast(lhs) * static_cast(rhs)); - return static_cast(uint16Result / 255u); + return static_cast(uint16Result / 255u); }; return Color(scaledMul(left.r, right.r), diff --git a/include/SFML/Graphics/Font.hpp b/include/SFML/Graphics/Font.hpp index 627b5ffc2..8849a6715 100644 --- a/include/SFML/Graphics/Font.hpp +++ b/include/SFML/Graphics/Font.hpp @@ -427,7 +427,7 @@ private: bool m_isSmooth; //!< Status of the smooth filter Info m_info; //!< Information about the font mutable PageTable m_pages; //!< Table containing the glyphs pages by character size - mutable std::vector m_pixelBuffer; //!< Pixel buffer holding a glyph's pixels before being written to the texture + mutable std::vector m_pixelBuffer; //!< Pixel buffer holding a glyph's pixels before being written to the texture #ifdef SFML_SYSTEM_ANDROID std::unique_ptr m_stream; //!< Asset file streamer (if loaded from file) #endif diff --git a/include/SFML/Graphics/Image.hpp b/include/SFML/Graphics/Image.hpp index 2845822d0..9bde7cafe 100644 --- a/include/SFML/Graphics/Image.hpp +++ b/include/SFML/Graphics/Image.hpp @@ -70,7 +70,7 @@ public: /// \param pixels Array of pixels to copy to the image /// //////////////////////////////////////////////////////////// - void create(const Vector2u& size, const Uint8* pixels); + void create(const Vector2u& size, const std::uint8_t* pixels); //////////////////////////////////////////////////////////// /// \brief Load the image from a file on disk @@ -157,7 +157,7 @@ public: /// \see create, loadFromFile, loadFromMemory, saveToFile /// //////////////////////////////////////////////////////////// - [[nodiscard]] bool saveToMemory(std::vector& output, const std::string& format) const; + [[nodiscard]] bool saveToMemory(std::vector& output, const std::string& format) const; //////////////////////////////////////////////////////////// /// \brief Return the size (width and height) of the image @@ -178,7 +178,7 @@ public: /// \param alpha Alpha value to assign to transparent pixels /// //////////////////////////////////////////////////////////// - void createMaskFromColor(const Color& color, Uint8 alpha = 0); + void createMaskFromColor(const Color& color, std::uint8_t alpha = 0); //////////////////////////////////////////////////////////// /// \brief Copy pixels from another image onto this one @@ -261,7 +261,7 @@ public: /// \return Read-only pointer to the array of pixels /// //////////////////////////////////////////////////////////// - const Uint8* getPixelsPtr() const; + const std::uint8_t* getPixelsPtr() const; //////////////////////////////////////////////////////////// /// \brief Flip the image horizontally (left <-> right) @@ -279,8 +279,8 @@ private: //////////////////////////////////////////////////////////// // Member data //////////////////////////////////////////////////////////// - Vector2u m_size; //!< Image size - std::vector m_pixels; //!< Pixels of the image + Vector2u m_size; //!< Image size + std::vector m_pixels; //!< Pixels of the image }; } // namespace sf diff --git a/include/SFML/Graphics/Texture.hpp b/include/SFML/Graphics/Texture.hpp index 13a52486c..9f661834c 100644 --- a/include/SFML/Graphics/Texture.hpp +++ b/include/SFML/Graphics/Texture.hpp @@ -254,7 +254,7 @@ public: /// \param pixels Array of pixels to copy to the texture /// //////////////////////////////////////////////////////////// - void update(const Uint8* pixels); + void update(const std::uint8_t* pixels); //////////////////////////////////////////////////////////// /// \brief Update a part of the texture from an array of pixels @@ -274,7 +274,7 @@ public: /// \param dest Coordinates of the destination position /// //////////////////////////////////////////////////////////// - void update(const Uint8* pixels, const Vector2u& size, const Vector2u& dest); + void update(const std::uint8_t* pixels, const Vector2u& size, const Vector2u& dest); //////////////////////////////////////////////////////////// /// \brief Update a part of this texture from another texture @@ -703,7 +703,7 @@ private: /// ... /// /// // update the texture -/// sf::Uint8* pixels = ...; // get a fresh chunk of pixels (the next frame of a movie, for example) +/// std::uint8_t* pixels = ...; // get a fresh chunk of pixels (the next frame of a movie, for example) /// texture.update(pixels); /// /// // draw it diff --git a/include/SFML/Network/IpAddress.hpp b/include/SFML/Network/IpAddress.hpp index d8a7fa0f7..62839bb93 100644 --- a/include/SFML/Network/IpAddress.hpp +++ b/include/SFML/Network/IpAddress.hpp @@ -71,7 +71,7 @@ public: /// \param byte3 Fourth byte of the address /// //////////////////////////////////////////////////////////// - IpAddress(Uint8 byte0, Uint8 byte1, Uint8 byte2, Uint8 byte3); + IpAddress(std::uint8_t byte0, std::uint8_t byte1, std::uint8_t byte2, std::uint8_t byte3); //////////////////////////////////////////////////////////// /// \brief Construct the address from a 32-bits integer diff --git a/include/SFML/Network/Packet.hpp b/include/SFML/Network/Packet.hpp index ba23b99d6..613ed9494 100644 --- a/include/SFML/Network/Packet.hpp +++ b/include/SFML/Network/Packet.hpp @@ -218,7 +218,7 @@ public: //////////////////////////////////////////////////////////// /// \overload //////////////////////////////////////////////////////////// - Packet& operator>>(Uint8& data); + Packet& operator>>(std::uint8_t& data); //////////////////////////////////////////////////////////// /// \overload @@ -299,7 +299,7 @@ public: //////////////////////////////////////////////////////////// /// \overload //////////////////////////////////////////////////////////// - Packet& operator<<(Uint8 data); + Packet& operator<<(std::uint8_t data); //////////////////////////////////////////////////////////// /// \overload diff --git a/include/SFML/System/String.hpp b/include/SFML/System/String.hpp index 6b1c5eeb8..1aaa8cf54 100644 --- a/include/SFML/System/String.hpp +++ b/include/SFML/System/String.hpp @@ -286,7 +286,7 @@ public: /// \see toUtf16, toUtf32 /// //////////////////////////////////////////////////////////// - std::basic_string toUtf8() const; + std::basic_string toUtf8() const; //////////////////////////////////////////////////////////// /// \brief Convert the Unicode string to a UTF-16 string diff --git a/include/SFML/System/Utf.hpp b/include/SFML/System/Utf.hpp index f2fde20d8..cabfc2634 100644 --- a/include/SFML/System/Utf.hpp +++ b/include/SFML/System/Utf.hpp @@ -86,7 +86,7 @@ public: /// //////////////////////////////////////////////////////////// template - static Out encode(Uint32 input, Out output, Uint8 replacement = 0); + static Out encode(Uint32 input, Out output, std::uint8_t replacement = 0); //////////////////////////////////////////////////////////// /// \brief Advance to the next UTF-8 character diff --git a/include/SFML/System/Utf.inl b/include/SFML/System/Utf.inl index e3bd5a2d3..eef35813d 100644 --- a/include/SFML/System/Utf.inl +++ b/include/SFML/System/Utf.inl @@ -68,7 +68,7 @@ In Utf<8>::decode(In begin, In end, Uint32& output, Uint32 replacement) // clang-format on // decode the character - int trailingBytes = trailing[static_cast(*begin)]; + int trailingBytes = trailing[static_cast(*begin)]; if (begin + trailingBytes < end) { output = 0; @@ -76,12 +76,12 @@ In Utf<8>::decode(In begin, In end, Uint32& output, Uint32 replacement) // clang-format off switch (trailingBytes) { - case 5: output += static_cast(*begin++); output <<= 6; [[fallthrough]]; - case 4: output += static_cast(*begin++); output <<= 6; [[fallthrough]]; - case 3: output += static_cast(*begin++); output <<= 6; [[fallthrough]]; - case 2: output += static_cast(*begin++); output <<= 6; [[fallthrough]]; - case 1: output += static_cast(*begin++); output <<= 6; [[fallthrough]]; - case 0: output += static_cast(*begin++); + case 5: output += static_cast(*begin++); output <<= 6; [[fallthrough]]; + case 4: output += static_cast(*begin++); output <<= 6; [[fallthrough]]; + case 3: output += static_cast(*begin++); output <<= 6; [[fallthrough]]; + case 2: output += static_cast(*begin++); output <<= 6; [[fallthrough]]; + case 1: output += static_cast(*begin++); output <<= 6; [[fallthrough]]; + case 0: output += static_cast(*begin++); } // clang-format on @@ -100,10 +100,10 @@ In Utf<8>::decode(In begin, In end, Uint32& output, Uint32 replacement) //////////////////////////////////////////////////////////// template -Out Utf<8>::encode(Uint32 input, Out output, Uint8 replacement) +Out Utf<8>::encode(Uint32 input, Out output, std::uint8_t replacement) { // Some useful precomputed data - static constexpr Uint8 firstBytes[7] = {0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC}; + static constexpr std::uint8_t firstBytes[7] = {0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC}; // encode the character if ((input > 0x0010FFFF) || ((input >= 0xD800) && (input <= 0xDBFF))) @@ -127,15 +127,15 @@ Out Utf<8>::encode(Uint32 input, Out output, Uint8 replacement) // clang-format on // Extract the bytes to write - Uint8 bytes[4]; + std::uint8_t bytes[4]; // clang-format off switch (bytestoWrite) { - case 4: bytes[3] = static_cast((input | 0x80) & 0xBF); input >>= 6; [[fallthrough]]; - case 3: bytes[2] = static_cast((input | 0x80) & 0xBF); input >>= 6; [[fallthrough]]; - case 2: bytes[1] = static_cast((input | 0x80) & 0xBF); input >>= 6; [[fallthrough]]; - case 1: bytes[0] = static_cast (input | firstBytes[bytestoWrite]); + case 4: bytes[3] = static_cast((input | 0x80) & 0xBF); input >>= 6; [[fallthrough]]; + case 3: bytes[2] = static_cast((input | 0x80) & 0xBF); input >>= 6; [[fallthrough]]; + case 2: bytes[1] = static_cast((input | 0x80) & 0xBF); input >>= 6; [[fallthrough]]; + case 1: bytes[0] = static_cast (input | firstBytes[bytestoWrite]); } // clang-format on diff --git a/include/SFML/Window/Cursor.hpp b/include/SFML/Window/Cursor.hpp index a74013d78..bf0daf5c9 100644 --- a/include/SFML/Window/Cursor.hpp +++ b/include/SFML/Window/Cursor.hpp @@ -172,7 +172,7 @@ public: /// false otherwise /// //////////////////////////////////////////////////////////// - [[nodiscard]] bool loadFromPixels(const Uint8* pixels, Vector2u size, Vector2u hotspot); + [[nodiscard]] bool loadFromPixels(const std::uint8_t* pixels, Vector2u size, Vector2u hotspot); //////////////////////////////////////////////////////////// /// \brief Create a native system cursor diff --git a/include/SFML/Window/WindowBase.hpp b/include/SFML/Window/WindowBase.hpp index 545166c2e..1b868dd4c 100644 --- a/include/SFML/Window/WindowBase.hpp +++ b/include/SFML/Window/WindowBase.hpp @@ -281,7 +281,7 @@ public: /// \see setTitle /// //////////////////////////////////////////////////////////// - void setIcon(const Vector2u& size, const Uint8* pixels); + void setIcon(const Vector2u& size, const std::uint8_t* pixels); //////////////////////////////////////////////////////////// /// \brief Show or hide the window diff --git a/src/SFML/Audio/SoundFileReaderMp3.cpp b/src/SFML/Audio/SoundFileReaderMp3.cpp index 48c75f807..16172fa74 100644 --- a/src/SFML/Audio/SoundFileReaderMp3.cpp +++ b/src/SFML/Audio/SoundFileReaderMp3.cpp @@ -67,7 +67,7 @@ int seekCallback(std::uint64_t offset, void* data) return position < 0 ? -1 : 0; } -bool hasValidId3Tag(const sf::Uint8* header) +bool hasValidId3Tag(const std::uint8_t* header) { return std::memcmp(header, "ID3", 3) == 0 && !((header[5] & 15) || (header[6] & 0x80) || (header[7] & 0x80) || (header[8] & 0x80) || (header[9] & 0x80)); @@ -81,7 +81,7 @@ namespace priv //////////////////////////////////////////////////////////// bool SoundFileReaderMp3::check(InputStream& stream) { - Uint8 header[10]; + std::uint8_t header[10]; if (static_cast(stream.read(header, static_cast(sizeof(header)))) < sizeof(header)) return false; diff --git a/src/SFML/Audio/SoundFileReaderWav.cpp b/src/SFML/Audio/SoundFileReaderWav.cpp index 4e4e5d079..21389abee 100644 --- a/src/SFML/Audio/SoundFileReaderWav.cpp +++ b/src/SFML/Audio/SoundFileReaderWav.cpp @@ -41,7 +41,7 @@ namespace // The following functions read integers as little endian and // return them in the host byte order -bool decode(sf::InputStream& stream, sf::Uint8& value) +bool decode(sf::InputStream& stream, std::uint8_t& value) { return static_cast(stream.read(&value, sizeof(value))) == sizeof(value); } @@ -164,7 +164,7 @@ Uint64 SoundFileReaderWav::read(Int16* samples, Uint64 maxCount) { case 1: { - Uint8 sample = 0; + std::uint8_t sample = 0; if (decode(*m_stream, sample)) *samples++ = static_cast((static_cast(sample) - 128) << 8); else diff --git a/src/SFML/Graphics/Font.cpp b/src/SFML/Graphics/Font.cpp index 8ccdd5c37..a73862993 100644 --- a/src/SFML/Graphics/Font.cpp +++ b/src/SFML/Graphics/Font.cpp @@ -536,7 +536,7 @@ void Font::cleanup() // Reset members m_pages.clear(); - std::vector().swap(m_pixelBuffer); + std::vector().swap(m_pixelBuffer); } @@ -661,8 +661,8 @@ Glyph Font::loadGlyph(Uint32 codePoint, unsigned int characterSize, bool bold, f // Resize the pixel buffer to the new size and fill it with transparent white pixels m_pixelBuffer.resize(static_cast(width) * static_cast(height) * 4); - Uint8* current = m_pixelBuffer.data(); - Uint8* end = current + width * height * 4; + std::uint8_t* current = m_pixelBuffer.data(); + std::uint8_t* end = current + width * height * 4; while (current != end) { @@ -673,7 +673,7 @@ Glyph Font::loadGlyph(Uint32 codePoint, unsigned int characterSize, bool bold, f } // Extract the glyph's pixels from the bitmap - const Uint8* pixels = bitmap.buffer; + const std::uint8_t* pixels = bitmap.buffer; if (bitmap.pixel_mode == FT_PIXEL_MODE_MONO) { // Pixels are 1 bit monochrome values diff --git a/src/SFML/Graphics/Image.cpp b/src/SFML/Graphics/Image.cpp index 09f3c1412..c5d3eab14 100644 --- a/src/SFML/Graphics/Image.cpp +++ b/src/SFML/Graphics/Image.cpp @@ -44,11 +44,11 @@ void Image::create(const Vector2u& size, const Color& color) if (size.x && size.y) { // Create a new pixel buffer first for exception safety's sake - std::vector newPixels(static_cast(size.x) * static_cast(size.y) * 4); + std::vector newPixels(static_cast(size.x) * static_cast(size.y) * 4); // Fill it with the specified color - Uint8* ptr = newPixels.data(); - Uint8* end = ptr + newPixels.size(); + std::uint8_t* ptr = newPixels.data(); + std::uint8_t* end = ptr + newPixels.size(); while (ptr < end) { *ptr++ = color.r; @@ -66,7 +66,7 @@ void Image::create(const Vector2u& size, const Color& color) else { // Dump the pixel buffer - std::vector().swap(m_pixels); + std::vector().swap(m_pixels); // Assign the new size m_size.x = 0; @@ -76,12 +76,12 @@ void Image::create(const Vector2u& size, const Color& color) //////////////////////////////////////////////////////////// -void Image::create(const Vector2u& size, const Uint8* pixels) +void Image::create(const Vector2u& size, const std::uint8_t* pixels) { if (pixels && size.x && size.y) { // Create a new pixel buffer first for exception safety's sake - std::vector newPixels(pixels, pixels + size.x * size.y * 4); + std::vector newPixels(pixels, pixels + size.x * size.y * 4); // Commit the new pixel buffer m_pixels.swap(newPixels); @@ -92,7 +92,7 @@ void Image::create(const Vector2u& size, const Uint8* pixels) else { // Dump the pixel buffer - std::vector().swap(m_pixels); + std::vector().swap(m_pixels); // Assign the new size m_size.x = 0; @@ -138,7 +138,7 @@ bool Image::saveToFile(const std::filesystem::path& filename) const } //////////////////////////////////////////////////////////// -bool Image::saveToMemory(std::vector& output, const std::string& format) const +bool Image::saveToMemory(std::vector& output, const std::string& format) const { return priv::ImageLoader::getInstance().saveImageToMemory(format, output, m_pixels, m_size); } @@ -152,14 +152,14 @@ Vector2u Image::getSize() const //////////////////////////////////////////////////////////// -void Image::createMaskFromColor(const Color& color, Uint8 alpha) +void Image::createMaskFromColor(const Color& color, std::uint8_t alpha) { // Make sure that the image is not empty if (!m_pixels.empty()) { // Replace the alpha of the pixels that match the transparent color - Uint8* ptr = m_pixels.data(); - Uint8* end = ptr + m_pixels.size(); + std::uint8_t* ptr = m_pixels.data(); + std::uint8_t* end = ptr + m_pixels.size(); while (ptr < end) { if ((ptr[0] == color.r) && (ptr[1] == color.g) && (ptr[2] == color.b) && (ptr[3] == color.a)) @@ -209,8 +209,8 @@ void Image::createMaskFromColor(const Color& color, Uint8 alpha) const unsigned int srcStride = source.m_size.x * 4; const unsigned int dstStride = m_size.x * 4; - const Uint8* srcPixels = source.m_pixels.data() + (srcRect.left + srcRect.top * source.m_size.x) * 4; - Uint8* dstPixels = m_pixels.data() + (dest.x + dest.y * m_size.x) * 4; + const std::uint8_t* srcPixels = source.m_pixels.data() + (srcRect.left + srcRect.top * source.m_size.x) * 4; + std::uint8_t* dstPixels = m_pixels.data() + (dest.x + dest.y * m_size.x) * 4; // Copy the pixels if (applyAlpha) @@ -221,19 +221,20 @@ void Image::createMaskFromColor(const Color& color, Uint8 alpha) for (unsigned int j = 0; j < dstSize.x; ++j) { // Get a direct pointer to the components of the current pixel - const Uint8* src = srcPixels + j * 4; - Uint8* dst = dstPixels + j * 4; + const std::uint8_t* src = srcPixels + j * 4; + std::uint8_t* dst = dstPixels + j * 4; // Interpolate RGBA components using the alpha values of the destination and source pixels - Uint8 src_alpha = src[3]; - Uint8 dst_alpha = dst[3]; - Uint8 out_alpha = static_cast(src_alpha + dst_alpha - src_alpha * dst_alpha / 255); + std::uint8_t src_alpha = src[3]; + std::uint8_t dst_alpha = dst[3]; + std::uint8_t out_alpha = static_cast(src_alpha + dst_alpha - src_alpha * dst_alpha / 255); dst[3] = out_alpha; if (out_alpha) for (int k = 0; k < 3; k++) - dst[k] = static_cast((src[k] * src_alpha + dst[k] * (out_alpha - src_alpha)) / out_alpha); + dst[k] = static_cast( + (src[k] * src_alpha + dst[k] * (out_alpha - src_alpha)) / out_alpha); else for (int k = 0; k < 3; k++) dst[k] = src[k]; @@ -261,24 +262,24 @@ void Image::createMaskFromColor(const Color& color, Uint8 alpha) //////////////////////////////////////////////////////////// void Image::setPixel(const Vector2u& coords, const Color& color) { - Uint8* pixel = &m_pixels[(coords.x + coords.y * m_size.x) * 4]; - *pixel++ = color.r; - *pixel++ = color.g; - *pixel++ = color.b; - *pixel++ = color.a; + std::uint8_t* pixel = &m_pixels[(coords.x + coords.y * m_size.x) * 4]; + *pixel++ = color.r; + *pixel++ = color.g; + *pixel++ = color.b; + *pixel++ = color.a; } //////////////////////////////////////////////////////////// Color Image::getPixel(const Vector2u& coords) const { - const Uint8* pixel = &m_pixels[(coords.x + coords.y * m_size.x) * 4]; + const std::uint8_t* pixel = &m_pixels[(coords.x + coords.y * m_size.x) * 4]; return Color(pixel[0], pixel[1], pixel[2], pixel[3]); } //////////////////////////////////////////////////////////// -const Uint8* Image::getPixelsPtr() const +const std::uint8_t* Image::getPixelsPtr() const { if (!m_pixels.empty()) { @@ -301,9 +302,9 @@ void Image::flipHorizontally() for (std::size_t y = 0; y < m_size.y; ++y) { - auto left = m_pixels.begin() + static_cast::iterator::difference_type>(y * rowSize); + auto left = m_pixels.begin() + static_cast::iterator::difference_type>(y * rowSize); auto right = m_pixels.begin() + - static_cast::iterator::difference_type>((y + 1) * rowSize - 4); + static_cast::iterator::difference_type>((y + 1) * rowSize - 4); for (std::size_t x = 0; x < m_size.x / 2; ++x) { @@ -322,7 +323,7 @@ void Image::flipVertically() { if (!m_pixels.empty()) { - auto rowSize = static_cast::iterator::difference_type>(m_size.x * 4); + auto rowSize = static_cast::iterator::difference_type>(m_size.x * 4); auto top = m_pixels.begin(); auto bottom = m_pixels.end() - rowSize; diff --git a/src/SFML/Graphics/ImageLoader.cpp b/src/SFML/Graphics/ImageLoader.cpp index 196731450..471ea62da 100644 --- a/src/SFML/Graphics/ImageLoader.cpp +++ b/src/SFML/Graphics/ImageLoader.cpp @@ -64,8 +64,8 @@ int eof(void* user) // stb_image callback for constructing a buffer void bufferFromCallback(void* context, void* data, int size) { - auto* source = static_cast(data); - auto* dest = static_cast*>(context); + auto* source = static_cast(data); + auto* dest = static_cast*>(context); std::copy(source, source + size, std::back_inserter(*dest)); } } // namespace @@ -92,7 +92,7 @@ ImageLoader::ImageLoader() //////////////////////////////////////////////////////////// -bool ImageLoader::loadImageFromFile(const std::filesystem::path& filename, std::vector& pixels, Vector2u& size) +bool ImageLoader::loadImageFromFile(const std::filesystem::path& filename, std::vector& pixels, Vector2u& size) { // Clear the array (just in case) pixels.clear(); @@ -133,7 +133,7 @@ bool ImageLoader::loadImageFromFile(const std::filesystem::path& filename, std:: //////////////////////////////////////////////////////////// -bool ImageLoader::loadImageFromMemory(const void* data, std::size_t dataSize, std::vector& pixels, Vector2u& size) +bool ImageLoader::loadImageFromMemory(const void* data, std::size_t dataSize, std::vector& pixels, Vector2u& size) { // Check input parameters if (data && dataSize) @@ -183,7 +183,7 @@ bool ImageLoader::loadImageFromMemory(const void* data, std::size_t dataSize, st //////////////////////////////////////////////////////////// -bool ImageLoader::loadImageFromStream(InputStream& stream, std::vector& pixels, Vector2u& size) +bool ImageLoader::loadImageFromStream(InputStream& stream, std::vector& pixels, Vector2u& size) { // Clear the array (just in case) pixels.clear(); @@ -236,7 +236,9 @@ bool ImageLoader::loadImageFromStream(InputStream& stream, std::vector& p //////////////////////////////////////////////////////////// -bool ImageLoader::saveImageToFile(const std::filesystem::path& filename, const std::vector& pixels, const Vector2u& size) +bool ImageLoader::saveImageToFile(const std::filesystem::path& filename, + const std::vector& pixels, + const Vector2u& size) { // Make sure the image is not empty if (!pixels.empty() && (size.x > 0) && (size.y > 0)) @@ -278,10 +280,10 @@ bool ImageLoader::saveImageToFile(const std::filesystem::path& filename, const s } //////////////////////////////////////////////////////////// -bool ImageLoader::saveImageToMemory(const std::string& format, - std::vector& output, - const std::vector& pixels, - const Vector2u& size) +bool ImageLoader::saveImageToMemory(const std::string& format, + std::vector& output, + const std::vector& pixels, + const Vector2u& size) { // Make sure the image is not empty if (!pixels.empty() && (size.x > 0) && (size.y > 0)) diff --git a/src/SFML/Graphics/ImageLoader.hpp b/src/SFML/Graphics/ImageLoader.hpp index ef3b7aaee..fb0afc812 100644 --- a/src/SFML/Graphics/ImageLoader.hpp +++ b/src/SFML/Graphics/ImageLoader.hpp @@ -68,7 +68,7 @@ public: /// \return True if loading was successful /// //////////////////////////////////////////////////////////// - bool loadImageFromFile(const std::filesystem::path& filename, std::vector& pixels, Vector2u& size); + bool loadImageFromFile(const std::filesystem::path& filename, std::vector& pixels, Vector2u& size); //////////////////////////////////////////////////////////// /// \brief Load an image from a file in memory @@ -81,7 +81,7 @@ public: /// \return True if loading was successful /// //////////////////////////////////////////////////////////// - bool loadImageFromMemory(const void* data, std::size_t dataSize, std::vector& pixels, Vector2u& size); + bool loadImageFromMemory(const void* data, std::size_t dataSize, std::vector& pixels, Vector2u& size); //////////////////////////////////////////////////////////// /// \brief Load an image from a custom stream @@ -93,7 +93,7 @@ public: /// \return True if loading was successful /// //////////////////////////////////////////////////////////// - bool loadImageFromStream(InputStream& stream, std::vector& pixels, Vector2u& size); + bool loadImageFromStream(InputStream& stream, std::vector& pixels, Vector2u& size); //////////////////////////////////////////////////////////// /// \brief Save an array of pixels as an image file @@ -105,7 +105,7 @@ public: /// \return True if saving was successful /// //////////////////////////////////////////////////////////// - bool saveImageToFile(const std::filesystem::path& filename, const std::vector& pixels, const Vector2u& size); + bool saveImageToFile(const std::filesystem::path& filename, const std::vector& pixels, const Vector2u& size); //////////////////////////////////////////////////////////// /// \brief Save an array of pixels as an encoded image buffer @@ -118,10 +118,10 @@ public: /// \return True if saving was successful /// //////////////////////////////////////////////////////////// - bool saveImageToMemory(const std::string& format, - std::vector& output, - const std::vector& pixels, - const Vector2u& size); + bool saveImageToMemory(const std::string& format, + std::vector& output, + const std::vector& pixels, + const Vector2u& size); private: //////////////////////////////////////////////////////////// diff --git a/src/SFML/Graphics/Texture.cpp b/src/SFML/Graphics/Texture.cpp index 5f12d803f..9597dda49 100644 --- a/src/SFML/Graphics/Texture.cpp +++ b/src/SFML/Graphics/Texture.cpp @@ -302,7 +302,7 @@ bool Texture::loadFromImage(const Image& image, const IntRect& area) priv::TextureSaver save; // Copy the pixels to the texture, row by row - const Uint8* pixels = image.getPixelsPtr() + 4 * (rectangle.left + (width * rectangle.top)); + const std::uint8_t* pixels = image.getPixelsPtr() + 4 * (rectangle.left + (width * rectangle.top)); glCheck(glBindTexture(GL_TEXTURE_2D, m_texture)); for (int i = 0; i < rectangle.height; ++i) { @@ -347,7 +347,7 @@ Image Texture::copyToImage() const priv::TextureSaver save; // Create an array of pixels - std::vector pixels(static_cast(m_size.x) * static_cast(m_size.y) * 4); + std::vector pixels(static_cast(m_size.x) * static_cast(m_size.y) * 4); #ifdef SFML_OPENGL_ES @@ -381,14 +381,14 @@ Image Texture::copyToImage() const // Texture is either padded or flipped, we have to use a slower algorithm // All the pixels will first be copied to a temporary array - std::vector allPixels( + std::vector allPixels( static_cast(m_actualSize.x) * static_cast(m_actualSize.y) * 4); glCheck(glBindTexture(GL_TEXTURE_2D, m_texture)); glCheck(glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, allPixels.data())); // Then we copy the useful pixels from the temporary array to the final one - const Uint8* src = allPixels.data(); - Uint8* dst = pixels.data(); + const std::uint8_t* src = allPixels.data(); + std::uint8_t* dst = pixels.data(); int srcPitch = static_cast(m_actualSize.x * 4); unsigned int dstPitch = m_size.x * 4; @@ -418,7 +418,7 @@ Image Texture::copyToImage() const //////////////////////////////////////////////////////////// -void Texture::update(const Uint8* pixels) +void Texture::update(const std::uint8_t* pixels) { // Update the whole texture update(pixels, m_size, {0, 0}); @@ -426,7 +426,7 @@ void Texture::update(const Uint8* pixels) //////////////////////////////////////////////////////////// -void Texture::update(const Uint8* pixels, const Vector2u& size, const Vector2u& dest) +void Texture::update(const std::uint8_t* pixels, const Vector2u& size, const Vector2u& dest) { assert(dest.x + size.x <= m_size.x); assert(dest.y + size.y <= m_size.y); diff --git a/src/SFML/Network/Ftp.cpp b/src/SFML/Network/Ftp.cpp index b23ec4111..e4a5f0b3b 100644 --- a/src/SFML/Network/Ftp.cpp +++ b/src/SFML/Network/Ftp.cpp @@ -537,15 +537,16 @@ Ftp::Response Ftp::DataChannel::open(Ftp::TransferMode mode) std::string::size_type begin = response.getMessage().find_first_of("0123456789"); if (begin != std::string::npos) { - Uint8 data[6] = {0, 0, 0, 0, 0, 0}; - std::string str = response.getMessage().substr(begin); - std::size_t index = 0; + std::uint8_t data[6] = {0, 0, 0, 0, 0, 0}; + std::string str = response.getMessage().substr(begin); + std::size_t index = 0; for (unsigned char& datum : data) { // Extract the current number while (isdigit(str[index])) { - datum = static_cast(static_cast(datum * 10) + static_cast(str[index] - '0')); + datum = static_cast( + static_cast(datum * 10) + static_cast(str[index] - '0')); ++index; } @@ -554,7 +555,7 @@ Ftp::Response Ftp::DataChannel::open(Ftp::TransferMode mode) } // Reconstruct connection port and address - unsigned short port = static_cast(data[4] * 256) + data[5]; + unsigned short port = static_cast(data[4] * 256) + data[5]; IpAddress address(data[0], data[1], data[2], data[3]); // Connect the data channel to the server diff --git a/src/SFML/Network/IpAddress.cpp b/src/SFML/Network/IpAddress.cpp index c8112badf..d96a64a46 100644 --- a/src/SFML/Network/IpAddress.cpp +++ b/src/SFML/Network/IpAddress.cpp @@ -86,7 +86,7 @@ std::optional IpAddress::resolve(std::string_view address) //////////////////////////////////////////////////////////// -IpAddress::IpAddress(Uint8 byte0, Uint8 byte1, Uint8 byte2, Uint8 byte3) : +IpAddress::IpAddress(std::uint8_t byte0, std::uint8_t byte1, std::uint8_t byte2, std::uint8_t byte3) : m_address(htonl(static_cast((byte0 << 24) | (byte1 << 16) | (byte2 << 8) | byte3))) { } diff --git a/src/SFML/Network/Packet.cpp b/src/SFML/Network/Packet.cpp index 372eb6e35..859dcba61 100644 --- a/src/SFML/Network/Packet.cpp +++ b/src/SFML/Network/Packet.cpp @@ -120,7 +120,7 @@ Packet::operator bool() const //////////////////////////////////////////////////////////// Packet& Packet::operator>>(bool& data) { - Uint8 value; + std::uint8_t value; if (*this >> value) data = (value != 0); @@ -142,7 +142,7 @@ Packet& Packet::operator>>(std::int8_t& data) //////////////////////////////////////////////////////////// -Packet& Packet::operator>>(Uint8& data) +Packet& Packet::operator>>(std::uint8_t& data) { if (checkSize(sizeof(data))) { @@ -217,7 +217,7 @@ Packet& Packet::operator>>(Int64& data) { // Since ntohll is not available everywhere, we have to convert // to network byte order (big endian) manually - Uint8 bytes[sizeof(data)]; + std::uint8_t bytes[sizeof(data)]; std::memcpy(bytes, &m_data[m_readPos], sizeof(data)); data = (static_cast(bytes[0]) << 56) | (static_cast(bytes[1]) << 48) | @@ -239,7 +239,7 @@ Packet& Packet::operator>>(Uint64& data) { // Since ntohll is not available everywhere, we have to convert // to network byte order (big endian) manually - Uint8 bytes[sizeof(data)]; + std::uint8_t bytes[sizeof(data)]; std::memcpy(bytes, &m_data[m_readPos], sizeof(data)); data = (static_cast(bytes[0]) << 56) | (static_cast(bytes[1]) << 48) | @@ -394,7 +394,7 @@ Packet& Packet::operator>>(String& data) //////////////////////////////////////////////////////////// Packet& Packet::operator<<(bool data) { - *this << static_cast(data); + *this << static_cast(data); return *this; } @@ -408,7 +408,7 @@ Packet& Packet::operator<<(std::int8_t data) //////////////////////////////////////////////////////////// -Packet& Packet::operator<<(Uint8 data) +Packet& Packet::operator<<(std::uint8_t data) { append(&data, sizeof(data)); return *this; @@ -457,14 +457,14 @@ Packet& Packet::operator<<(Int64 data) // Since htonll is not available everywhere, we have to convert // to network byte order (big endian) manually - Uint8 toWrite[] = {static_cast((data >> 56) & 0xFF), - static_cast((data >> 48) & 0xFF), - static_cast((data >> 40) & 0xFF), - static_cast((data >> 32) & 0xFF), - static_cast((data >> 24) & 0xFF), - static_cast((data >> 16) & 0xFF), - static_cast((data >> 8) & 0xFF), - static_cast((data)&0xFF)}; + std::uint8_t toWrite[] = {static_cast((data >> 56) & 0xFF), + static_cast((data >> 48) & 0xFF), + static_cast((data >> 40) & 0xFF), + static_cast((data >> 32) & 0xFF), + static_cast((data >> 24) & 0xFF), + static_cast((data >> 16) & 0xFF), + static_cast((data >> 8) & 0xFF), + static_cast((data)&0xFF)}; append(&toWrite, sizeof(toWrite)); return *this; @@ -477,14 +477,14 @@ Packet& Packet::operator<<(Uint64 data) // Since htonll is not available everywhere, we have to convert // to network byte order (big endian) manually - Uint8 toWrite[] = {static_cast((data >> 56) & 0xFF), - static_cast((data >> 48) & 0xFF), - static_cast((data >> 40) & 0xFF), - static_cast((data >> 32) & 0xFF), - static_cast((data >> 24) & 0xFF), - static_cast((data >> 16) & 0xFF), - static_cast((data >> 8) & 0xFF), - static_cast((data)&0xFF)}; + std::uint8_t toWrite[] = {static_cast((data >> 56) & 0xFF), + static_cast((data >> 48) & 0xFF), + static_cast((data >> 40) & 0xFF), + static_cast((data >> 32) & 0xFF), + static_cast((data >> 24) & 0xFF), + static_cast((data >> 16) & 0xFF), + static_cast((data >> 8) & 0xFF), + static_cast((data)&0xFF)}; append(&toWrite, sizeof(toWrite)); return *this; diff --git a/src/SFML/System/String.cpp b/src/SFML/System/String.cpp index 10852eaf2..757783263 100644 --- a/src/SFML/System/String.cpp +++ b/src/SFML/System/String.cpp @@ -182,10 +182,10 @@ std::wstring String::toWideString() const //////////////////////////////////////////////////////////// -std::basic_string String::toUtf8() const +std::basic_string String::toUtf8() const { // Prepare the output string - std::basic_string output; + std::basic_string output; output.reserve(m_string.length()); // Convert diff --git a/src/SFML/Window/Android/CursorImpl.cpp b/src/SFML/Window/Android/CursorImpl.cpp index 91bf5e245..8cf6e5dfd 100644 --- a/src/SFML/Window/Android/CursorImpl.cpp +++ b/src/SFML/Window/Android/CursorImpl.cpp @@ -40,7 +40,7 @@ CursorImpl::CursorImpl() //////////////////////////////////////////////////////////// -bool CursorImpl::loadFromPixels(const Uint8* /* pixels */, Vector2u /* size */, Vector2u /* hotspot */) +bool CursorImpl::loadFromPixels(const std::uint8_t* /* pixels */, Vector2u /* size */, Vector2u /* hotspot */) { // Not supported return false; diff --git a/src/SFML/Window/Android/CursorImpl.hpp b/src/SFML/Window/Android/CursorImpl.hpp index eecbb3f07..a00504d09 100644 --- a/src/SFML/Window/Android/CursorImpl.hpp +++ b/src/SFML/Window/Android/CursorImpl.hpp @@ -72,7 +72,7 @@ public: /// Returns false. /// //////////////////////////////////////////////////////////// - bool loadFromPixels(const Uint8* pixels, Vector2u size, Vector2u hotspot); + bool loadFromPixels(const std::uint8_t* pixels, Vector2u size, Vector2u hotspot); //////////////////////////////////////////////////////////// /// \brief Create a native system cursor diff --git a/src/SFML/Window/Android/WindowImplAndroid.cpp b/src/SFML/Window/Android/WindowImplAndroid.cpp index 0b14dafd9..62676593d 100644 --- a/src/SFML/Window/Android/WindowImplAndroid.cpp +++ b/src/SFML/Window/Android/WindowImplAndroid.cpp @@ -165,7 +165,7 @@ void WindowImplAndroid::setTitle(const String& /* title */) //////////////////////////////////////////////////////////// -void WindowImplAndroid::setIcon(const Vector2u& /* size */, const Uint8* /* pixels */) +void WindowImplAndroid::setIcon(const Vector2u& /* size */, const std::uint8_t* /* pixels */) { // Not applicable } diff --git a/src/SFML/Window/Android/WindowImplAndroid.hpp b/src/SFML/Window/Android/WindowImplAndroid.hpp index 1d99a5435..cfbf446a6 100644 --- a/src/SFML/Window/Android/WindowImplAndroid.hpp +++ b/src/SFML/Window/Android/WindowImplAndroid.hpp @@ -127,7 +127,7 @@ public: /// \param pixels Pointer to the pixels in memory, format must be RGBA 32 bits /// //////////////////////////////////////////////////////////// - void setIcon(const Vector2u& size, const Uint8* pixels) override; + void setIcon(const Vector2u& size, const std::uint8_t* pixels) override; //////////////////////////////////////////////////////////// /// \brief Show or hide the window diff --git a/src/SFML/Window/Cursor.cpp b/src/SFML/Window/Cursor.cpp index 0f98dccf8..6bd142fda 100644 --- a/src/SFML/Window/Cursor.cpp +++ b/src/SFML/Window/Cursor.cpp @@ -45,7 +45,7 @@ Cursor::~Cursor() = default; //////////////////////////////////////////////////////////// -bool Cursor::loadFromPixels(const Uint8* pixels, Vector2u size, Vector2u hotspot) +bool Cursor::loadFromPixels(const std::uint8_t* pixels, Vector2u size, Vector2u hotspot) { if ((pixels == nullptr) || (size.x == 0) || (size.y == 0)) return false; diff --git a/src/SFML/Window/DRM/CursorImpl.cpp b/src/SFML/Window/DRM/CursorImpl.cpp index 69dae386a..46d8f5264 100644 --- a/src/SFML/Window/DRM/CursorImpl.cpp +++ b/src/SFML/Window/DRM/CursorImpl.cpp @@ -41,21 +41,21 @@ CursorImpl::CursorImpl() //////////////////////////////////////////////////////////// -bool CursorImpl::loadFromPixels(const Uint8* /*pixels*/, Vector2u /*size*/, Vector2u /*hotspot*/) +bool CursorImpl::loadFromPixels(const std::uint8_t* /*pixels*/, Vector2u /*size*/, Vector2u /*hotspot*/) { return false; } //////////////////////////////////////////////////////////// -bool CursorImpl::loadFromPixelsARGB(const Uint8* /*pixels*/, Vector2u /*size*/, Vector2u /*hotspot*/) +bool CursorImpl::loadFromPixelsARGB(const std::uint8_t* /*pixels*/, Vector2u /*size*/, Vector2u /*hotspot*/) { return false; } //////////////////////////////////////////////////////////// -bool CursorImpl::loadFromPixelsMonochrome(const Uint8* /*pixels*/, Vector2u /*size*/, Vector2u /*hotspot*/) +bool CursorImpl::loadFromPixelsMonochrome(const std::uint8_t* /*pixels*/, Vector2u /*size*/, Vector2u /*hotspot*/) { return false; } diff --git a/src/SFML/Window/DRM/CursorImpl.hpp b/src/SFML/Window/DRM/CursorImpl.hpp index 3165e7942..11e8eec1e 100644 --- a/src/SFML/Window/DRM/CursorImpl.hpp +++ b/src/SFML/Window/DRM/CursorImpl.hpp @@ -70,7 +70,7 @@ public: /// Refer to sf::Cursor::loadFromPixels(). /// //////////////////////////////////////////////////////////// - bool loadFromPixels(const Uint8* pixels, Vector2u size, Vector2u hotspot); + bool loadFromPixels(const std::uint8_t* pixels, Vector2u size, Vector2u hotspot); //////////////////////////////////////////////////////////// /// \brief Create a native system cursor @@ -95,7 +95,7 @@ private: /// Refer to sf::Cursor::loadFromPixels(). /// //////////////////////////////////////////////////////////// - bool loadFromPixelsARGB(const Uint8* pixels, Vector2u size, Vector2u hotspot); + bool loadFromPixelsARGB(const std::uint8_t* pixels, Vector2u size, Vector2u hotspot); //////////////////////////////////////////////////////////// /// \brief Create a cursor with the provided image (monochrome) @@ -103,7 +103,7 @@ private: /// Refer to sf::Cursor::loadFromPixels(). /// //////////////////////////////////////////////////////////// - bool loadFromPixelsMonochrome(const Uint8* pixels, Vector2u size, Vector2u hotspot); + bool loadFromPixelsMonochrome(const std::uint8_t* pixels, Vector2u size, Vector2u hotspot); //////////////////////////////////////////////////////////// /// \brief Release the cursor, if we have loaded one. diff --git a/src/SFML/Window/DRM/WindowImplDRM.cpp b/src/SFML/Window/DRM/WindowImplDRM.cpp index 6e4978209..e26cb3b7c 100644 --- a/src/SFML/Window/DRM/WindowImplDRM.cpp +++ b/src/SFML/Window/DRM/WindowImplDRM.cpp @@ -101,7 +101,7 @@ void WindowImplDRM::setTitle(const String& /*title*/) //////////////////////////////////////////////////////////// -void WindowImplDRM::setIcon(const Vector2u& /*size*/, const Uint8* /*pixels*/) +void WindowImplDRM::setIcon(const Vector2u& /*size*/, const std::uint8_t* /*pixels*/) { } diff --git a/src/SFML/Window/DRM/WindowImplDRM.hpp b/src/SFML/Window/DRM/WindowImplDRM.hpp index 551e55a6e..010987cdd 100644 --- a/src/SFML/Window/DRM/WindowImplDRM.hpp +++ b/src/SFML/Window/DRM/WindowImplDRM.hpp @@ -122,7 +122,7 @@ public: /// \param pixels Pointer to the pixels in memory, format must be RGBA 32 bits /// //////////////////////////////////////////////////////////// - virtual void setIcon(const Vector2u& size, const Uint8* pixels) override; + virtual void setIcon(const Vector2u& size, const std::uint8_t* pixels) override; //////////////////////////////////////////////////////////// /// \brief Show or hide the window diff --git a/src/SFML/Window/OSX/ClipboardImpl.mm b/src/SFML/Window/OSX/ClipboardImpl.mm index 4c98fcc10..9a2dc52f3 100644 --- a/src/SFML/Window/OSX/ClipboardImpl.mm +++ b/src/SFML/Window/OSX/ClipboardImpl.mm @@ -53,8 +53,8 @@ String ClipboardImpl::getString() //////////////////////////////////////////////////////////// void ClipboardImpl::setString(const String& text) { - AutoreleasePool pool; - std::basic_string utf8 = text.toUtf8(); + AutoreleasePool pool; + std::basic_string utf8 = text.toUtf8(); NSString* data = [[NSString alloc] initWithBytes:utf8.data() length:utf8.length() encoding:NSUTF8StringEncoding]; NSPasteboard* pboard = [NSPasteboard generalPasteboard]; diff --git a/src/SFML/Window/OSX/CursorImpl.hpp b/src/SFML/Window/OSX/CursorImpl.hpp index 0bb8cdf75..ae1ebf74b 100644 --- a/src/SFML/Window/OSX/CursorImpl.hpp +++ b/src/SFML/Window/OSX/CursorImpl.hpp @@ -92,7 +92,7 @@ public: /// Refer to sf::Cursor::loadFromPixels(). /// //////////////////////////////////////////////////////////// - bool loadFromPixels(const Uint8* pixels, Vector2u size, Vector2u hotspot); + bool loadFromPixels(const std::uint8_t* pixels, Vector2u size, Vector2u hotspot); //////////////////////////////////////////////////////////// /// \brief Create a native system cursor diff --git a/src/SFML/Window/OSX/CursorImpl.mm b/src/SFML/Window/OSX/CursorImpl.mm index 3922b0a73..194cd8110 100644 --- a/src/SFML/Window/OSX/CursorImpl.mm +++ b/src/SFML/Window/OSX/CursorImpl.mm @@ -67,7 +67,7 @@ CursorImpl::~CursorImpl() //////////////////////////////////////////////////////////// -bool CursorImpl::loadFromPixels(const Uint8* pixels, Vector2u size, Vector2u hotspot) +bool CursorImpl::loadFromPixels(const std::uint8_t* pixels, Vector2u size, Vector2u hotspot) { AutoreleasePool pool; if (m_cursor) diff --git a/src/SFML/Window/OSX/NSImage+raw.h b/src/SFML/Window/OSX/NSImage+raw.h index 0636a938e..f9a759263 100644 --- a/src/SFML/Window/OSX/NSImage+raw.h +++ b/src/SFML/Window/OSX/NSImage+raw.h @@ -47,6 +47,6 @@ /// \return an instance of NSImage that needs to be released by the caller /// //////////////////////////////////////////////////////////// -+ (NSImage*)imageWithRawData:(const sf::Uint8*)pixels andSize:(NSSize)size; ++ (NSImage*)imageWithRawData:(const std::uint8_t*)pixels andSize:(NSSize)size; @end diff --git a/src/SFML/Window/OSX/NSImage+raw.mm b/src/SFML/Window/OSX/NSImage+raw.mm index 38f5c60ef..c4e451079 100644 --- a/src/SFML/Window/OSX/NSImage+raw.mm +++ b/src/SFML/Window/OSX/NSImage+raw.mm @@ -30,7 +30,7 @@ @implementation NSImage (raw) -+ (NSImage*)imageWithRawData:(const sf::Uint8*)pixels andSize:(NSSize)size ++ (NSImage*)imageWithRawData:(const std::uint8_t*)pixels andSize:(NSSize)size { // Create an empty image representation. NSBitmapImageRep* bitmap = [[NSBitmapImageRep alloc] diff --git a/src/SFML/Window/OSX/SFViewController.mm b/src/SFML/Window/OSX/SFViewController.mm index ce95b5c7a..bde1b6d1d 100644 --- a/src/SFML/Window/OSX/SFViewController.mm +++ b/src/SFML/Window/OSX/SFViewController.mm @@ -236,7 +236,7 @@ //////////////////////////////////////////////////////// -- (void)setIconTo:(unsigned int)width by:(unsigned int)height with:(const sf::Uint8*)pixels +- (void)setIconTo:(unsigned int)width by:(unsigned int)height with:(const std::uint8_t*)pixels { (void)width; (void)height; diff --git a/src/SFML/Window/OSX/SFWindowController.mm b/src/SFML/Window/OSX/SFWindowController.mm index 6cb481b80..64f515a78 100644 --- a/src/SFML/Window/OSX/SFWindowController.mm +++ b/src/SFML/Window/OSX/SFWindowController.mm @@ -543,7 +543,7 @@ //////////////////////////////////////////////////////// -- (void)setIconTo:(unsigned int)width by:(unsigned int)height with:(const sf::Uint8*)pixels +- (void)setIconTo:(unsigned int)width by:(unsigned int)height with:(const std::uint8_t*)pixels { // Load image and set app icon. NSImage* icon = [NSImage imageWithRawData:pixels andSize:NSMakeSize(width, height)]; diff --git a/src/SFML/Window/OSX/WindowImplCocoa.hpp b/src/SFML/Window/OSX/WindowImplCocoa.hpp index 3fac74a30..aae2e6c9b 100644 --- a/src/SFML/Window/OSX/WindowImplCocoa.hpp +++ b/src/SFML/Window/OSX/WindowImplCocoa.hpp @@ -296,7 +296,7 @@ public: /// \param pixels Pointer to the pixels in memory, format must be RGBA 32 bits /// //////////////////////////////////////////////////////////// - void setIcon(const Vector2u& size, const Uint8* pixels) override; + void setIcon(const Vector2u& size, const std::uint8_t* pixels) override; //////////////////////////////////////////////////////////// /// \brief Show or hide the window diff --git a/src/SFML/Window/OSX/WindowImplCocoa.mm b/src/SFML/Window/OSX/WindowImplCocoa.mm index 5392cc99e..6c3698e5e 100644 --- a/src/SFML/Window/OSX/WindowImplCocoa.mm +++ b/src/SFML/Window/OSX/WindowImplCocoa.mm @@ -448,7 +448,7 @@ void WindowImplCocoa::setTitle(const String& title) //////////////////////////////////////////////////////////// -void WindowImplCocoa::setIcon(const Vector2u& size, const Uint8* pixels) +void WindowImplCocoa::setIcon(const Vector2u& size, const std::uint8_t* pixels) { AutoreleasePool pool; [m_delegate setIconTo:size.x by:size.y with:pixels]; diff --git a/src/SFML/Window/OSX/WindowImplDelegateProtocol.h b/src/SFML/Window/OSX/WindowImplDelegateProtocol.h index d67462a52..a4a0541e2 100644 --- a/src/SFML/Window/OSX/WindowImplDelegateProtocol.h +++ b/src/SFML/Window/OSX/WindowImplDelegateProtocol.h @@ -26,7 +26,7 @@ //////////////////////////////////////////////////////////// // Headers //////////////////////////////////////////////////////////// -#include // for sf::Uint8 +#include #include @@ -221,7 +221,7 @@ class WindowImplCocoa; /// \param pixels icon's data /// //////////////////////////////////////////////////////////// -- (void)setIconTo:(unsigned int)width by:(unsigned int)height with:(const sf::Uint8*)pixels; +- (void)setIconTo:(unsigned int)width by:(unsigned int)height with:(const std::uint8_t*)pixels; //////////////////////////////////////////////////////////// /// \brief Fetch new event diff --git a/src/SFML/Window/Unix/ClipboardImpl.cpp b/src/SFML/Window/Unix/ClipboardImpl.cpp index d594335c6..ba535dadc 100644 --- a/src/SFML/Window/Unix/ClipboardImpl.cpp +++ b/src/SFML/Window/Unix/ClipboardImpl.cpp @@ -343,7 +343,7 @@ void ClipboardImpl::processEvent(XEvent& windowEvent) { // Respond to a request for conversion to a UTF-8 string // or an encoding of our choosing (we always choose UTF-8) - std::basic_string data = m_clipboardContents.toUtf8(); + std::basic_string data = m_clipboardContents.toUtf8(); XChangeProperty(m_display, selectionRequestEvent.requestor, diff --git a/src/SFML/Window/Unix/CursorImpl.cpp b/src/SFML/Window/Unix/CursorImpl.cpp index dd3ebe74e..88816bda9 100644 --- a/src/SFML/Window/Unix/CursorImpl.cpp +++ b/src/SFML/Window/Unix/CursorImpl.cpp @@ -58,7 +58,7 @@ CursorImpl::~CursorImpl() //////////////////////////////////////////////////////////// -bool CursorImpl::loadFromPixels(const Uint8* pixels, Vector2u size, Vector2u hotspot) +bool CursorImpl::loadFromPixels(const std::uint8_t* pixels, Vector2u size, Vector2u hotspot) { release(); @@ -70,7 +70,7 @@ bool CursorImpl::loadFromPixels(const Uint8* pixels, Vector2u size, Vector2u hot //////////////////////////////////////////////////////////// -bool CursorImpl::loadFromPixelsARGB(const Uint8* pixels, Vector2u size, Vector2u hotspot) +bool CursorImpl::loadFromPixelsARGB(const std::uint8_t* pixels, Vector2u size, Vector2u hotspot) { // Create cursor image, convert from RGBA to ARGB. XcursorImage* cursorImage = XcursorImageCreate(static_cast(size.x), static_cast(size.y)); @@ -97,16 +97,16 @@ bool CursorImpl::loadFromPixelsARGB(const Uint8* pixels, Vector2u size, Vector2u //////////////////////////////////////////////////////////// -bool CursorImpl::loadFromPixelsMonochrome(const Uint8* pixels, Vector2u size, Vector2u hotspot) +bool CursorImpl::loadFromPixelsMonochrome(const std::uint8_t* pixels, Vector2u size, Vector2u hotspot) { // Convert the image into a bitmap (monochrome!). // The bit data is stored packed into bytes. If the number of pixels on each row of the image // does not fit exactly into (width/8) bytes, one extra byte is allocated at the end of each // row to store the extra pixels. - std::size_t packedWidth = (size.x + 7) / 8; - std::size_t bytes = packedWidth * size.y; - std::vector mask(bytes, 0); // Defines which pixel is opaque (1) or transparent (0). - std::vector data(bytes, 0); // Defines which pixel is white (1) or black (0). + std::size_t packedWidth = (size.x + 7) / 8; + std::size_t bytes = packedWidth * size.y; + std::vector mask(bytes, 0); // Defines which pixel is opaque (1) or transparent (0). + std::vector data(bytes, 0); // Defines which pixel is white (1) or black (0). for (std::size_t j = 0; j < size.y; ++j) { @@ -117,15 +117,15 @@ bool CursorImpl::loadFromPixelsMonochrome(const Uint8* pixels, Vector2u size, Ve std::size_t bitIndex = i % 8; // Turn on pixel that are not transparent - Uint8 opacity = pixels[pixelIndex * 4 + 3] > 0 ? 1 : 0; - mask[byteIndex] |= static_cast(opacity << bitIndex); + std::uint8_t opacity = pixels[pixelIndex * 4 + 3] > 0 ? 1 : 0; + mask[byteIndex] |= static_cast(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. int intensity = (pixels[pixelIndex * 4 + 0] + pixels[pixelIndex * 4 + 1] + pixels[pixelIndex * 4 + 2]) / 3; - Uint8 bit = intensity > 128 ? 1 : 0; - data[byteIndex] |= static_cast(bit << bitIndex); + std::uint8_t bit = intensity > 128 ? 1 : 0; + data[byteIndex] |= static_cast(bit << bitIndex); } } diff --git a/src/SFML/Window/Unix/CursorImpl.hpp b/src/SFML/Window/Unix/CursorImpl.hpp index beb4b343d..c55b661d4 100644 --- a/src/SFML/Window/Unix/CursorImpl.hpp +++ b/src/SFML/Window/Unix/CursorImpl.hpp @@ -80,7 +80,7 @@ public: /// Refer to sf::Cursor::loadFromPixels(). /// //////////////////////////////////////////////////////////// - bool loadFromPixels(const Uint8* pixels, Vector2u size, Vector2u hotspot); + bool loadFromPixels(const std::uint8_t* pixels, Vector2u size, Vector2u hotspot); //////////////////////////////////////////////////////////// /// \brief Create a native system cursor @@ -105,7 +105,7 @@ private: /// Refer to sf::Cursor::loadFromPixels(). /// //////////////////////////////////////////////////////////// - bool loadFromPixelsARGB(const Uint8* pixels, Vector2u size, Vector2u hotspot); + bool loadFromPixelsARGB(const std::uint8_t* pixels, Vector2u size, Vector2u hotspot); //////////////////////////////////////////////////////////// /// \brief Create a cursor with the provided image (monochrome) @@ -113,7 +113,7 @@ private: /// Refer to sf::Cursor::loadFromPixels(). /// //////////////////////////////////////////////////////////// - bool loadFromPixelsMonochrome(const Uint8* pixels, Vector2u size, Vector2u hotspot); + bool loadFromPixelsMonochrome(const std::uint8_t* pixels, Vector2u size, Vector2u hotspot); //////////////////////////////////////////////////////////// /// \brief Release the cursor, if we have loaded one. diff --git a/src/SFML/Window/Unix/WindowImplX11.cpp b/src/SFML/Window/Unix/WindowImplX11.cpp index 94e9dd43a..695515509 100644 --- a/src/SFML/Window/Unix/WindowImplX11.cpp +++ b/src/SFML/Window/Unix/WindowImplX11.cpp @@ -956,7 +956,7 @@ void WindowImplX11::setTitle(const String& title) // There is however an option to tell the window manager your Unicode title via hints. // Convert to UTF-8 encoding. - std::basic_string utf8Title; + std::basic_string utf8Title; Utf32::toUtf8(title.begin(), title.end(), std::back_inserter(utf8Title)); Atom useUtf8 = getAtom("UTF8_STRING", false); @@ -1001,11 +1001,11 @@ void WindowImplX11::setTitle(const String& title) //////////////////////////////////////////////////////////// -void WindowImplX11::setIcon(const Vector2u& size, const Uint8* pixels) +void WindowImplX11::setIcon(const Vector2u& size, const std::uint8_t* pixels) { // X11 wants BGRA pixels: swap red and blue channels // Note: this memory will be freed by XDestroyImage - auto* iconPixels = static_cast( + auto* iconPixels = static_cast( std::malloc(static_cast(size.x) * static_cast(size.y) * 4)); for (std::size_t i = 0; i < static_cast(size.x) * static_cast(size.y); ++i) { @@ -1048,8 +1048,8 @@ void WindowImplX11::setIcon(const Vector2u& size, const Uint8* pixels) XDestroyImage(iconImage); // Create the mask pixmap (must have 1 bit depth) - std::size_t pitch = (size.x + 7) / 8; - std::vector maskPixels(pitch * size.y, 0); + std::size_t pitch = (size.x + 7) / 8; + std::vector maskPixels(pitch * size.y, 0); for (std::size_t j = 0; j < size.y; ++j) { for (std::size_t i = 0; i < pitch; ++i) @@ -1058,8 +1058,8 @@ void WindowImplX11::setIcon(const Vector2u& size, const Uint8* pixels) { if (i * 8 + k < size.x) { - Uint8 opacity = (pixels[(i * 8 + k + j * size.x) * 4 + 3] > 0) ? 1 : 0; - maskPixels[i + j * pitch] |= static_cast(opacity << k); + std::uint8_t opacity = (pixels[(i * 8 + k + j * size.x) * 4 + 3] > 0) ? 1 : 0; + maskPixels[i + j * pitch] |= static_cast(opacity << k); } } } @@ -1921,8 +1921,8 @@ bool WindowImplX11::processEvent(XEvent& windowEvent) #ifdef X_HAVE_UTF8_STRING if (m_inputContext) { - Status status; - Uint8 keyBuffer[64]; + Status status; + std::uint8_t keyBuffer[64]; int length = Xutf8LookupString(m_inputContext, &windowEvent.xkey, @@ -1940,8 +1940,8 @@ bool WindowImplX11::processEvent(XEvent& windowEvent) { // There might be more than 1 characters in this event, // so we must iterate it - Uint32 unicode = 0; - Uint8* iter = keyBuffer; + Uint32 unicode = 0; + std::uint8_t* iter = keyBuffer; while (iter < keyBuffer + length) { iter = Utf8::decode(iter, keyBuffer + length, unicode, 0); diff --git a/src/SFML/Window/Unix/WindowImplX11.hpp b/src/SFML/Window/Unix/WindowImplX11.hpp index be8493eee..1bd9c7404 100644 --- a/src/SFML/Window/Unix/WindowImplX11.hpp +++ b/src/SFML/Window/Unix/WindowImplX11.hpp @@ -129,7 +129,7 @@ public: /// \param pixels Pointer to the pixels in memory, format must be RGBA 32 bits /// //////////////////////////////////////////////////////////// - void setIcon(const Vector2u& size, const Uint8* pixels) override; + void setIcon(const Vector2u& size, const std::uint8_t* pixels) override; //////////////////////////////////////////////////////////// /// \brief Show or hide the window diff --git a/src/SFML/Window/Win32/CursorImpl.cpp b/src/SFML/Window/Win32/CursorImpl.cpp index be5d60f1d..c6ea7a8bb 100644 --- a/src/SFML/Window/Win32/CursorImpl.cpp +++ b/src/SFML/Window/Win32/CursorImpl.cpp @@ -53,7 +53,7 @@ CursorImpl::~CursorImpl() //////////////////////////////////////////////////////////// -bool CursorImpl::loadFromPixels(const Uint8* pixels, Vector2u size, Vector2u hotspot) +bool CursorImpl::loadFromPixels(const std::uint8_t* pixels, Vector2u size, Vector2u hotspot) { release(); diff --git a/src/SFML/Window/Win32/CursorImpl.hpp b/src/SFML/Window/Win32/CursorImpl.hpp index 212462196..9734b3b7a 100644 --- a/src/SFML/Window/Win32/CursorImpl.hpp +++ b/src/SFML/Window/Win32/CursorImpl.hpp @@ -77,7 +77,7 @@ public: /// Refer to sf::Cursor::loadFromPixels(). /// //////////////////////////////////////////////////////////// - bool loadFromPixels(const Uint8* pixels, Vector2u size, Vector2u hotspot); + bool loadFromPixels(const std::uint8_t* pixels, Vector2u size, Vector2u hotspot); //////////////////////////////////////////////////////////// /// \brief Create a native system cursor diff --git a/src/SFML/Window/Win32/WindowImplWin32.cpp b/src/SFML/Window/Win32/WindowImplWin32.cpp index 6d03eb00b..29011a9c0 100644 --- a/src/SFML/Window/Win32/WindowImplWin32.cpp +++ b/src/SFML/Window/Win32/WindowImplWin32.cpp @@ -367,14 +367,14 @@ void WindowImplWin32::setTitle(const String& title) //////////////////////////////////////////////////////////// -void WindowImplWin32::setIcon(const Vector2u& size, const Uint8* pixels) +void WindowImplWin32::setIcon(const Vector2u& size, const std::uint8_t* pixels) { // First destroy the previous one if (m_icon) DestroyIcon(m_icon); // Windows wants BGRA pixels: swap red and blue channels - std::vector iconPixels(size.x * size.y * 4); + std::vector iconPixels(size.x * size.y * 4); for (std::size_t i = 0; i < iconPixels.size() / 4; ++i) { iconPixels[i * 4 + 0] = pixels[i * 4 + 2]; diff --git a/src/SFML/Window/Win32/WindowImplWin32.hpp b/src/SFML/Window/Win32/WindowImplWin32.hpp index a2ab53c0c..dafb28922 100644 --- a/src/SFML/Window/Win32/WindowImplWin32.hpp +++ b/src/SFML/Window/Win32/WindowImplWin32.hpp @@ -126,7 +126,7 @@ public: /// \param pixels Pointer to the pixels in memory, format must be RGBA 32 bits /// //////////////////////////////////////////////////////////// - void setIcon(const Vector2u& size, const Uint8* pixels) override; + void setIcon(const Vector2u& size, const std::uint8_t* pixels) override; //////////////////////////////////////////////////////////// /// \brief Show or hide the window diff --git a/src/SFML/Window/WindowBase.cpp b/src/SFML/Window/WindowBase.cpp index 14757ae0c..dcea8fd39 100644 --- a/src/SFML/Window/WindowBase.cpp +++ b/src/SFML/Window/WindowBase.cpp @@ -229,7 +229,7 @@ void WindowBase::setTitle(const String& title) //////////////////////////////////////////////////////////// -void WindowBase::setIcon(const Vector2u& size, const Uint8* pixels) +void WindowBase::setIcon(const Vector2u& size, const std::uint8_t* pixels) { if (m_impl) m_impl->setIcon(size, pixels); diff --git a/src/SFML/Window/WindowImpl.hpp b/src/SFML/Window/WindowImpl.hpp index 19bd258cb..8f776a24a 100644 --- a/src/SFML/Window/WindowImpl.hpp +++ b/src/SFML/Window/WindowImpl.hpp @@ -180,7 +180,7 @@ public: /// \param pixels Pointer to the pixels in memory, format must be RGBA 32 bits /// //////////////////////////////////////////////////////////// - virtual void setIcon(const Vector2u& size, const Uint8* pixels) = 0; + virtual void setIcon(const Vector2u& size, const std::uint8_t* pixels) = 0; //////////////////////////////////////////////////////////// /// \brief Show or hide the window diff --git a/src/SFML/Window/iOS/ClipboardImpl.mm b/src/SFML/Window/iOS/ClipboardImpl.mm index 980687ab4..50aad8cc7 100644 --- a/src/SFML/Window/iOS/ClipboardImpl.mm +++ b/src/SFML/Window/iOS/ClipboardImpl.mm @@ -58,7 +58,7 @@ String ClipboardImpl::getString() //////////////////////////////////////////////////////////// void ClipboardImpl::setString(const String& text) { - std::basic_string utf8 = text.toUtf8(); + std::basic_string utf8 = text.toUtf8(); NSString* data = [[NSString alloc] initWithBytes:utf8.data() length:utf8.length() encoding:NSUTF8StringEncoding]; UIPasteboard* pboard = [UIPasteboard generalPasteboard]; diff --git a/src/SFML/Window/iOS/CursorImpl.cpp b/src/SFML/Window/iOS/CursorImpl.cpp index c6fec99bf..61a2c27c9 100644 --- a/src/SFML/Window/iOS/CursorImpl.cpp +++ b/src/SFML/Window/iOS/CursorImpl.cpp @@ -40,7 +40,7 @@ CursorImpl::CursorImpl() //////////////////////////////////////////////////////////// -bool CursorImpl::loadFromPixels(const Uint8* /* pixels */, Vector2u /* size */, Vector2u /* hotspot */) +bool CursorImpl::loadFromPixels(const std::uint8_t* /* pixels */, Vector2u /* size */, Vector2u /* hotspot */) { // Not supported return false; diff --git a/src/SFML/Window/iOS/CursorImpl.hpp b/src/SFML/Window/iOS/CursorImpl.hpp index 1d4f59805..0de47cdf8 100644 --- a/src/SFML/Window/iOS/CursorImpl.hpp +++ b/src/SFML/Window/iOS/CursorImpl.hpp @@ -72,7 +72,7 @@ public: /// Returns false. /// //////////////////////////////////////////////////////////// - bool loadFromPixels(const Uint8* pixels, Vector2u size, Vector2u hotspot); + bool loadFromPixels(const std::uint8_t* pixels, Vector2u size, Vector2u hotspot); //////////////////////////////////////////////////////////// /// \brief Create a native system cursor diff --git a/src/SFML/Window/iOS/WindowImplUIKit.hpp b/src/SFML/Window/iOS/WindowImplUIKit.hpp index ad41dd212..b10802f25 100644 --- a/src/SFML/Window/iOS/WindowImplUIKit.hpp +++ b/src/SFML/Window/iOS/WindowImplUIKit.hpp @@ -129,7 +129,7 @@ public: /// \param pixels Pointer to the pixels in memory, format must be RGBA 32 bits /// //////////////////////////////////////////////////////////// - void setIcon(const Vector2u& size, const Uint8* pixels) override; + void setIcon(const Vector2u& size, const std::uint8_t* pixels) override; //////////////////////////////////////////////////////////// /// \brief Show or hide the window diff --git a/src/SFML/Window/iOS/WindowImplUIKit.mm b/src/SFML/Window/iOS/WindowImplUIKit.mm index f9f17baa8..6c283c46c 100644 --- a/src/SFML/Window/iOS/WindowImplUIKit.mm +++ b/src/SFML/Window/iOS/WindowImplUIKit.mm @@ -161,7 +161,7 @@ void WindowImplUIKit::setTitle(const String& /* title */) //////////////////////////////////////////////////////////// -void WindowImplUIKit::setIcon(const Vector2u& /* size */, const Uint8* /* pixels */) +void WindowImplUIKit::setIcon(const Vector2u& /* size */, const std::uint8_t* /* pixels */) { // Not applicable } diff --git a/test/Graphics/Image.cpp b/test/Graphics/Image.cpp index 06d9d27c3..bd786b4c0 100644 --- a/test/Graphics/Image.cpp +++ b/test/Graphics/Image.cpp @@ -49,10 +49,10 @@ TEST_CASE("sf::Image - [graphics]") } } - SUBCASE("create(Vector2, Uint8*)") + SUBCASE("create(Vector2, std::uint8_t*)") { // 10 x 10, with 4 colour channels array - std::array pixels; + std::array pixels; for (std::size_t i = 0; i < pixels.size(); i += 4) { pixels[i] = 255; // r @@ -135,12 +135,12 @@ TEST_CASE("sf::Image - [graphics]") const sf::Color source(5, 255, 78, 232); // Create the composited colour for via the alpha composite over operation - const auto a = static_cast(source.a + (dest.a * (255 - source.a)) / 255); - const auto r = static_cast( + const auto a = static_cast(source.a + (dest.a * (255 - source.a)) / 255); + const auto r = static_cast( ((source.r * source.a) + (((dest.r * dest.a) * (255 - source.a))) / 255) / a); - const auto g = static_cast( + const auto g = static_cast( ((source.g * source.a) + (((dest.g * dest.a) * (255 - source.a))) / 255) / a); - const auto b = static_cast( + const auto b = static_cast( ((source.b * source.a) + (((dest.b * dest.a) * (255 - source.a))) / 255) / a); const sf::Color composite(r, g, b, a); @@ -214,7 +214,7 @@ TEST_CASE("sf::Image - [graphics]") } } - SUBCASE("createMaskFromColor(Color, Uint8)") + SUBCASE("createMaskFromColor(Color, std::uint8_t)") { sf::Image image; image.create(sf::Vector2u(10, 10), sf::Color::Blue); diff --git a/test/System/Config.cpp b/test/System/Config.cpp index 482d5b929..b1fe65bca 100644 --- a/test/System/Config.cpp +++ b/test/System/Config.cpp @@ -14,8 +14,6 @@ TEST_CASE("SFML/Config.hpp") SUBCASE("Fixed width types") { - CHECK(sizeof(sf::Uint8) == 1); - CHECK(sizeof(sf::Int16) == 2); CHECK(sizeof(sf::Uint16) == 2);