LibGfx: Remove redundant enum

With the templatized overload of set_pixel() gone, there is no reason to
have two separate enums anymore.
This commit is contained in:
InvalidUsernameException 2025-11-23 13:07:37 +01:00 committed by Jelle Raaijmakers
parent 645052b87e
commit 07f61f2cec
Notes: github-actions[bot] 2025-11-28 17:35:01 +00:00
2 changed files with 19 additions and 39 deletions

View file

@ -34,11 +34,11 @@ struct BackingStore {
size_t Bitmap::minimum_pitch(size_t width, BitmapFormat format)
{
size_t element_size;
switch (determine_storage_format(format)) {
case StorageFormat::BGRx8888:
case StorageFormat::BGRA8888:
case StorageFormat::RGBx8888:
case StorageFormat::RGBA8888:
switch (format) {
case BitmapFormat::BGRx8888:
case BitmapFormat::BGRA8888:
case BitmapFormat::RGBx8888:
case BitmapFormat::RGBA8888:
element_size = 4;
break;
default:

View file

@ -39,29 +39,6 @@ inline bool is_valid_bitmap_format(u32 const format)
}
}
enum class StorageFormat {
BGRx8888,
BGRA8888,
RGBA8888,
RGBx8888,
};
inline StorageFormat determine_storage_format(BitmapFormat format)
{
switch (format) {
case BitmapFormat::BGRx8888:
return StorageFormat::BGRx8888;
case BitmapFormat::BGRA8888:
return StorageFormat::BGRA8888;
case BitmapFormat::RGBA8888:
return StorageFormat::RGBA8888;
case BitmapFormat::RGBx8888:
return StorageFormat::RGBx8888;
default:
VERIFY_NOT_REACHED();
}
}
enum class MaskKind {
Alpha,
Luminance
@ -251,33 +228,36 @@ ALWAYS_INLINE Color Bitmap::get_pixel(int x, int y) const
VERIFY(x >= 0);
VERIFY(x < width());
auto pixel = scanline(y)[x];
switch (determine_storage_format(m_format)) {
case StorageFormat::BGRx8888:
switch (m_format) {
case BitmapFormat::BGRx8888:
return Color::from_rgb(pixel);
case StorageFormat::BGRA8888:
case BitmapFormat::BGRA8888:
return Color::from_argb(pixel);
case StorageFormat::RGBA8888:
case BitmapFormat::RGBA8888:
return Color::from_abgr(pixel);
case StorageFormat::RGBx8888:
case BitmapFormat::RGBx8888:
return Color::from_bgr(pixel);
default:
case BitmapFormat::Invalid:
VERIFY_NOT_REACHED();
}
VERIFY_NOT_REACHED();
}
ALWAYS_INLINE void Bitmap::set_pixel(int x, int y, Color color)
{
switch (determine_storage_format(m_format)) {
case StorageFormat::BGRx8888:
case StorageFormat::BGRA8888:
switch (m_format) {
case BitmapFormat::BGRx8888:
case BitmapFormat::BGRA8888:
scanline(y)[x] = color.value();
return;
case StorageFormat::RGBA8888:
case BitmapFormat::RGBA8888:
scanline(y)[x] = (color.alpha() << 24) | (color.blue() << 16) | (color.green() << 8) | color.red();
return;
case StorageFormat::RGBx8888:
case BitmapFormat::RGBx8888:
scanline(y)[x] = (color.blue() << 16) | (color.green() << 8) | color.red();
return;
case BitmapFormat::Invalid:
VERIFY_NOT_REACHED();
}
VERIFY_NOT_REACHED();
}