diff options
author | Andreas Kling <kling@serenityos.org> | 2021-11-06 13:29:13 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-11-08 00:35:27 +0100 |
commit | 16f064d9bea97b499843e1a90a545a738d9c35fd (patch) | |
tree | 6c33c69891628d00475b726e215b715d67dfe553 /Userland/Libraries/LibGfx/Bitmap.cpp | |
parent | d85d741c5975dfa6e2883e93ac555c57ea9d4340 (diff) | |
download | serenity-16f064d9bea97b499843e1a90a545a738d9c35fd.zip |
LibGfx: Convert Gfx::Bitmap to east const style
Diffstat (limited to 'Userland/Libraries/LibGfx/Bitmap.cpp')
-rw-r--r-- | Userland/Libraries/LibGfx/Bitmap.cpp | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/Userland/Libraries/LibGfx/Bitmap.cpp b/Userland/Libraries/LibGfx/Bitmap.cpp index eb59326d67..198840fdde 100644 --- a/Userland/Libraries/LibGfx/Bitmap.cpp +++ b/Userland/Libraries/LibGfx/Bitmap.cpp @@ -55,7 +55,7 @@ size_t Bitmap::minimum_pitch(size_t physical_width, BitmapFormat format) return physical_width * element_size; } -static bool size_would_overflow(BitmapFormat format, const IntSize& size, int scale_factor) +static bool size_would_overflow(BitmapFormat format, IntSize const& size, int scale_factor) { if (size.width() < 0 || size.height() < 0) return true; @@ -67,7 +67,7 @@ static bool size_would_overflow(BitmapFormat format, const IntSize& size, int sc return Checked<size_t>::multiplication_would_overflow(pitch, size.height() * scale_factor); } -RefPtr<Bitmap> Bitmap::try_create(BitmapFormat format, const IntSize& size, int scale_factor) +RefPtr<Bitmap> Bitmap::try_create(BitmapFormat format, IntSize const& size, int scale_factor) { auto backing_store_or_error = Bitmap::allocate_backing_store(format, size, scale_factor); if (backing_store_or_error.is_error()) @@ -75,20 +75,20 @@ RefPtr<Bitmap> Bitmap::try_create(BitmapFormat format, const IntSize& size, int return adopt_ref(*new Bitmap(format, size, scale_factor, backing_store_or_error.release_value())); } -ErrorOr<NonnullRefPtr<Bitmap>> Bitmap::try_create_shareable(BitmapFormat format, const IntSize& size, int scale_factor) +ErrorOr<NonnullRefPtr<Bitmap>> Bitmap::try_create_shareable(BitmapFormat format, IntSize const& size, int scale_factor) { if (size_would_overflow(format, size, scale_factor)) return Error::from_string_literal("Gfx::Bitmap::try_create_shareable size overflow"sv); - const auto pitch = minimum_pitch(size.width() * scale_factor, format); - const auto data_size = size_in_bytes(pitch, size.height() * scale_factor); + auto const pitch = minimum_pitch(size.width() * scale_factor, format); + auto const data_size = size_in_bytes(pitch, size.height() * scale_factor); auto buffer = TRY(Core::AnonymousBuffer::create_with_size(round_up_to_power_of_two(data_size, PAGE_SIZE))); auto bitmap = TRY(Bitmap::try_create_with_anonymous_buffer(format, buffer, size, scale_factor, {})); return bitmap; } -Bitmap::Bitmap(BitmapFormat format, const IntSize& size, int scale_factor, const BackingStore& backing_store) +Bitmap::Bitmap(BitmapFormat format, IntSize const& size, int scale_factor, BackingStore const& backing_store) : m_size(size) , m_scale(scale_factor) , m_data(backing_store.data) @@ -134,7 +134,7 @@ RefPtr<Bitmap> Bitmap::try_load_from_fd_and_close(int fd, String const& path, in if (path.ends_with(Ext, CaseSensitivity::CaseInsensitive)) { \ auto file = MappedFile::map_from_fd_and_close(fd, highdpi_icon_path.to_string()); \ if (!file.is_error()) \ - bmp = load_##Name##_from_memory((const u8*)file.value()->data(), file.value()->size(), highdpi_icon_path.to_string()); \ + bmp = load_##Name##_from_memory((u8 const*)file.value()->data(), file.value()->size(), highdpi_icon_path.to_string()); \ } ENUMERATE_IMAGE_FORMATS #undef __ENUMERATE_IMAGE_FORMAT @@ -152,7 +152,7 @@ RefPtr<Bitmap> Bitmap::try_load_from_fd_and_close(int fd, String const& path, in if (path.ends_with(Ext, CaseSensitivity::CaseInsensitive)) { \ auto file = MappedFile::map_from_fd_and_close(fd, path); \ if (!file.is_error()) \ - return load_##Name##_from_memory((const u8*)file.value()->data(), file.value()->size(), path); \ + return load_##Name##_from_memory((u8 const*)file.value()->data(), file.value()->size(), path); \ } ENUMERATE_IMAGE_FORMATS #undef __ENUMERATE_IMAGE_FORMAT @@ -160,7 +160,7 @@ RefPtr<Bitmap> Bitmap::try_load_from_fd_and_close(int fd, String const& path, in return nullptr; } -Bitmap::Bitmap(BitmapFormat format, const IntSize& size, int scale_factor, size_t pitch, void* data) +Bitmap::Bitmap(BitmapFormat format, IntSize const& size, int scale_factor, size_t pitch, void* data) : m_size(size) , m_scale(scale_factor) , m_data(data) @@ -174,7 +174,7 @@ Bitmap::Bitmap(BitmapFormat format, const IntSize& size, int scale_factor, size_ allocate_palette_from_format(format, {}); } -static bool check_size(const IntSize& size, int scale_factor, BitmapFormat format, unsigned actual_size) +static bool check_size(IntSize const& size, int scale_factor, BitmapFormat format, unsigned actual_size) { // FIXME: Code duplication of size_in_bytes() and m_pitch unsigned expected_size_min = Bitmap::minimum_pitch(size.width() * scale_factor, format) * size.height() * scale_factor; @@ -194,7 +194,7 @@ static bool check_size(const IntSize& size, int scale_factor, BitmapFormat forma return true; } -ErrorOr<NonnullRefPtr<Bitmap>> Bitmap::try_create_with_anonymous_buffer(BitmapFormat format, Core::AnonymousBuffer buffer, const IntSize& size, int scale_factor, const Vector<RGBA32>& palette) +ErrorOr<NonnullRefPtr<Bitmap>> Bitmap::try_create_with_anonymous_buffer(BitmapFormat format, Core::AnonymousBuffer buffer, IntSize const& size, int scale_factor, Vector<RGBA32> const& palette) { if (size_would_overflow(format, size, scale_factor)) return Error::from_string_literal("Gfx::Bitmap::try_create_with_anonymous_buffer size overflow"); @@ -290,7 +290,7 @@ ByteBuffer Bitmap::serialize_to_byte_buffer() const return buffer; } -Bitmap::Bitmap(BitmapFormat format, Core::AnonymousBuffer buffer, const IntSize& size, int scale_factor, const Vector<RGBA32>& palette) +Bitmap::Bitmap(BitmapFormat format, Core::AnonymousBuffer buffer, IntSize const& size, int scale_factor, Vector<RGBA32> const& palette) : m_size(size) , m_scale(scale_factor) , m_data(buffer.data<void>()) @@ -593,8 +593,8 @@ ErrorOr<BackingStore> Bitmap::allocate_backing_store(BitmapFormat format, IntSiz if (size_would_overflow(format, size, scale_factor)) return Error::from_string_literal("Gfx::Bitmap backing store size overflow"sv); - const auto pitch = minimum_pitch(size.width() * scale_factor, format); - const auto data_size_in_bytes = size_in_bytes(pitch, size.height() * scale_factor); + auto const pitch = minimum_pitch(size.width() * scale_factor, format); + auto const data_size_in_bytes = size_in_bytes(pitch, size.height() * scale_factor); int map_flags = MAP_ANONYMOUS | MAP_PRIVATE; #ifdef __serenity__ @@ -608,7 +608,7 @@ ErrorOr<BackingStore> Bitmap::allocate_backing_store(BitmapFormat format, IntSiz return BackingStore { data, pitch, data_size_in_bytes }; } -void Bitmap::allocate_palette_from_format(BitmapFormat format, const Vector<RGBA32>& source_palette) +void Bitmap::allocate_palette_from_format(BitmapFormat format, Vector<RGBA32> const& source_palette) { size_t size = palette_size(format); if (size == 0) |