[Scummvm-git-logs] scummvm master -> 533bb5b257b7788b99b307381d96f8e54d9e9c75

csnover csnover at users.noreply.github.com
Tue Sep 12 18:05:15 CEST 2017


This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
2228ae255c SDL: List supported 32bpp pixel formats when using SDL2
533bb5b257 SCI32: Improve chance of rendering non-8bpp AVIs


Commit: 2228ae255c176478225ae5ff271db323ee31b9cc
    https://github.com/scummvm/scummvm/commit/2228ae255c176478225ae5ff271db323ee31b9cc
Author: Colin Snover (github.com at zetafleet.com)
Date: 2017-09-12T10:12:53-05:00

Commit Message:
SDL: List supported 32bpp pixel formats when using SDL2

_hwscreen is always initialized to 16bpp so the supported 32bpp
pixel formats would never be put into the list of supported pixel
formats, making it useless for engines to query for usable 32bpp
pixel formats.

This patch changes things so that the native desktop pixel format
is at the top of the supported formats list, and all pixel formats
<= the default desktop pixel format will now show up in the list
of supported formats. ("Supported" is somewhat of a misnomer here
since there is no hardware querying beyond checking the default
desktop pixel format. SDL generally accepts a wide variety of pixel
formats and tries to convert them to whatever the hardware
supports.)

Changed paths:
    backends/graphics/surfacesdl/surfacesdl-graphics.cpp


diff --git a/backends/graphics/surfacesdl/surfacesdl-graphics.cpp b/backends/graphics/surfacesdl/surfacesdl-graphics.cpp
index f84c09f..0718c92 100644
--- a/backends/graphics/surfacesdl/surfacesdl-graphics.cpp
+++ b/backends/graphics/surfacesdl/surfacesdl-graphics.cpp
@@ -464,11 +464,64 @@ Common::List<Graphics::PixelFormat> SurfaceSdlGraphicsManager::getSupportedForma
 	return _supportedFormats;
 }
 
