diff options
author | Andreas Kling <kling@serenityos.org> | 2022-03-04 22:05:20 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-03-04 23:40:21 +0100 |
commit | 5ace66a9037fa6968b417cfb604ae8419be62271 (patch) | |
tree | acc383f50bfab4f576af6f80b5dffee02a036883 /Userland/Libraries/LibGfx/Bitmap.cpp | |
parent | 5c4bb039266242ee606aceabba5926831de46e83 (diff) | |
download | serenity-5ace66a9037fa6968b417cfb604ae8419be62271.zip |
LibGfx: Rename RGBA32 => ARGB32
The ARGB32 typedef is used for 32-bit #AARRGGBB quadruplets. As such,
the name RGBA32 was misleading, so let's call it ARGB32 instead.
Since endianness is a thing, let's not encode any assumptions about byte
order in the name of this type. ARGB32 is basically a "machine word"
of color.
Diffstat (limited to 'Userland/Libraries/LibGfx/Bitmap.cpp')
-rw-r--r-- | Userland/Libraries/LibGfx/Bitmap.cpp | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/Userland/Libraries/LibGfx/Bitmap.cpp b/Userland/Libraries/LibGfx/Bitmap.cpp index 211acd229a..724d211618 100644 --- a/Userland/Libraries/LibGfx/Bitmap.cpp +++ b/Userland/Libraries/LibGfx/Bitmap.cpp @@ -175,7 +175,7 @@ static bool check_size(IntSize const& size, int scale_factor, BitmapFormat forma return true; } -ErrorOr<NonnullRefPtr<Bitmap>> Bitmap::try_create_with_anonymous_buffer(BitmapFormat format, Core::AnonymousBuffer buffer, IntSize const& size, int scale_factor, Vector<RGBA32> const& palette) +ErrorOr<NonnullRefPtr<Bitmap>> Bitmap::try_create_with_anonymous_buffer(BitmapFormat format, Core::AnonymousBuffer buffer, IntSize const& size, int scale_factor, Vector<ARGB32> const& palette) { if (size_would_overflow(format, size, scale_factor)) return Error::from_string_literal("Gfx::Bitmap::try_create_with_anonymous_buffer size overflow"); @@ -201,7 +201,7 @@ ErrorOr<NonnullRefPtr<Bitmap>> Bitmap::try_create_from_serialized_byte_buffer(By unsigned scale_factor; BitmapFormat format; unsigned palette_size; - Vector<RGBA32> palette; + Vector<ARGB32> palette; auto read = [&]<typename T>(T& value) { if (stream.read({ &value, sizeof(T) }) != sizeof(T)) @@ -231,8 +231,8 @@ ErrorOr<NonnullRefPtr<Bitmap>> Bitmap::try_create_from_serialized_byte_buffer(By auto bitmap = TRY(Bitmap::try_create(format, { width, height }, scale_factor)); - bitmap->m_palette = new RGBA32[palette_size]; - memcpy(bitmap->m_palette, palette.data(), palette_size * sizeof(RGBA32)); + bitmap->m_palette = new ARGB32[palette_size]; + memcpy(bitmap->m_palette, palette.data(), palette_size * sizeof(ARGB32)); data.copy_to({ bitmap->scanline(0), bitmap->size_in_bytes() }); return bitmap; @@ -241,7 +241,7 @@ ErrorOr<NonnullRefPtr<Bitmap>> Bitmap::try_create_from_serialized_byte_buffer(By ByteBuffer Bitmap::serialize_to_byte_buffer() const { // FIXME: Somehow handle possible OOM situation here. - auto buffer = ByteBuffer::create_uninitialized(sizeof(size_t) + 4 * sizeof(unsigned) + sizeof(BitmapFormat) + sizeof(RGBA32) * palette_size(m_format) + size_in_bytes()).release_value_but_fixme_should_propagate_errors(); + auto buffer = ByteBuffer::create_uninitialized(sizeof(size_t) + 4 * sizeof(unsigned) + sizeof(BitmapFormat) + sizeof(ARGB32) * palette_size(m_format) + size_in_bytes()).release_value_but_fixme_should_propagate_errors(); OutputMemoryStream stream { buffer }; auto write = [&]<typename T>(T value) { @@ -268,7 +268,7 @@ ByteBuffer Bitmap::serialize_to_byte_buffer() const return buffer; } -Bitmap::Bitmap(BitmapFormat format, Core::AnonymousBuffer buffer, IntSize const& size, int scale_factor, Vector<RGBA32> const& palette) +Bitmap::Bitmap(BitmapFormat format, Core::AnonymousBuffer buffer, IntSize const& size, int scale_factor, Vector<ARGB32> const& palette) : m_size(size) , m_scale(scale_factor) , m_data(buffer.data<void>()) @@ -561,21 +561,21 @@ 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, Vector<RGBA32> const& source_palette) +void Bitmap::allocate_palette_from_format(BitmapFormat format, Vector<ARGB32> const& source_palette) { size_t size = palette_size(format); if (size == 0) return; - m_palette = new RGBA32[size]; + m_palette = new ARGB32[size]; if (!source_palette.is_empty()) { VERIFY(source_palette.size() == size); - memcpy(m_palette, source_palette.data(), size * sizeof(RGBA32)); + memcpy(m_palette, source_palette.data(), size * sizeof(ARGB32)); } } -Vector<RGBA32> Bitmap::palette_to_vector() const +Vector<ARGB32> Bitmap::palette_to_vector() const { - Vector<RGBA32> vector; + Vector<ARGB32> vector; auto size = palette_size(m_format); vector.ensure_capacity(size); for (size_t i = 0; i < size; ++i) |