[Scummvm-git-logs] scummvm master -> 906a957b4a4e8746ae272b8393830165b5e60283

lephilousophe noreply at scummvm.org
Sun Jun 4 16:24:09 UTC 2023


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

Summary:
906a957b4a SURFACESDL: Apply the key color in the cursor margins


Commit: 906a957b4a4e8746ae272b8393830165b5e60283
    https://github.com/scummvm/scummvm/commit/906a957b4a4e8746ae272b8393830165b5e60283
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2023-06-04T18:24:06+02:00

Commit Message:
SURFACESDL: Apply the key color in the cursor margins

This avoids artefacts on borders when using scalers like AdvMame.
This fixes bug #14308

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 9b2052ab09b..17fac57b551 100644
--- a/backends/graphics/surfacesdl/surfacesdl-graphics.cpp
+++ b/backends/graphics/surfacesdl/surfacesdl-graphics.cpp
@@ -2111,7 +2111,12 @@ void SurfaceSdlGraphicsManager::setMouseCursor(const void *buf, uint w, uint h,
 	_mouseCurState.hotX = hotspotX;
 	_mouseCurState.hotY = hotspotY;
 
-	_mouseKeyColor = keyColor;
+	bool keycolorChanged = false;
+
+	if (_mouseKeyColor != keyColor) {
+		_mouseKeyColor = keyColor;
+		keycolorChanged = true;
+	}
 
 	_cursorDontScale = dontScale;
 
@@ -2163,12 +2168,29 @@ void SurfaceSdlGraphicsManager::setMouseCursor(const void *buf, uint w, uint h,
 			_mouseScaler = _scalerPlugin->createInstance(_cursorFormat);
 		}
 #endif
+
+		// Force setup of border
+		keycolorChanged = true;
 	}
 
-	SDL_SetColorKey(_mouseOrigSurface, SDL_RLEACCEL | SDL_SRCCOLORKEY | SDL_SRCALPHA, _mouseKeyColor);
+	if (keycolorChanged) {
+		SDL_SetColorKey(_mouseOrigSurface, SDL_RLEACCEL | SDL_SRCCOLORKEY | SDL_SRCALPHA, _mouseKeyColor);
+	}
 
 	SDL_LockSurface(_mouseOrigSurface);
 
+	if (keycolorChanged && _mouseScaler && _maxExtraPixels > 0 && _cursorFormat.aBits() == 0) {
+		// We have extra pixels and no alpha channel, we must use color key on the borders
+		Graphics::Surface cursorSurface;
+		Common::Rect border(0, 0, _mouseCurState.w + _maxExtraPixels * 2, _mouseCurState.h + _maxExtraPixels * 2);
+		cursorSurface.init(border.width(), border.height(), border.width() * _cursorFormat.bytesPerPixel,
+				_mouseOrigSurface->pixels, _cursorFormat);
+		for(unsigned int i = 0; i < _maxExtraPixels; i++) {
+			cursorSurface.frameRect(border, _mouseKeyColor);
+			border.grow(-1);
+		}
+	}
+
 	// Draw from [_maxExtraPixels,_maxExtraPixels] since scalers will read past boudaries
 	Graphics::copyBlit((byte *)_mouseOrigSurface->pixels + _mouseOrigSurface->pitch * _maxExtraPixels + _maxExtraPixels * _mouseOrigSurface->format->BytesPerPixel,
 	                   (const byte *)buf, _mouseOrigSurface->pitch, w * _cursorFormat.bytesPerPixel, w, h, _cursorFormat.bytesPerPixel);




More information about the Scummvm-git-logs mailing list