aboutsummaryrefslogtreecommitdiff
path: root/backends/platform/sdl
diff options
context:
space:
mode:
authorJody Northup2009-07-10 19:55:06 +0000
committerJody Northup2009-07-10 19:55:06 +0000
commit02e639ea0ceaa4b6a530847dbb043a5c2352e4a2 (patch)
tree3fbb28d816e099e90d4785c666bd17c4d6353c4a /backends/platform/sdl
parentddcab8169f45055c8272648279c3dd96432ba956 (diff)
downloadscummvm-rg350-02e639ea0ceaa4b6a530847dbb043a5c2352e4a2.tar.gz
scummvm-rg350-02e639ea0ceaa4b6a530847dbb043a5c2352e4a2.tar.bz2
scummvm-rg350-02e639ea0ceaa4b6a530847dbb043a5c2352e4a2.zip
Fixed a couple of errors in the new getSupportedFormats implementation.
svn-id: r42350
Diffstat (limited to 'backends/platform/sdl')
-rw-r--r--backends/platform/sdl/graphics.cpp39
1 files changed, 27 insertions, 12 deletions
diff --git a/backends/platform/sdl/graphics.cpp b/backends/platform/sdl/graphics.cpp
index 61f33569af..ea9c285a44 100644
--- a/backends/platform/sdl/graphics.cpp
+++ b/backends/platform/sdl/graphics.cpp
@@ -242,22 +242,37 @@ const Graphics::PixelFormat BGRList[] = {
// TODO: prioritize matching alpha masks
Common::List<Graphics::PixelFormat> OSystem_SDL::getSupportedFormats() {
static Common::List<Graphics::PixelFormat> list;
- if (!list.empty())
+ static bool inited = false;
+
+ if (inited)
return list;
+
bool BGR = false;
int listLength = ARRAYSIZE(RGBList);
- // Get our currently set format
- Graphics::PixelFormat format(_hwscreen->format->BytesPerPixel,
- _hwscreen->format->Rloss, _hwscreen->format->Gloss,
- _hwscreen->format->Bloss, _hwscreen->format->Aloss,
- _hwscreen->format->Rshift, _hwscreen->format->Gshift,
- _hwscreen->format->Bshift, _hwscreen->format->Ashift);
-
- // Push it first, as the prefered format.
- list.push_back(format);
- if (format.bShift > format.rShift)
- BGR = true;
+ Graphics::PixelFormat format = Graphics::PixelFormat::createFormatCLUT8();
+ if (_hwscreen) {
+ // Get our currently set hardware format
+ format = Graphics::PixelFormat(_hwscreen->format->BytesPerPixel,
+ _hwscreen->format->Rloss, _hwscreen->format->Gloss,
+ _hwscreen->format->Bloss, _hwscreen->format->Aloss,
+ _hwscreen->format->Rshift, _hwscreen->format->Gshift,
+ _hwscreen->format->Bshift, _hwscreen->format->Ashift);
+
+ // Workaround to MacOSX SDL not providing an accurate Aloss value.
+ if (_hwscreen->format->Amask == 0)
+ format.aLoss = 8;
+
+ // Push it first, as the prefered format.
+ list.push_back(format);
+
+ if (format.bShift > format.rShift)
+ BGR = true;
+
+ // Mark that we don't need to do this any more.
+ inited = true;
+ }
+
for (int i = 0; i < listLength; i++) {
if (RGBList[i].bytesPerPixel > format.bytesPerPixel)
continue;