haiku: Combine HAIKU_ColorSpaceToBitsPerPixel and HAIKU_BPPToSDLPxFormat
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121
diff --git a/src/video/haiku/SDL_bframebuffer.cc b/src/video/haiku/SDL_bframebuffer.cc
index 9712319..f303177 100644
--- a/src/video/haiku/SDL_bframebuffer.cc
+++ b/src/video/haiku/SDL_bframebuffer.cc
@@ -60,8 +60,7 @@ int HAIKU_CreateWindowFramebuffer(_THIS, SDL_Window * window,
/* format */
display_mode bmode;
bscreen.GetMode(&bmode);
- int32 bpp = HAIKU_ColorSpaceToBitsPerPixel(bmode.space);
- *format = HAIKU_BPPToSDLPxFormat(bpp);
+ *format = HAIKU_ColorSpaceToSDLPxFormat(bmode.space);
/* Create the new bitmap object */
BBitmap *bitmap = bwin->GetBitmap();
diff --git a/src/video/haiku/SDL_bmodes.cc b/src/video/haiku/SDL_bmodes.cc
index 0cbc56b..586e2a9 100644
--- a/src/video/haiku/SDL_bmodes.cc
+++ b/src/video/haiku/SDL_bmodes.cc
@@ -132,62 +132,32 @@ void _SpoutModeData(display_mode *bmode) {
-int32 HAIKU_ColorSpaceToBitsPerPixel(uint32 colorspace)
+int32 HAIKU_ColorSpaceToSDLPxFormat(uint32 colorspace)
{
- int bitsperpixel;
-
- bitsperpixel = 0;
switch (colorspace) {
- case B_CMAP8:
- bitsperpixel = 8;
- break;
- case B_RGB15:
- case B_RGBA15:
- case B_RGB15_BIG:
- case B_RGBA15_BIG:
- bitsperpixel = 15;
- break;
- case B_RGB16:
- case B_RGB16_BIG:
- bitsperpixel = 16;
- break;
- case B_RGB32:
- case B_RGBA32:
- case B_RGB32_BIG:
- case B_RGBA32_BIG:
- bitsperpixel = 32;
- break;
- default:
- break;
- }
- return(bitsperpixel);
-}
-
-int32 HAIKU_BPPToSDLPxFormat(int32 bpp) {
- /* Translation taken from SDL_windowsmodes.c */
- switch (bpp) {
- case 32:
- return SDL_PIXELFORMAT_RGB888;
- break;
- case 24: /* May not be supported by Haiku */
- return SDL_PIXELFORMAT_RGB24;
- break;
- case 16:
- return SDL_PIXELFORMAT_RGB565;
+ case B_CMAP8:
+ return SDL_PIXELFORMAT_INDEX8;
break;
- case 15:
+ case B_RGB15:
+ case B_RGBA15:
+ case B_RGB15_BIG:
+ case B_RGBA15_BIG:
return SDL_PIXELFORMAT_RGB555;
break;
- case 8:
- return SDL_PIXELFORMAT_INDEX8;
+ case B_RGB16:
+ case B_RGB16_BIG:
+ return SDL_PIXELFORMAT_RGB565;
break;
- case 4: /* May not be supported by Haiku */
- return SDL_PIXELFORMAT_INDEX4LSB;
+ case B_RGB32:
+ case B_RGBA32:
+ case B_RGB32_BIG:
+ case B_RGBA32_BIG:
+ return SDL_PIXELFORMAT_RGB888;
break;
}
/* May never get here, but safer and needed to shut up compiler */
- SDL_SetError("Invalid bpp value");
+ SDL_SetError("Invalid color space");
return 0;
}
@@ -210,8 +180,7 @@ static void _BDisplayModeToSdlDisplayMode(display_mode *bmode,
#endif
/* Set the format */
- int32 bpp = HAIKU_ColorSpaceToBitsPerPixel(bmode->space);
- mode->format = HAIKU_BPPToSDLPxFormat(bpp);
+ mode->format = HAIKU_ColorSpaceToSDLPxFormat(bmode->space);
}
/* Later, there may be more than one monitor available */
diff --git a/src/video/haiku/SDL_bmodes.h b/src/video/haiku/SDL_bmodes.h
index 56fa144..5b40418 100644
--- a/src/video/haiku/SDL_bmodes.h
+++ b/src/video/haiku/SDL_bmodes.h
@@ -28,8 +28,7 @@ extern "C" {
#include "../SDL_sysvideo.h"
-extern int32 HAIKU_ColorSpaceToBitsPerPixel(uint32 colorspace);
-extern int32 HAIKU_BPPToSDLPxFormat(int32 bpp);
+extern int32 HAIKU_ColorSpaceToSDLPxFormat(uint32 colorspace);
extern int HAIKU_InitModes(_THIS);
extern int HAIKU_QuitModes(_THIS);