From 02e639ea0ceaa4b6a530847dbb043a5c2352e4a2 Mon Sep 17 00:00:00 2001 From: Jody Northup Date: Fri, 10 Jul 2009 19:55:06 +0000 Subject: Fixed a couple of errors in the new getSupportedFormats implementation. svn-id: r42350 --- backends/platform/sdl/graphics.cpp | 39 ++++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 12 deletions(-) (limited to 'backends/platform/sdl') 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 OSystem_SDL::getSupportedFormats() { static Common::List 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; -- cgit v1.2.3