Skip to content

Commit 07f61f2

Browse files
InvalidUsernameExceptiongmta
authored andcommitted
LibGfx: Remove redundant enum
With the templatized overload of set_pixel() gone, there is no reason to have two separate enums anymore.
1 parent 645052b commit 07f61f2

File tree

2 files changed

+19
-39
lines changed

2 files changed

+19
-39
lines changed

Libraries/LibGfx/Bitmap.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ struct BackingStore {
3434
size_t Bitmap::minimum_pitch(size_t width, BitmapFormat format)
3535
{
3636
size_t element_size;
37-
switch (determine_storage_format(format)) {
38-
case StorageFormat::BGRx8888:
39-
case StorageFormat::BGRA8888:
40-
case StorageFormat::RGBx8888:
41-
case StorageFormat::RGBA8888:
37+
switch (format) {
38+
case BitmapFormat::BGRx8888:
39+
case BitmapFormat::BGRA8888:
40+
case BitmapFormat::RGBx8888:
41+
case BitmapFormat::RGBA8888:
4242
element_size = 4;
4343
break;
4444
default:

Libraries/LibGfx/Bitmap.h

Lines changed: 14 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -39,29 +39,6 @@ inline bool is_valid_bitmap_format(u32 const format)
3939
}
4040
}
4141

42-
enum class StorageFormat {
43-
BGRx8888,
44-
BGRA8888,
45-
RGBA8888,
46-
RGBx8888,
47-
};
48-
49-
inline StorageFormat determine_storage_format(BitmapFormat format)
50-
{
51-
switch (format) {
52-
case BitmapFormat::BGRx8888:
53-
return StorageFormat::BGRx8888;
54-
case BitmapFormat::BGRA8888:
55-
return StorageFormat::BGRA8888;
56-
case BitmapFormat::RGBA8888:
57-
return StorageFormat::RGBA8888;
58-
case BitmapFormat::RGBx8888:
59-
return StorageFormat::RGBx8888;
60-
default:
61-
VERIFY_NOT_REACHED();
62-
}
63-
}
64-
6542
enum class MaskKind {
6643
Alpha,
6744
Luminance
@@ -251,33 +228,36 @@ ALWAYS_INLINE Color Bitmap::get_pixel(int x, int y) const
251228
VERIFY(x >= 0);
252229
VERIFY(x < width());
253230
auto pixel = scanline(y)[x];
254-
switch (determine_storage_format(m_format)) {
255-
case StorageFormat::BGRx8888:
231+
switch (m_format) {
232+
case BitmapFormat::BGRx8888:
256233
return Color::from_rgb(pixel);
257-
case StorageFormat::BGRA8888:
234+
case BitmapFormat::BGRA8888:
258235
return Color::from_argb(pixel);
259-
case StorageFormat::RGBA8888:
236+
case BitmapFormat::RGBA8888:
260237
return Color::from_abgr(pixel);
261-
case StorageFormat::RGBx8888:
238+
case BitmapFormat::RGBx8888:
262239
return Color::from_bgr(pixel);
263-
default:
240+
case BitmapFormat::Invalid:
264241
VERIFY_NOT_REACHED();
265242
}
243+
VERIFY_NOT_REACHED();
266244
}
267245

268246
ALWAYS_INLINE void Bitmap::set_pixel(int x, int y, Color color)
269247
{
270-
switch (determine_storage_format(m_format)) {
271-
case StorageFormat::BGRx8888:
272-
case StorageFormat::BGRA8888:
248+
switch (m_format) {
249+
case BitmapFormat::BGRx8888:
250+
case BitmapFormat::BGRA8888:
273251
scanline(y)[x] = color.value();
274252
return;
275-
case StorageFormat::RGBA8888:
253+
case BitmapFormat::RGBA8888:
276254
scanline(y)[x] = (color.alpha() << 24) | (color.blue() << 16) | (color.green() << 8) | color.red();
277255
return;
278-
case StorageFormat::RGBx8888:
256+
case BitmapFormat::RGBx8888:
279257
scanline(y)[x] = (color.blue() << 16) | (color.green() << 8) | color.red();
280258
return;
259+
case BitmapFormat::Invalid:
260+
VERIFY_NOT_REACHED();
281261
}
282262
VERIFY_NOT_REACHED();
283263
}

0 commit comments

Comments
 (0)