diff options
author | Nick Johnson <sylvyrfysh@gmail.com> | 2021-12-19 15:46:55 -0600 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-12-21 22:13:51 +0100 |
commit | 08e4a1a4dcbf07853f3c1a63adb64298fc236e3f (patch) | |
tree | 96b88d0dd878850c1e9cb7313a28f26964435536 /Userland/Libraries/LibGfx | |
parent | 26bb3e1acf4aa1814573d628af356f9fbb628786 (diff) | |
download | serenity-08e4a1a4dcbf07853f3c1a63adb64298fc236e3f.zip |
AK+Everywhere: Replace __builtin bit functions
In order to reduce our reliance on __builtin_{ffs, clz, ctz, popcount},
this commit removes all calls to these functions and replaces them with
the equivalent functions in AK/BuiltinWrappers.h.
Diffstat (limited to 'Userland/Libraries/LibGfx')
-rw-r--r-- | Userland/Libraries/LibGfx/BMPLoader.cpp | 5 | ||||
-rw-r--r-- | Userland/Libraries/LibGfx/BitmapFont.cpp | 5 |
2 files changed, 6 insertions, 4 deletions
diff --git a/Userland/Libraries/LibGfx/BMPLoader.cpp b/Userland/Libraries/LibGfx/BMPLoader.cpp index d642117177..1e5a0f0d6f 100644 --- a/Userland/Libraries/LibGfx/BMPLoader.cpp +++ b/Userland/Libraries/LibGfx/BMPLoader.cpp @@ -4,6 +4,7 @@ * SPDX-License-Identifier: BSD-2-Clause */ +#include <AK/BuiltinWrappers.h> #include <AK/Debug.h> #include <AK/Function.h> #include <AK/String.h> @@ -326,9 +327,9 @@ static void populate_dib_mask_info_if_needed(BMPLoadingContext& context) mask_sizes.append(0); continue; } - int trailing_zeros = count_trailing_zeroes_32(mask); + int trailing_zeros = count_trailing_zeroes(mask); // If mask is exactly `0xFFFFFFFF`, then we might try to count the trailing zeros of 0x00000000 here, so we need the safe version: - int size = count_trailing_zeroes_32_safe(~(mask >> trailing_zeros)); + int size = count_trailing_zeroes_safe(~(mask >> trailing_zeros)); if (size > 8) { // Drop lowest bits if mask is longer than 8 bits. trailing_zeros += size - 8; diff --git a/Userland/Libraries/LibGfx/BitmapFont.cpp b/Userland/Libraries/LibGfx/BitmapFont.cpp index d7d55e0dd6..6d2f1b6ee6 100644 --- a/Userland/Libraries/LibGfx/BitmapFont.cpp +++ b/Userland/Libraries/LibGfx/BitmapFont.cpp @@ -6,6 +6,7 @@ #include "BitmapFont.h" #include "Emoji.h" +#include <AK/BuiltinWrappers.h> #include <AK/Utf32View.h> #include <AK/Utf8View.h> #include <LibCore/FileStream.h> @@ -95,7 +96,7 @@ NonnullRefPtr<BitmapFont> BitmapFont::masked_character_set() const } size_t new_glyph_count { 0 }; for (size_t i = 0; i < new_range_mask_size; ++i) { - new_glyph_count += 256 * __builtin_popcount(new_range_mask[i]); + new_glyph_count += 256 * popcount(new_range_mask[i]); } size_t bytes_per_glyph = sizeof(u32) * m_glyph_height; auto* new_rows = static_cast<u8*>(calloc(new_glyph_count, bytes_per_glyph)); @@ -191,7 +192,7 @@ RefPtr<BitmapFont> BitmapFont::load_from_memory(const u8* data) size_t glyph_count { 0 }; u8* range_mask = const_cast<u8*>(data + sizeof(FontFileHeader)); for (size_t i = 0; i < header.range_mask_size; ++i) - glyph_count += 256 * __builtin_popcount(range_mask[i]); + glyph_count += 256 * popcount(range_mask[i]); u8* rows = range_mask + header.range_mask_size; u8* widths = (u8*)(rows) + glyph_count * bytes_per_glyph; return adopt_ref(*new BitmapFont(String(header.name), String(header.family), rows, widths, !header.is_variable_width, header.glyph_width, header.glyph_height, header.glyph_spacing, header.range_mask_size, range_mask, header.baseline, header.mean_line, header.presentation_size, header.weight, header.slope)); |