aboutsummaryrefslogtreecommitdiff
path: root/backends
diff options
context:
space:
mode:
authorJody Northup2009-07-10 06:46:50 +0000
committerJody Northup2009-07-10 06:46:50 +0000
commita5d374bded6204c9250155d572d23b0caef636a5 (patch)
tree883a93b38524e4a4914265a7fbfdaa36fd7fa2fe /backends
parent4e99bee142899dae1385210012dd34453920fe54 (diff)
downloadscummvm-rg350-a5d374bded6204c9250155d572d23b0caef636a5.tar.gz
scummvm-rg350-a5d374bded6204c9250155d572d23b0caef636a5.tar.bz2
scummvm-rg350-a5d374bded6204c9250155d572d23b0caef636a5.zip
Moved OSystem_SDL::getSupportedFormats function body from platforms/sdl/sdl.h to platforms/sdl/graphics.cpp,
Improved and simplified list-generation method for OSystem_SDL::getSupportedFormats. svn-id: r42325
Diffstat (limited to 'backends')
-rw-r--r--backends/platform/sdl/graphics.cpp70
-rw-r--r--backends/platform/sdl/sdl.h34
2 files changed, 71 insertions, 33 deletions
diff --git a/backends/platform/sdl/graphics.cpp b/backends/platform/sdl/graphics.cpp
index fa162a6348..61f33569af 100644
--- a/backends/platform/sdl/graphics.cpp
+++ b/backends/platform/sdl/graphics.cpp
@@ -26,6 +26,9 @@
#include "backends/platform/sdl/sdl.h"
#include "common/mutex.h"
#include "common/util.h"
+#ifdef ENABLE_RGB_COLOR
+#include "common/list.h"
+#endif
#include "graphics/font.h"
#include "graphics/fontman.h"
#include "graphics/scaler.h"
@@ -206,6 +209,73 @@ OSystem::TransactionError OSystem_SDL::endGFXTransaction(void) {
return (TransactionError)errors;
}
+#ifdef ENABLE_RGB_COLOR
+const Graphics::PixelFormat RGBList[] = {
+#ifdef ENABLE_32BIT
+ // RGBA8888, ARGB8888, RGB888
+ Graphics::PixelFormat(4, 0, 0, 0, 0, 24, 16, 8, 0),
+ Graphics::PixelFormat(4, 0, 0, 0, 0, 16, 8, 0, 24),
+ Graphics::PixelFormat(3, 0, 0, 0, 8, 16, 8, 0, 0),
+#endif
+ // RGB565, XRGB1555, RGB555, RGBA4444, ARGB4444
+ Graphics::PixelFormat(2, 3, 2, 3, 8, 11, 5, 0, 0),
+ Graphics::PixelFormat(2, 3, 3, 3, 7, 10, 5, 0, 15),
+ Graphics::PixelFormat(2, 3, 3, 3, 8, 10, 5, 0, 0),
+ Graphics::PixelFormat(2, 4, 4, 4, 4, 12, 8, 4, 0),
+ Graphics::PixelFormat(2, 4, 4, 4, 4, 8, 4, 0, 12)
+};
+const Graphics::PixelFormat BGRList[] = {
+#ifdef ENABLE_32BIT
+ // ABGR8888, BGRA8888, BGR888
+ Graphics::PixelFormat(4, 0, 0, 0, 0, 0, 8, 16, 24),
+ Graphics::PixelFormat(4, 0, 0, 0, 0, 8, 16, 24, 0),
+ Graphics::PixelFormat(3, 0, 0, 0, 8, 0, 8, 16, 0),
+#endif
+ // BGR565, XBGR1555, BGR555, ABGR4444, BGRA4444
+ Graphics::PixelFormat(2, 3, 2, 3, 8, 0, 5, 11, 0),
+ Graphics::PixelFormat(2, 3, 3, 3, 7, 0, 5, 10, 15),
+ Graphics::PixelFormat(2, 3, 3, 3, 8, 0, 5, 10, 0),
+ Graphics::PixelFormat(2, 4, 4, 4, 4, 0, 4, 8, 12),
+ Graphics::PixelFormat(2, 3, 3, 3, 8, 4, 8, 12, 0)
+};
+
+// TODO: prioritize matching alpha masks
+Common::List<Graphics::PixelFormat> OSystem_SDL::getSupportedFormats() {
+ static Common::List<Graphics::PixelFormat> list;
+ if (!list.empty())
+ 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;
+ for (int i = 0; i < listLength; i++) {
+ if (RGBList[i].bytesPerPixel > format.bytesPerPixel)
+ continue;
+ if (BGR) {
+ if (BGRList[i] != format)
+ list.push_back(BGRList[i]);
+ list.push_back(RGBList[i]);
+ } else {
+ if (RGBList[i] != format)
+ list.push_back(RGBList[i]);
+ list.push_back(BGRList[i]);
+ }
+ }
+ list.push_back(Graphics::PixelFormat::createFormatCLUT8());
+ return list;
+}
+#endif
+
bool OSystem_SDL::setGraphicsMode(int mode) {
Common::StackLock lock(_graphicsMutex);
diff --git a/backends/platform/sdl/sdl.h b/backends/platform/sdl/sdl.h
index c2648e8ed7..3e074a884a 100644
--- a/backends/platform/sdl/sdl.h
+++ b/backends/platform/sdl/sdl.h
@@ -86,39 +86,7 @@ public:
virtual Graphics::PixelFormat getScreenFormat() const { return _screenFormat; }
// Highest supported
- virtual Common::List<Graphics::PixelFormat> getSupportedFormats() const {
- //TODO determine hardware color component order
- Common::List<Graphics::PixelFormat> list;
- SDL_PixelFormat *HWFormat = SDL_GetVideoInfo()->vfmt;
-#ifdef ENABLE_32BIT
- if (HWFormat->BitsPerPixel >= 32)
- {
- list.push_back(Graphics::PixelFormat::createFormatRGBA8888());
- list.push_back(Graphics::PixelFormat(4, 0, 0, 0, 0, 16, 8, 0, 24));
- list.push_back(Graphics::PixelFormat(4, 0, 0, 0, 0, 0, 8, 16, 24));
- list.push_back(Graphics::PixelFormat(4, 0, 0, 0, 0, 8, 16, 24, 0));
- }
- if (HWFormat->BitsPerPixel >= 24)
- {
- list.push_back(Graphics::PixelFormat(3, 0, 0, 0, 8, 16, 8, 0, 0));
- list.push_back(Graphics::PixelFormat(3, 0, 0, 0, 8, 0, 8, 16, 0));
- }
-#endif //ENABLE_32BIT
- if (HWFormat->BitsPerPixel >= 16) {
- list.push_back(Graphics::PixelFormat(2, 3, 2, 3, 8, 11, 5, 0, 0));
- list.push_back(Graphics::PixelFormat(2, 3, 3, 3, 7, 10, 5, 0, 15));
- list.push_back(Graphics::PixelFormat(2, 3, 3, 3, 8, 10, 5, 0, 0));
- list.push_back(Graphics::PixelFormat(2, 4, 4, 4, 4, 12, 8, 4, 0));
- list.push_back(Graphics::PixelFormat(2, 4, 4, 4, 4, 8, 4, 0, 12));
- list.push_back(Graphics::PixelFormat(2, 3, 2, 3, 8, 0, 5, 11, 0));
- list.push_back(Graphics::PixelFormat(2, 3, 3, 3, 7, 0, 5, 10, 15));
- list.push_back(Graphics::PixelFormat(2, 3, 3, 3, 8, 0, 5, 10, 0));
- list.push_back(Graphics::PixelFormat(2, 4, 4, 4, 4, 0, 4, 8, 12));
- list.push_back(Graphics::PixelFormat(2, 4, 4, 4, 4, 4, 8, 12, 0));
- }
- list.push_back(Graphics::PixelFormat::createFormatCLUT8());
- return list;
- }
+ virtual Common::List<Graphics::PixelFormat> getSupportedFormats();
#endif
// Set the size and format of the video bitmap.