[Scummvm-git-logs] scummvm master -> 730e0e148ecf969a42a9704d9be96c3029f4b31f

sev- noreply at scummvm.org
Sun Apr 5 23:32:05 UTC 2026


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

Summary:
730e0e148e SURFACESDL: Reject true colour pixel formats when _isHwPalette is enabled


Commit: 730e0e148ecf969a42a9704d9be96c3029f4b31f
    https://github.com/scummvm/scummvm/commit/730e0e148ecf969a42a9704d9be96c3029f4b31f
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2026-04-06T01:32:01+02:00

Commit Message:
SURFACESDL: Reject true colour pixel formats when _isHwPalette is enabled

Changed paths:
    backends/graphics/surfacesdl/surfacesdl-graphics.cpp
    backends/graphics/surfacesdl/surfacesdl-graphics.h
    engines/engine.cpp


diff --git a/backends/graphics/surfacesdl/surfacesdl-graphics.cpp b/backends/graphics/surfacesdl/surfacesdl-graphics.cpp
index 77cb5ffadfe..83d01772306 100644
--- a/backends/graphics/surfacesdl/surfacesdl-graphics.cpp
+++ b/backends/graphics/surfacesdl/surfacesdl-graphics.cpp
@@ -387,9 +387,7 @@ void SurfaceSdlGraphicsManager::beginGFXTransaction() {
 	_transactionDetails.needDisplayResize = false;
 	_transactionDetails.needTextureUpdate = false;
 #endif
-#ifdef USE_RGB_COLOR
 	_transactionDetails.formatChanged = false;
-#endif
 
 	_oldVideoMode = _videoMode;
 }
@@ -443,14 +441,13 @@ OSystem::TransactionError SurfaceSdlGraphicsManager::endGFXTransaction() {
 
 			_videoMode.filtering = _oldVideoMode.filtering;
 		}
-#ifdef USE_RGB_COLOR
+
 		if (_videoMode.format != _oldVideoMode.format) {
 			errors |= OSystem::kTransactionFormatNotSupported;
 
 			_videoMode.format = _oldVideoMode.format;
 			_screenFormat = _videoMode.format;
 		}
