[Scummvm-cvs-logs] SF.net SVN: scummvm:[41662] scummvm/branches/gsoc2009-16bit

upthorn at users.sourceforge.net upthorn at users.sourceforge.net
Fri Jun 19 11:28:56 CEST 2009


Revision: 41662
          http://scummvm.svn.sourceforge.net/scummvm/?rev=41662&view=rev
Author:   upthorn
Date:     2009-06-19 09:28:55 +0000 (Fri, 19 Jun 2009)

Log Message:
-----------
Removed replaced Graphics::ColorMode enum type with factory methods for Graphics::PixelFormat.

Modified Paths:
--------------
    scummvm/branches/gsoc2009-16bit/backends/platform/sdl/sdl.cpp
    scummvm/branches/gsoc2009-16bit/backends/platform/sdl/sdl.h
    scummvm/branches/gsoc2009-16bit/base/main.cpp
    scummvm/branches/gsoc2009-16bit/engines/engine.cpp
    scummvm/branches/gsoc2009-16bit/engines/scumm/scumm.cpp
    scummvm/branches/gsoc2009-16bit/graphics/pixelformat.h

Modified: scummvm/branches/gsoc2009-16bit/backends/platform/sdl/sdl.cpp
===================================================================
--- scummvm/branches/gsoc2009-16bit/backends/platform/sdl/sdl.cpp	2009-06-19 08:47:41 UTC (rev 41661)
+++ scummvm/branches/gsoc2009-16bit/backends/platform/sdl/sdl.cpp	2009-06-19 09:28:55 UTC (rev 41662)
@@ -197,8 +197,8 @@
 #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),

Modified: scummvm/branches/gsoc2009-16bit/backends/platform/sdl/sdl.h
===================================================================
--- scummvm/branches/gsoc2009-16bit/backends/platform/sdl/sdl.h	2009-06-19 08:47:41 UTC (rev 41661)
+++ scummvm/branches/gsoc2009-16bit/backends/platform/sdl/sdl.h	2009-06-19 09:28:55 UTC (rev 41662)
@@ -96,22 +96,17 @@
 		{
 			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
 

Modified: scummvm/branches/gsoc2009-16bit/base/main.cpp
===================================================================
--- scummvm/branches/gsoc2009-16bit/base/main.cpp	2009-06-19 08:47:41 UTC (rev 41661)
+++ scummvm/branches/gsoc2009-16bit/base/main.cpp	2009-06-19 09:28:55 UTC (rev 41662)
@@ -227,7 +227,7 @@
 		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);
 

Modified: scummvm/branches/gsoc2009-16bit/engines/engine.cpp
===================================================================
--- scummvm/branches/gsoc2009-16bit/engines/engine.cpp	2009-06-19 08:47:41 UTC (rev 41661)
+++ scummvm/branches/gsoc2009-16bit/engines/engine.cpp	2009-06-19 09:28:55 UTC (rev 41662)
@@ -126,8 +126,7 @@
 }
 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

Modified: scummvm/branches/gsoc2009-16bit/engines/scumm/scumm.cpp
===================================================================
--- scummvm/branches/gsoc2009-16bit/engines/scumm/scumm.cpp	2009-06-19 08:47:41 UTC (rev 41661)
+++ scummvm/branches/gsoc2009-16bit/engines/scumm/scumm.cpp	2009-06-19 09:28:55 UTC (rev 41662)
@@ -1085,7 +1085,7 @@
 					(_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;

Modified: scummvm/branches/gsoc2009-16bit/graphics/pixelformat.h
===================================================================
--- scummvm/branches/gsoc2009-16bit/graphics/pixelformat.h	2009-06-19 08:47:41 UTC (rev 41661)
+++ scummvm/branches/gsoc2009-16bit/graphics/pixelformat.h	2009-06-19 09:28:55 UTC (rev 41662)
@@ -30,36 +30,7 @@
 
 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.
  *
  * Like ColorMasks it includes the given values to create colors from RGB
@@ -93,68 +64,37 @@
 		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.


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list