mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 19:17:44 +00:00
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.
This commit is contained in:
parent
5c4bb03926
commit
5ace66a903
14 changed files with 84 additions and 84 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue