SDL: Add a function to convert from SDL_PixelFormat to Graphics::PixelFormat
This commit is contained in:
parent
4c708dc97f
commit
342733cee6
3 changed files with 19 additions and 30 deletions
|
@ -493,6 +493,14 @@ static void maskToBitCount(Uint32 mask, uint8 &numBits, uint8 &shift) {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Graphics::PixelFormat SurfaceSdlGraphicsManager::convertSDLPixelFormat(SDL_PixelFormat *in) const {
|
||||||
|
return Graphics::PixelFormat(in->BytesPerPixel,
|
||||||
|
8 - in->Rloss, 8 - in->Gloss,
|
||||||
|
8 - in->Bloss, 8 - in->Aloss,
|
||||||
|
in->Rshift, in->Gshift,
|
||||||
|
in->Bshift, in->Ashift);
|
||||||
|
}
|
||||||
|
|
||||||
void SurfaceSdlGraphicsManager::detectSupportedFormats() {
|
void SurfaceSdlGraphicsManager::detectSupportedFormats() {
|
||||||
_supportedFormats.clear();
|
_supportedFormats.clear();
|
||||||
|
|
||||||
|
@ -570,11 +578,7 @@ void SurfaceSdlGraphicsManager::detectSupportedFormats() {
|
||||||
|
|
||||||
if (_hwScreen) {
|
if (_hwScreen) {
|
||||||
// Get our currently set hardware format
|
// Get our currently set hardware format
|
||||||
Graphics::PixelFormat hwFormat(_hwScreen->format->BytesPerPixel,
|
Graphics::PixelFormat hwFormat = convertSDLPixelFormat(_hwScreen->format);
|
||||||
8 - _hwScreen->format->Rloss, 8 - _hwScreen->format->Gloss,
|
|
||||||
8 - _hwScreen->format->Bloss, 8 - _hwScreen->format->Aloss,
|
|
||||||
_hwScreen->format->Rshift, _hwScreen->format->Gshift,
|
|
||||||
_hwScreen->format->Bshift, _hwScreen->format->Ashift);
|
|
||||||
|
|
||||||
// Workaround to SDL not providing an accurate Aloss value on Mac OS X.
|
// Workaround to SDL not providing an accurate Aloss value on Mac OS X.
|
||||||
if (_hwScreen->format->Amask == 0)
|
if (_hwScreen->format->Amask == 0)
|
||||||
|
@ -1041,17 +1045,7 @@ bool SurfaceSdlGraphicsManager::loadGFXMode() {
|
||||||
if (_overlayscreen == NULL)
|
if (_overlayscreen == NULL)
|
||||||
error("allocating _overlayscreen failed");
|
error("allocating _overlayscreen failed");
|
||||||
|
|
||||||
_overlayFormat.bytesPerPixel = _overlayscreen->format->BytesPerPixel;
|
_overlayFormat = convertSDLPixelFormat(_overlayscreen->format);
|
||||||
|
|
||||||
_overlayFormat.rLoss = _overlayscreen->format->Rloss;
|
|
||||||
_overlayFormat.gLoss = _overlayscreen->format->Gloss;
|
|
||||||
_overlayFormat.bLoss = _overlayscreen->format->Bloss;
|
|
||||||
_overlayFormat.aLoss = _overlayscreen->format->Aloss;
|
|
||||||
|
|
||||||
_overlayFormat.rShift = _overlayscreen->format->Rshift;
|
|
||||||
_overlayFormat.gShift = _overlayscreen->format->Gshift;
|
|
||||||
_overlayFormat.bShift = _overlayscreen->format->Bshift;
|
|
||||||
_overlayFormat.aShift = _overlayscreen->format->Ashift;
|
|
||||||
|
|
||||||
_tmpscreen2 = SDL_CreateRGBSurface(SDL_SWSURFACE, _videoMode.overlayWidth + 3, _videoMode.overlayHeight + 3,
|
_tmpscreen2 = SDL_CreateRGBSurface(SDL_SWSURFACE, _videoMode.overlayWidth + 3, _videoMode.overlayHeight + 3,
|
||||||
16,
|
16,
|
||||||
|
@ -2362,11 +2356,7 @@ void SurfaceSdlGraphicsManager::displayMessageOnOSD(const char *msg) {
|
||||||
|
|
||||||
Graphics::Surface dst;
|
Graphics::Surface dst;
|
||||||
dst.init(_osdMessageSurface->w, _osdMessageSurface->h, _osdMessageSurface->pitch, _osdMessageSurface->pixels,
|
dst.init(_osdMessageSurface->w, _osdMessageSurface->h, _osdMessageSurface->pitch, _osdMessageSurface->pixels,
|
||||||
Graphics::PixelFormat(_osdMessageSurface->format->BytesPerPixel,
|
convertSDLPixelFormat(_osdMessageSurface->format));
|
||||||
8 - _osdMessageSurface->format->Rloss, 8 - _osdMessageSurface->format->Gloss,
|
|
||||||
8 - _osdMessageSurface->format->Bloss, 8 - _osdMessageSurface->format->Aloss,
|
|
||||||
_osdMessageSurface->format->Rshift, _osdMessageSurface->format->Gshift,
|
|
||||||
_osdMessageSurface->format->Bshift, _osdMessageSurface->format->Ashift));
|
|
||||||
|
|
||||||
// Render the message, centered, and in white
|
// Render the message, centered, and in white
|
||||||
for (i = 0; i < lines.size(); i++) {
|
for (i = 0; i < lines.size(); i++) {
|
||||||
|
|
|
@ -118,6 +118,12 @@ protected:
|
||||||
virtual void setPalette(const byte *colors, uint start, uint num) override;
|
virtual void setPalette(const byte *colors, uint start, uint num) override;
|
||||||
virtual void grabPalette(byte *colors, uint start, uint num) const override;
|
virtual void grabPalette(byte *colors, uint start, uint num) const override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert from the SDL pixel format to Graphics::PixelFormat
|
||||||
|
* @param in The SDL pixel format to convert
|
||||||
|
* @param out A pixel format to be written to
|
||||||
|
*/
|
||||||
|
Graphics::PixelFormat convertSDLPixelFormat(SDL_PixelFormat *in) const;
|
||||||
public:
|
public:
|
||||||
virtual void copyRectToScreen(const void *buf, int pitch, int x, int y, int w, int h) override;
|
virtual void copyRectToScreen(const void *buf, int pitch, int x, int y, int w, int h) override;
|
||||||
virtual Graphics::Surface *lockScreen() override;
|
virtual Graphics::Surface *lockScreen() override;
|
||||||
|
|
|
@ -883,15 +883,8 @@ bool WINCESdlGraphicsManager::loadGFXMode() {
|
||||||
InitScalers(555);
|
InitScalers(555);
|
||||||
else
|
else
|
||||||
InitScalers(565);
|
InitScalers(565);
|
||||||
_overlayFormat.bytesPerPixel = _hwscreen->format->BytesPerPixel;
|
|
||||||
_overlayFormat.rLoss = _hwscreen->format->Rloss;
|
_overlayFormat = convertSDLPixelFormat(_hwscreen->format);
|
||||||
_overlayFormat.gLoss = _hwscreen->format->Gloss;
|
|
||||||
_overlayFormat.bLoss = _hwscreen->format->Bloss;
|
|
||||||
_overlayFormat.aLoss = _hwscreen->format->Aloss;
|
|
||||||
_overlayFormat.rShift = _hwscreen->format->Rshift;
|
|
||||||
_overlayFormat.gShift = _hwscreen->format->Gshift;
|
|
||||||
_overlayFormat.bShift = _hwscreen->format->Bshift;
|
|
||||||
_overlayFormat.aShift = _hwscreen->format->Ashift;
|
|
||||||
|
|
||||||
// Need some extra bytes around when using 2xSaI
|
// Need some extra bytes around when using 2xSaI
|
||||||
_tmpscreen = SDL_CreateRGBSurface(SDL_SWSURFACE, _videoMode.screenWidth + 3, _videoMode.screenHeight + 3, 16, _hwscreen->format->Rmask, _hwscreen->format->Gmask, _hwscreen->format->Bmask, _hwscreen->format->Amask);
|
_tmpscreen = SDL_CreateRGBSurface(SDL_SWSURFACE, _videoMode.screenWidth + 3, _videoMode.screenHeight + 3, 16, _hwscreen->format->Rmask, _hwscreen->format->Gmask, _hwscreen->format->Bmask, _hwscreen->format->Amask);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue