mirror of https://github.com/encounter/SDL.git
haiku: Combine HAIKU_ColorSpaceToBitsPerPixel and HAIKU_BPPToSDLPxFormat
This commit is contained in:
parent
dd51787e07
commit
1f7a7fd931
|
@ -60,8 +60,7 @@ int HAIKU_CreateWindowFramebuffer(_THIS, SDL_Window * window,
|
||||||
/* format */
|
/* format */
|
||||||
display_mode bmode;
|
display_mode bmode;
|
||||||
bscreen.GetMode(&bmode);
|
bscreen.GetMode(&bmode);
|
||||||
int32 bpp = HAIKU_ColorSpaceToBitsPerPixel(bmode.space);
|
*format = HAIKU_ColorSpaceToSDLPxFormat(bmode.space);
|
||||||
*format = HAIKU_BPPToSDLPxFormat(bpp);
|
|
||||||
|
|
||||||
/* Create the new bitmap object */
|
/* Create the new bitmap object */
|
||||||
BBitmap *bitmap = bwin->GetBitmap();
|
BBitmap *bitmap = bwin->GetBitmap();
|
||||||
|
|
|
@ -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) {
|
switch (colorspace) {
|
||||||
case B_CMAP8:
|
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;
|
|
||||||
break;
|
|
||||||
case 15:
|
|
||||||
return SDL_PIXELFORMAT_RGB555;
|
|
||||||
break;
|
|
||||||
case 8:
|
|
||||||
return SDL_PIXELFORMAT_INDEX8;
|
return SDL_PIXELFORMAT_INDEX8;
|
||||||
break;
|
break;
|
||||||
case 4: /* May not be supported by Haiku */
|
case B_RGB15:
|
||||||
return SDL_PIXELFORMAT_INDEX4LSB;
|
case B_RGBA15:
|
||||||
|
case B_RGB15_BIG:
|
||||||
|
case B_RGBA15_BIG:
|
||||||
|
return SDL_PIXELFORMAT_RGB555;
|
||||||
|
break;
|
||||||
|
case B_RGB16:
|
||||||
|
case B_RGB16_BIG:
|
||||||
|
return SDL_PIXELFORMAT_RGB565;
|
||||||
|
break;
|
||||||
|
case B_RGB32:
|
||||||
|
case B_RGBA32:
|
||||||
|
case B_RGB32_BIG:
|
||||||
|
case B_RGBA32_BIG:
|
||||||
|
return SDL_PIXELFORMAT_RGB888;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* May never get here, but safer and needed to shut up compiler */
|
/* May never get here, but safer and needed to shut up compiler */
|
||||||
SDL_SetError("Invalid bpp value");
|
SDL_SetError("Invalid color space");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -210,8 +180,7 @@ static void _BDisplayModeToSdlDisplayMode(display_mode *bmode,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Set the format */
|
/* Set the format */
|
||||||
int32 bpp = HAIKU_ColorSpaceToBitsPerPixel(bmode->space);
|
mode->format = HAIKU_ColorSpaceToSDLPxFormat(bmode->space);
|
||||||
mode->format = HAIKU_BPPToSDLPxFormat(bpp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Later, there may be more than one monitor available */
|
/* Later, there may be more than one monitor available */
|
||||||
|
|
|
@ -28,8 +28,7 @@ extern "C" {
|
||||||
|
|
||||||
#include "../SDL_sysvideo.h"
|
#include "../SDL_sysvideo.h"
|
||||||
|
|
||||||
extern int32 HAIKU_ColorSpaceToBitsPerPixel(uint32 colorspace);
|
extern int32 HAIKU_ColorSpaceToSDLPxFormat(uint32 colorspace);
|
||||||
extern int32 HAIKU_BPPToSDLPxFormat(int32 bpp);
|
|
||||||
|
|
||||||
extern int HAIKU_InitModes(_THIS);
|
extern int HAIKU_InitModes(_THIS);
|
||||||
extern int HAIKU_QuitModes(_THIS);
|
extern int HAIKU_QuitModes(_THIS);
|
||||||
|
|
Loading…
Reference in New Issue