[Scummvm-git-logs] scummvm master -> 7555252c59fcb317c5ed57d42be1f95909c4fd52

eriktorbjorn noreply at scummvm.org
Mon Sep 29 20:19:14 UTC 2025


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:
7555252c59 GAPHICS: Really test if cursor masks are supported in cursor manager


Commit: 7555252c59fcb317c5ed57d42be1f95909c4fd52
    https://github.com/scummvm/scummvm/commit/7555252c59fcb317c5ed57d42be1f95909c4fd52
Author: Torbjörn Andersson (eriktorbjorn at users.sourceforge.net)
Date: 2025-09-29T22:17:43+02:00

Commit Message:
GAPHICS: Really test if cursor masks are supported in cursor manager

Before it would only test if cursor masks in general were supported, not
if the specific type passed to the cursor manager was. This should fix
bug #16284.

Changed paths:
    graphics/cursorman.cpp
    graphics/cursorman.h


diff --git a/graphics/cursorman.cpp b/graphics/cursorman.cpp
index 67e9324568e..689af0f6e6f 100644
--- a/graphics/cursorman.cpp
+++ b/graphics/cursorman.cpp
@@ -85,6 +85,38 @@ bool CursorManager::showMouse(bool visible) {
 	return g_system->showMouse(visible);
 }
 
+bool CursorManager::systemSupportsCursorMask(const byte *mask, uint width, uint height) {
+	if (!mask)
+		return true;
+
+	bool supportsCursorMask = g_system->hasFeature(OSystem::kFeatureCursorMask);
+	bool supportsCursorMaskInvert = g_system->hasFeature(OSystem::kFeatureCursorMaskInvert);
+	bool supportsCursorMaskPaletteXorColorXnor = g_system->hasFeature(OSystem::kFeatureCursorMaskPaletteXorColorXnor);
+
+	for (uint i = 0; i < width * height; i++) {
+		switch (mask[i]) {
+		case kCursorMaskTransparent:
+		case kCursorMaskOpaque:
+			if (!supportsCursorMask)
+				return false;
+			break;
+		case kCursorMaskInvert:
+			if (!supportsCursorMaskInvert)
+				return false;
+			break;
+		case kCursorMaskPaletteXorColorXnor:
+			if (!supportsCursorMaskPaletteXorColorXnor)
+				return false;
+			break;
+		default:
+			warning("Unknown cursor mask value %d", mask[i]);
+			return false;
+		}
+	}
+
+	return true;
+}
+
 void CursorManager::pushCursor(const void *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, bool dontScale, const Graphics::PixelFormat *format, const byte *mask) {
 	PixelFormat pixelFormat;
 	if (format)
@@ -100,7 +132,7 @@ void CursorManager::pushCursor(const void *buf, uint w, uint h, int hotspotX, in
 }
 
 void CursorManager::pushCursor(const Surface &surf, int hotspotX, int hotspotY, uint32 keycolor, bool dontScale, const byte *mask) {
-	if (!g_system->hasFeature(OSystem::kFeatureCursorMask))
+	if (!systemSupportsCursorMask(mask, surf.w, surf.h))
 		mask = nullptr;
 
 	Cursor *cur = new Cursor(surf, hotspotX, hotspotY, keycolor, dontScale, mask);
@@ -161,7 +193,7 @@ void CursorManager::replaceCursor(const void *buf, uint w, uint h, int hotspotX,
 }
 
 void CursorManager::replaceCursor(const Surface &surf, int hotspotX, int hotspotY, uint32 keycolor, bool dontScale, const byte *mask) {
-	if (!g_system->hasFeature(OSystem::kFeatureCursorMask))
+	if (!systemSupportsCursorMask(mask, surf.w, surf.h))
 		mask = nullptr;
 
 	if (_cursorStack.empty()) {
diff --git a/graphics/cursorman.h b/graphics/cursorman.h
index 968f3e165fa..6238802e35a 100644
--- a/graphics/cursorman.h
+++ b/graphics/cursorman.h
@@ -302,6 +302,8 @@ private:
 	Common::Stack<Cursor *> _cursorStack;
 	Common::Stack<Palette *> _cursorPaletteStack;
 	bool _locked;
+
+	bool systemSupportsCursorMask(const byte *mask, uint width, uint height);
 };
 /** @} */
 } // End of namespace Graphics




More information about the Scummvm-git-logs mailing list