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

upthorn at users.sourceforge.net upthorn at users.sourceforge.net
Fri Jul 10 08:46:50 CEST 2009


Revision: 42325
          http://scummvm.svn.sourceforge.net/scummvm/?rev=42325&view=rev
Author:   upthorn
Date:     2009-07-10 06:46:50 +0000 (Fri, 10 Jul 2009)

Log Message:
-----------
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.

Modified Paths:
--------------
    scummvm/branches/gsoc2009-16bit/backends/platform/sdl/graphics.cpp
    scummvm/branches/gsoc2009-16bit/backends/platform/sdl/sdl.h
    scummvm/branches/gsoc2009-16bit/common/system.h

Modified: scummvm/branches/gsoc2009-16bit/backends/platform/sdl/graphics.cpp
===================================================================
--- scummvm/branches/gsoc2009-16bit/backends/platform/sdl/graphics.cpp	2009-07-10 01:17:41 UTC (rev 42324)
+++ scummvm/branches/gsoc2009-16bit/backends/platform/sdl/graphics.cpp	2009-07-10 06:46:50 UTC (rev 42325)
@@ -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 @@
 	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);
 

Modified: scummvm/branches/gsoc2009-16bit/backends/platform/sdl/sdl.h
===================================================================
--- scummvm/branches/gsoc2009-16bit/backends/platform/sdl/sdl.h	2009-07-10 01:17:41 UTC (rev 42324)
+++ scummvm/branches/gsoc2009-16bit/backends/platform/sdl/sdl.h	2009-07-10 06:46:50 UTC (rev 42325)
@@ -86,39 +86,7 @@
 	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.

Modified: scummvm/branches/gsoc2009-16bit/common/system.h
===================================================================
--- scummvm/branches/gsoc2009-16bit/common/system.h	2009-07-10 01:17:41 UTC (rev 42324)
+++ scummvm/branches/gsoc2009-16bit/common/system.h	2009-07-10 06:46:50 UTC (rev 42325)
@@ -381,7 +381,7 @@
 	 *
 	 * @see convertScreenRect
 	 */
-	virtual Common::List<Graphics::PixelFormat> getSupportedFormats() const = 0;
+	virtual Common::List<Graphics::PixelFormat> getSupportedFormats() = 0;
 #else
 	inline Graphics::PixelFormat getScreenFormat() const {
 		return Graphics::PixelFormat::createFormatCLUT8();


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