aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJody Northup2009-06-19 09:28:55 +0000
committerJody Northup2009-06-19 09:28:55 +0000
commit704386d3b09b68f96b6d4160a1a261e3e754f461 (patch)
tree7067ae6b04495b6aa6a2d437c061a057bd1881e6
parent6f2b46964bd3bee3ee12f2c3cd19b62bbb8aa9b6 (diff)
downloadscummvm-rg350-704386d3b09b68f96b6d4160a1a261e3e754f461.tar.gz
scummvm-rg350-704386d3b09b68f96b6d4160a1a261e3e754f461.tar.bz2
scummvm-rg350-704386d3b09b68f96b6d4160a1a261e3e754f461.zip
Removed replaced Graphics::ColorMode enum type with factory methods for Graphics::PixelFormat.
svn-id: r41662
-rw-r--r--backends/platform/sdl/sdl.cpp4
-rw-r--r--backends/platform/sdl/sdl.h23
-rw-r--r--base/main.cpp2
-rw-r--r--engines/engine.cpp3
-rw-r--r--engines/scumm/scumm.cpp2
-rw-r--r--graphics/pixelformat.h114
6 files changed, 41 insertions, 107 deletions
diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp
index 81b5fcc3eb..17ee5941a4 100644
--- a/backends/platform/sdl/sdl.cpp
+++ b/backends/platform/sdl/sdl.cpp
@@ -197,8 +197,8 @@ OSystem_SDL::OSystem_SDL()
#endif
_hwscreen(0), _screen(0), _tmpscreen(0),
#ifdef ENABLE_16BIT
- _screenFormat(Graphics::kFormatCLUT8),
- _cursorFormat(Graphics::kFormatCLUT8),
+ _screenFormat(Graphics::PixelFormat::createFormatCLUT8()),
+ _cursorFormat(Graphics::PixelFormat::createFormatCLUT8()),
#endif
_overlayVisible(false),
_overlayscreen(0), _tmpscreen2(0),
diff --git a/backends/platform/sdl/sdl.h b/backends/platform/sdl/sdl.h
index 598b943e4b..2cb9451a0d 100644
--- a/backends/platform/sdl/sdl.h
+++ b/backends/platform/sdl/sdl.h
@@ -96,22 +96,17 @@ public:
{
SDL_PixelFormat *HWFormat = SDL_GetVideoInfo()->vfmt;
#ifdef ENABLE_32BIT
- if (HWFormat->BitsPerPixel > 32)
- return Graphics::PixelFormat(Graphics::kFormatRGBA8888);
- return Graphics::PixelFormat(HWFormat->BytesPerPixel,
- HWFormat->Rloss, HWFormat->Gloss, HWFormat->Bloss, HWFormat->Aloss,
- HWFormat->Rshift, HWFormat->Gshift, HWFormat->Bshift, HWFormat->Ashift);
-#else //16
- if (HWFormat->BitsPerPixel > 16)
- return Graphics::PixelFormat(Graphics::kFormatRGB565);
- return Graphics::PixelFormat(HWFormat->BytesPerPixel,
- HWFormat->Rloss, HWFormat->Gloss, HWFormat->Bloss, HWFormat->Aloss,
- HWFormat->Rshift, HWFormat->Gshift, HWFormat->Bshift, HWFormat->Ashift);
+ if (HWFormat->BitsPerPixel >= 32)
+ return Graphics::PixelFormat::createFormatRGBA8888();
+ if (HWFormat->BitsPerPixel >= 24)
+ return Graphics::
+ FormatRGB888();
+#endif //ENABLE_32BIT
+ if (HWFormat->BitsPerPixel >= 16)
+ return Graphics::PixelFormat::createFormatRGB565();
}
-#endif //ENABLE_32BIT
-#else //8BIT only
- return Graphics::PixelFormat(Graphics::kFormatCLUT8);
#endif //ENABLE_32BIT or ENABLE_16BIT
+ return Graphics::PixelFormat::createFormatCLUT8();
}
#endif
diff --git a/base/main.cpp b/base/main.cpp
index 6f3bacebb7..56db1a4276 100644
--- a/base/main.cpp
+++ b/base/main.cpp
@@ -227,7 +227,7 @@ static void setupGraphics(OSystem &system) {
system.setGraphicsMode(ConfMan.get("gfx_mode").c_str());
#ifdef ENABLE_16BIT
- system.initFormat(Graphics::PixelFormat(Graphics::kFormatCLUT8));
+ system.initFormat(Graphics::PixelFormat::createFormatCLUT8());
#endif
system.initSize(320, 200);
diff --git a/engines/engine.cpp b/engines/engine.cpp
index 77ce7c44ad..fdf0186a89 100644
--- a/engines/engine.cpp
+++ b/engines/engine.cpp
@@ -126,8 +126,7 @@ void initCommonGFX(bool defaultTo1XScaler) {
}
void initGraphics(int width, int height, bool defaultTo1xScaler) {
#ifdef ENABLE_16BIT
- Graphics::PixelFormat format(Graphics::kFormatCLUT8);
- initGraphics(width,height,defaultTo1xScaler, format);
+ initGraphics(width,height,defaultTo1xScaler, Graphics::PixelFormat::createFormatCLUT8());
}
void initGraphics(int width, int height, bool defaultTo1xScaler, Graphics::PixelFormat format) {
#endif
diff --git a/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp
index 98da55d428..75a03aae0f 100644
--- a/engines/scumm/scumm.cpp
+++ b/engines/scumm/scumm.cpp
@@ -1085,7 +1085,7 @@ Common::Error ScummEngine::init() {
(_screenWidth * _textSurfaceMultiplier > 320));
} else if (_game.features & GF_16BIT_COLOR) {
#ifdef ENABLE_16BIT
- Graphics::PixelFormat format(Graphics::kFormatRGB555);
+ Graphics::PixelFormat format = Graphics::PixelFormat::createFormatRGB555();
initGraphics(_screenWidth, _screenHeight, _screenWidth > 320, format);
if (format != _system->getScreenFormat())
return Common::kUnsupportedColorMode;
diff --git a/graphics/pixelformat.h b/graphics/pixelformat.h
index 37fca07b48..899ef3bdd7 100644
--- a/graphics/pixelformat.h
+++ b/graphics/pixelformat.h
@@ -30,35 +30,6 @@
namespace Graphics {
-#ifdef ENABLE_16BIT
-/**
- * A condensed bit format description.
- *
- * It includes the necessary information to create a PixelFormat and/or
- * ColorMask which fully describe the given color format.
- *
- * It contains two components, the format (8Bit paletted, RGB555, etc)
- * and the order (palette, ARGB, ABGR, etc)
- *
- * Use (format & kFormatTypeMask) to get the type, and (format & kFormatOrderMask)
- * to get the applicable color order.
- */
-enum ColorMode {
-#ifdef ENABLE_16BIT
- kFormatRGB555 = 1,
- kFormatXRGB1555 = 2, // Special case, high bit has special purpose, which may be alpha.
- // Engines should probably handle this bit internally and pass RGB only, though
- kFormatRGB565 = 3,
- kFormatRGBA4444 = 4, // since this mode is commonly supported in game hardware, some unimplemented engines may use it?
-#endif
-#ifdef ENABLE_32BIT
- kFormatRGB888 = 5,
- kFormatRGBA8888 = 6,
-#endif
- kFormatCLUT8 = 0 //256 color palette.
-};
-#endif
-
/**
* A pixel format description.
*
@@ -93,68 +64,37 @@ struct PixelFormat {
rShift = RShift, gShift = GShift, bShift = BShift, aShift = AShift;
}
-#ifdef ENABLE_16BIT
- //Convenience constructor from enum type
+ //"Factory" methods for convenience
//TODO: BGR support
//TODO: Specify alpha position
- explicit inline PixelFormat(ColorMode mode) {
- switch (mode) {
-#ifdef ENABLE_16BIT
- case kFormatRGB555:
- aLoss = 8;
- bytesPerPixel = 2;
- rLoss = gLoss = bLoss = 3;
- break;
- case kFormatXRGB1555:
- //Special case, alpha bit is always high in this mode.
- aLoss = 7;
- bytesPerPixel = 2;
- rLoss = gLoss = bLoss = 3;
- bShift = 0;
- gShift = bShift + bBits();
- rShift = gShift + gBits();
- aShift = rShift + rBits();
- //FIXME: there should be a clean way to handle setting
- //up the color order without prematurely returning.
- //This will probably be handled when alpha position specification is possible
- return;
- case kFormatRGB565:
- bytesPerPixel = 2;
- aLoss = 8;
- gLoss = 2;
- rLoss = bLoss = 3;
- break;
- case kFormatRGBA4444:
- bytesPerPixel = 2;
- aLoss = gLoss = rLoss = bLoss = 4;
- break;
-#endif
+ static inline PixelFormat PixelFormat::createFormatCLUT8() {
+ return PixelFormat(1,8,8,8,8,0,0,0,0);
+ }
+#if (defined ENABLE_16BIT) || (defined ENABLE_32BIT) //TODO: more generic define instead of ENABLE_16BIT
+ //2 Bytes-per-pixel modes
+ static inline PixelFormat PixelFormat::createFormatRGB555() {
+ return PixelFormat(2,3,3,3,8,10,5,0,0);
+ }
+ static inline PixelFormat PixelFormat::createFormatXRGB1555() {
+ //Special case, alpha bit is always high in this mode.
+ return PixelFormat(2,3,3,3,7,10,5,0,15);
+ }
+ static inline PixelFormat PixelFormat::createFormatRGB565() {
+ return PixelFormat(2,3,2,3,8,11,5,0,0);
+ }
+ static inline PixelFormat PixelFormat::createFormatRGBA4444() {
+ return PixelFormat(2,4,4,4,4,12,8,4,0);
+ }
#ifdef ENABLE_32BIT
- case kFormatRGB888:
- bytesPerPixel = 3;
- aLoss = 8;
- gLoss = rLoss = bLoss = 0;
- break;
- case kFormatRGBA8888:
- bytesPerPixel = 4;
- aLoss = gLoss = rLoss = bLoss = 0;
- break;
-#endif
- case kFormatCLUT8:
- default:
- bytesPerPixel = 1;
- rShift = gShift = bShift = aShift = 0;
- rLoss = gLoss = bLoss = aLoss = 8;
- return;
- }
-
- aShift = 0;
- bShift = aBits();
- gShift = bShift + bBits();
- rShift = gShift + gBits();
- return;
+ //3 to 4 byte per pixel modes
+ static inline PixelFormat PixelFormat::createFormatRGB888() {
+ return PixelFormat(3,0,0,0,8,16,8,0,0);
}
-#endif
+ static inline PixelFormat PixelFormat::createFormatRGBA8888() {
+ return PixelFormat(4,0,0,0,0,24,16,8,0);
+ }
+#endif //ENABLE_32BIT
+#endif //ENABLE_16BIT or ENABLE_32BIT
inline bool operator==(const PixelFormat &fmt) const {
// TODO: If aLoss==8, then the value of aShift is irrelevant, and should be ignored.