@@ -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-
6542enum 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
268246ALWAYS_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