aboutsummaryrefslogtreecommitdiff
path: root/backends/graphics/surfacesdl/surfacesdl-graphics.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'backends/graphics/surfacesdl/surfacesdl-graphics.cpp')
-rw-r--r--backends/graphics/surfacesdl/surfacesdl-graphics.cpp32
1 files changed, 11 insertions, 21 deletions
diff --git a/backends/graphics/surfacesdl/surfacesdl-graphics.cpp b/backends/graphics/surfacesdl/surfacesdl-graphics.cpp
index dd334f3814..37965d057e 100644
--- a/backends/graphics/surfacesdl/surfacesdl-graphics.cpp
+++ b/backends/graphics/surfacesdl/surfacesdl-graphics.cpp
@@ -493,6 +493,14 @@ static void maskToBitCount(Uint32 mask, uint8 &numBits, uint8 &shift) {
}
#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() {
_supportedFormats.clear();
@@ -570,11 +578,7 @@ void SurfaceSdlGraphicsManager::detectSupportedFormats() {
if (_hwScreen) {
// Get our currently set hardware format
- Graphics::PixelFormat hwFormat(_hwScreen->format->BytesPerPixel,
- 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);
+ Graphics::PixelFormat hwFormat = convertSDLPixelFormat(_hwScreen->format);
// Workaround to SDL not providing an accurate Aloss value on Mac OS X.
if (_hwScreen->format->Amask == 0)
@@ -1041,17 +1045,7 @@ bool SurfaceSdlGraphicsManager::loadGFXMode() {
if (_overlayscreen == NULL)
error("allocating _overlayscreen failed");
- _overlayFormat.bytesPerPixel = _overlayscreen->format->BytesPerPixel;
-
- _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;
+ _overlayFormat = convertSDLPixelFormat(_overlayscreen->format);
_tmpscreen2 = SDL_CreateRGBSurface(SDL_SWSURFACE, _videoMode.overlayWidth + 3, _videoMode.overlayHeight + 3,
16,
@@ -2362,11 +2356,7 @@ void SurfaceSdlGraphicsManager::displayMessageOnOSD(const char *msg) {
Graphics::Surface dst;
dst.init(_osdMessageSurface->w, _osdMessageSurface->h, _osdMessageSurface->pitch, _osdMessageSurface->pixels,
- Graphics::PixelFormat(_osdMessageSurface->format->BytesPerPixel,
- 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));
+ convertSDLPixelFormat(_osdMessageSurface->format));
// Render the message, centered, and in white
for (i = 0; i < lines.size(); i++) {