-#endif
 
 		if (_videoMode.screenWidth != _oldVideoMode.screenWidth || _videoMode.screenHeight != _oldVideoMode.screenHeight) {
 			errors |= OSystem::kTransactionSizeChangeFailed;
@@ -468,11 +465,7 @@ OSystem::TransactionError SurfaceSdlGraphicsManager::endGFXTransaction() {
 		_oldVideoMode.setup = false;
 	}
 
-#ifdef USE_RGB_COLOR
 	if (_transactionDetails.sizeChanged || _transactionDetails.formatChanged) {
-#else
-	if (_transactionDetails.sizeChanged) {
-#endif
 		unloadGFXMode();
 		if (!loadGFXMode()) {
 			if (_oldVideoMode.setup) {
@@ -709,10 +702,7 @@ void SurfaceSdlGraphicsManager::setGraphicsModeIntern() {
 
 	// If the scalerIndex has changed, change scaler plugins
 	if (&_scalerPlugins[_videoMode.scalerIndex]->get<ScalerPluginObject>() != _scalerPlugin
-#ifdef USE_RGB_COLOR
-		|| _transactionDetails.formatChanged
-#endif
-		) {
+		|| _transactionDetails.formatChanged) {
 		Graphics::PixelFormat format = convertSDLPixelFormat(_hwScreen->format);
 		delete _scaler;
 
@@ -812,7 +802,6 @@ void SurfaceSdlGraphicsManager::initSize(uint w, uint h, const Graphics::PixelFo
 		getDefaultResolution(w, h);
 	}
 
-#ifdef USE_RGB_COLOR
 	//avoid redundant format changes
 	Graphics::PixelFormat newFormat;
 	if (!format)
@@ -827,7 +816,6 @@ void SurfaceSdlGraphicsManager::initSize(uint w, uint h, const Graphics::PixelFo
 		_transactionDetails.formatChanged = true;
 		_screenFormat = newFormat;
 	}
-#endif
 
 #if !SDL_VERSION_ATLEAST(2, 0, 0)
 	// Avoid redundant res changes, only in SDL1. In SDL2, redundancies may not
@@ -997,10 +985,8 @@ bool SurfaceSdlGraphicsManager::loadGFXMode() {
 	if (_screen == nullptr)
 		error("allocating _screen failed");
 
-#ifdef USE_RGB_COLOR
 	// Avoid having SDL_SRCALPHA set even if we supplied an alpha-channel in the format.
 	SDL_SetAlpha(_screen, 0, 255);
-#endif
 
 	// SDL 1.2 palettes default to all black,
 	// SDL 1.3 palettes default to all white,
@@ -1086,6 +1072,9 @@ bool SurfaceSdlGraphicsManager::loadGFXMode() {
 		error("allocating _tmpscreen2 failed");
 
 	if (_isHwPalette) {
+		if (!_screenFormat.isCLUT8())
+			return false;
+
 		SDL_SetColors(_tmpscreen2, _overlayPalette, 0, 256);
 		SDL_SetColors(_overlayscreen, _overlayPalette, 0, 256);
 	}
@@ -2170,7 +2159,6 @@ void SurfaceSdlGraphicsManager::setMouseCursor(const void *buf, uint w, uint h,
 		return;
 	}
 
-#ifdef USE_RGB_COLOR
 	if (mask && format && format->bytesPerPixel > 1 && !_isHwPalette) {
 		const uint numPixels = w * h;
 		const uint inBPP = format->bytesPerPixel;
@@ -2221,7 +2209,6 @@ void SurfaceSdlGraphicsManager::setMouseCursor(const void *buf, uint w, uint h,
 		setMouseCursor(&maskedImage[0], w, h, hotspotX, hotspotY, 0, dontScale, &formatWithAlpha, nullptr, true);
 		return;
 	}
-#endif
 
 	bool formatChanged = false;
 
diff --git a/backends/graphics/surfacesdl/surfacesdl-graphics.h b/backends/graphics/surfacesdl/surfacesdl-graphics.h
index 0ddf4f64732..953b06f4cdf 100644
--- a/backends/graphics/surfacesdl/surfacesdl-graphics.h
+++ b/backends/graphics/surfacesdl/surfacesdl-graphics.h
@@ -245,9 +245,7 @@ protected:
 		bool needTextureUpdate;
 		bool needDisplayResize;
 #endif
-#ifdef USE_RGB_COLOR
 		bool formatChanged;
-#endif
 
 		TransactionDetails() {
 			sizeChanged = false;
@@ -258,9 +256,7 @@ protected:
 			needTextureUpdate = false;
 			needDisplayResize = false;
 #endif
-#ifdef USE_RGB_COLOR
 			formatChanged = false;
-#endif
 		}
 	};
 	TransactionDetails _transactionDetails;
@@ -285,9 +281,7 @@ protected:
 		int screenWidth, screenHeight;
 		int overlayWidth, overlayHeight;
 		int hardwareWidth, hardwareHeight;
-#ifdef USE_RGB_COLOR
 		Graphics::PixelFormat format;
-#endif
 
 		VideoState() {
 			setup = false;
@@ -311,9 +305,7 @@ protected:
 			overlayHeight = 0;
 			hardwareWidth = 0;
 			hardwareHeight = 0;
-#ifdef USE_RGB_COLOR
 			// format set to 0 values by Graphics::PixelFormat constructor
-#endif
 		}
 	};
 	VideoState _videoMode, _oldVideoMode;
@@ -389,11 +381,7 @@ protected:
 
 	SDL_Rect _mouseLastRect, _mouseNextRect;
 	MousePos _mouseCurState;
-#ifdef USE_RGB_COLOR
 	uint32 _mouseKeyColor;
-#else
-	byte _mouseKeyColor;
-#endif
 	bool _disableMouseKeyColor;
 	byte _mappedMouseKeyColor;
 	bool _cursorDontScale;
diff --git a/engines/engine.cpp b/engines/engine.cpp
index 281bee16ed5..ec099010a37 100644
--- a/engines/engine.cpp
+++ b/engines/engine.cpp
@@ -376,14 +376,12 @@ static void warnTransactionFailures(OSystem::TransactionError gfxError, int widt
 	}
 
 	// Just show warnings then these occur:
-#ifdef USE_RGB_COLOR
 	if (gfxError & OSystem::kTransactionFormatNotSupported) {
 		Common::U32String message = _("Could not initialize color format.");
 
 		GUI::MessageDialog dialog(message);
 		dialog.runModal();
 	}
-#endif
 
 	if (gfxError & OSystem::kTransactionModeSwitchFailed) {
 		Common::U32String message;
@@ -434,16 +432,12 @@ int initGraphicsAny(const Graphics::ModeWithFormatList &modes, int start) {
 	for (candidate = start; candidate < (int)modes.size(); candidate++) {
 		g_system->beginGFXTransaction();
 		initCommonGFX(false);
-#ifdef USE_RGB_COLOR
 		if (modes[candidate].hasFormat)
 			g_system->initSize(modes[candidate].width, modes[candidate].height, &modes[candidate].format);
 		else {
 			Graphics::PixelFormat bestFormat = g_system->getSupportedFormats().front();
 			g_system->initSize(modes[candidate].width, modes[candidate].height, &bestFormat);
 		}
-#else
-		g_system->initSize(modes[candidate].width, modes[candidate].height);
-#endif
 		last_width = modes[candidate].width;
 		last_height = modes[candidate].height;
 
@@ -482,14 +476,12 @@ void initGraphics(int width, int height, const Graphics::PixelFormat *format) {
  *					or PixelFormat::createFormatCLUT8() if no matching formats were found.
  */
 inline Graphics::PixelFormat findCompatibleFormat(const Common::List<Graphics::PixelFormat> &backend, const Common::List<Graphics::PixelFormat> &frontend) {
-#ifdef USE_RGB_COLOR
 	for (const auto &back : backend) {
 		for (auto &front : frontend) {
 			if (back == front)
 				return back;
 		}
 	}
-#endif
 	return Graphics::PixelFormat::createFormatCLUT8();
 }
 




More information about the Scummvm-git-logs mailing list