-void SurfaceSdlGraphicsManager::detectSupportedFormats() {
+#if SDL_VERSION_ATLEAST(2, 0, 0)
+static void maskToBitCount(uint32 mask, uint8 &numBits, uint8 &shift) {
+	numBits = 0;
+	shift = 32;
+	for (int i = 0; i < 32; ++i) {
+		if (mask & 1) {
+			if (i < shift) {
+				shift = i;
+			}
+			++numBits;
+		}
+
+		mask >>= 1;
+	}
+}
+#endif
 
-	// Clear old list
+void SurfaceSdlGraphicsManager::detectSupportedFormats() {
 	_supportedFormats.clear();
 
+	Graphics::PixelFormat format = Graphics::PixelFormat::createFormatCLUT8();
+
+#if SDL_VERSION_ATLEAST(2, 0, 0)
+	{
+		SDL_Window *window = _window->getSDLWindow();
+		if (window == nullptr) {
+			error("Could not find ScummVM window for retrieving default display mode");
+		}
+
+		const int displayIndex = SDL_GetWindowDisplayIndex(window);
+		if (displayIndex < 0) {
+			error("Could not find ScummVM window display index");
+		}
+
+		SDL_DisplayMode defaultMode;
+		if (SDL_GetDesktopDisplayMode(displayIndex, &defaultMode) != 0) {
+			error("Could not get default system display mode");
+		}
+
+		int bpp;
+		uint32 rMask, gMask, bMask, aMask;
+		if (SDL_PixelFormatEnumToMasks(defaultMode.format, &bpp, &rMask, &gMask, &bMask, &aMask) != SDL_TRUE) {
+			error("Could not convert system pixel format %s to masks", SDL_GetPixelFormatName(defaultMode.format));
+		}
+
+		const uint8 bytesPerPixel = SDL_BYTESPERPIXEL(defaultMode.format);
+		uint8 rBits, rShift, gBits, gShift, bBits, bShift, aBits, aShift;
+		maskToBitCount(rMask, rBits, rShift);
+		maskToBitCount(gMask, gBits, gShift);
+		maskToBitCount(bMask, bBits, bShift);
+		maskToBitCount(aMask, aBits, aShift);
+
+		format = Graphics::PixelFormat(bytesPerPixel, rBits, gBits, bBits, aBits, rShift, gShift, bShift, aShift);
+
+		_supportedFormats.push_back(format);
+	}
+#endif
+
 	// Some tables with standard formats that we always list
 	// as "supported". If frontend code tries to use one of
 	// these, we will perform the necessary format
@@ -507,10 +560,9 @@ void SurfaceSdlGraphicsManager::detectSupportedFormats() {
 		Graphics::PixelFormat(2, 4, 4, 4, 4, 4, 8, 12, 0)
 	};
 
-	Graphics::PixelFormat format = Graphics::PixelFormat::createFormatCLUT8();
 	if (_hwscreen) {
 		// Get our currently set hardware format
-		format = Graphics::PixelFormat(_hwscreen->format->BytesPerPixel,
+		Graphics::PixelFormat hwFormat(_hwscreen->format->BytesPerPixel,
 			8 - _hwscreen->format->Rloss, 8 - _hwscreen->format->Gloss,
 			8 - _hwscreen->format->Bloss, 8 - _hwscreen->format->Aloss,
 			_hwscreen->format->Rshift, _hwscreen->format->Gshift,
@@ -518,10 +570,13 @@ void SurfaceSdlGraphicsManager::detectSupportedFormats() {
 
 		// Workaround to SDL not providing an accurate Aloss value on Mac OS X.
 		if (_hwscreen->format->Amask == 0)
-			format.aLoss = 8;
+			hwFormat.aLoss = 8;
 
-		// Push it first, as the prefered format.
-		_supportedFormats.push_back(format);
+		_supportedFormats.push_back(hwFormat);
+
+#if !SDL_VERSION_ATLEAST(2, 0, 0)
+		format = hwFormat;
+#endif
 	}
 
 	// TODO: prioritize matching alpha masks


Commit: 533bb5b257b7788b99b307381d96f8e54d9e9c75
    https://github.com/scummvm/scummvm/commit/533bb5b257b7788b99b307381d96f8e54d9e9c75
Author: Colin Snover (github.com at zetafleet.com)
Date: 2017-09-12T11:03:15-05:00

Commit Message:
SCI32: Improve chance of rendering non-8bpp AVIs

OpenGL backends don't always support the pixel format that is
returned by the Indeo 3 decoder when playing the GK2A.AVI from the
GK2 demo. If this happens, use the backend's preferred pixel format
and convert in software.

If a backend doesn't support any 16-bit or 32-bit format, the
playback code will error out. This is probably fine, since there
are not really any of those any more.

Fixes Trac#9994.

Changed paths:
    engines/sci/graphics/video32.cpp


diff --git a/engines/sci/graphics/video32.cpp b/engines/sci/graphics/video32.cpp
index c9c48eb..301092b 100644
--- a/engines/sci/graphics/video32.cpp
+++ b/engines/sci/graphics/video32.cpp
@@ -408,7 +408,22 @@ AVIPlayer::IOStatus AVIPlayer::init(const bool doublePixels) {
 	_drawRect.setHeight(height);
 
 	if (!startHQVideo() && _decoder->getPixelFormat().bytesPerPixel != 1) {
-		g_sci->_gfxFrameout->setPixelFormat(_decoder->getPixelFormat());
+		const Common::List<Graphics::PixelFormat> outFormats = g_system->getSupportedFormats();
+		Graphics::PixelFormat inFormat = _decoder->getPixelFormat();
+		Graphics::PixelFormat bestFormat = outFormats.front();
+		Common::List<Graphics::PixelFormat>::const_iterator it;
+		for (it = outFormats.begin(); it != outFormats.end(); ++it) {
+			if (*it == inFormat) {
+				bestFormat = inFormat;
+				break;
+			}
+		}
+
+		if (bestFormat.bytesPerPixel != 2 && bestFormat.bytesPerPixel != 4) {
+			error("Failed to find any valid output pixel format");
+		}
+
+		g_sci->_gfxFrameout->setPixelFormat(bestFormat);
 	}
 
 	return kIOSuccess;





More information about the Scummvm-git-logs mailing list