[Scummvm-tracker] [ScummVM :: Bugs] #16248: GRAPHICS: The cursor manager accepts unsupported cursor masks

ScummVM :: Bugs trac at scummvm.org
Mon Sep 29 07:48:34 UTC 2025


#16248: GRAPHICS: The cursor manager accepts unsupported cursor masks
-------------------------+----------------------
Reporter:  eriktorbjorn  |      Owner:  (none)
    Type:  defect        |     Status:  new
Priority:  normal        |  Component:  Graphics
 Version:                |   Keywords:
    Game:                |
-------------------------+----------------------
 The Mac window manager class recently started using invert masks (for the
 "beam" cursor). It turns out that the SDL Surface graphics backend doesn't
 handle this, but the cursor manager thinks it does.

 I can't submit a pull request at this very moment, but this is how I
 imagine it could be fixed:

 {{{
 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
 }}}

 (Of course, it would be even better if the backend could somehow be made
 to handle invert masks. And there's a third mode that I think even the
 OpenGL backend doesn't support yet.)
-- 
Ticket URL: <https://bugs.scummvm.org/ticket/16248>
ScummVM :: Bugs <https://bugs.scummvm.org>
ScummVM


More information about the Scummvm-tracker mailing list