aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Snover2017-09-13 00:47:44 -0500
committerColin Snover2017-10-15 13:24:20 -0500
commit5d8cf6ba42c71e37530e83bb766b60bf1388a904 (patch)
tree626825abc3aa9936050443127a3859a49c54a276
parentda0a8db704f610994d665dfd7c080b49476ce76d (diff)
downloadscummvm-rg350-5d8cf6ba42c71e37530e83bb766b60bf1388a904.tar.gz
scummvm-rg350-5d8cf6ba42c71e37530e83bb766b60bf1388a904.tar.bz2
scummvm-rg350-5d8cf6ba42c71e37530e83bb766b60bf1388a904.zip
BACKENDS: Fix GraphicsManager handling of empty cursors
The SDL graphics manager was just ignoring calls from CursorMan to set the cursor to a blank cursor, which meant engines that did not immediately send a cursor to CursorMan at startup would still show the launcher's cursor (usually with a broken palette). The OpenGL graphics manager would try to generate and draw an invalid cursor surface when receiving an empty cursor.
-rw-r--r--backends/graphics/opengl/opengl-graphics.cpp17
-rw-r--r--backends/graphics/surfacesdl/surfacesdl-graphics.cpp26
2 files changed, 25 insertions, 18 deletions
diff --git a/backends/graphics/opengl/opengl-graphics.cpp b/backends/graphics/opengl/opengl-graphics.cpp
index f3ea372b2a..7bac4c85cb 100644
--- a/backends/graphics/opengl/opengl-graphics.cpp
+++ b/backends/graphics/opengl/opengl-graphics.cpp
@@ -567,6 +567,18 @@ void applyColorKey(DstPixel *dst, const SrcPixel *src, uint w, uint h, uint dstP
} // End of anonymous namespace
void OpenGLGraphicsManager::setMouseCursor(const void *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, bool dontScale, const Graphics::PixelFormat *format) {
+
+ _cursorKeyColor = keycolor;
+ _cursorHotspotX = hotspotX;
+ _cursorHotspotY = hotspotY;
+ _cursorDontScale = dontScale;
+
+ if (!w || !h) {
+ delete _cursor;
+ _cursor = nullptr;
+ return;
+ }
+
Graphics::PixelFormat inputFormat;
#ifdef USE_RGB_COLOR
if (format) {
@@ -602,11 +614,6 @@ void OpenGLGraphicsManager::setMouseCursor(const void *buf, uint w, uint h, int
_cursor->enableLinearFiltering(_currentState.filtering);
}
- _cursorKeyColor = keycolor;
- _cursorHotspotX = hotspotX;
- _cursorHotspotY = hotspotY;
- _cursorDontScale = dontScale;
-
_cursor->allocate(w, h);
if (inputFormat.bytesPerPixel == 1) {
// For CLUT8 cursors we can simply copy the input data into the
diff --git a/backends/graphics/surfacesdl/surfacesdl-graphics.cpp b/backends/graphics/surfacesdl/surfacesdl-graphics.cpp
index f610922cc2..9b6cbb91e1 100644
--- a/backends/graphics/surfacesdl/surfacesdl-graphics.cpp
+++ b/backends/graphics/surfacesdl/surfacesdl-graphics.cpp
@@ -1876,9 +1876,6 @@ void SurfaceSdlGraphicsManager::setMouseCursor(const void *buf, uint w, uint h,
assert(keycolor <= 0xFF);
#endif
- if (w == 0 || h == 0)
- return;
-
_mouseCurState.hotX = hotspot_x;
_mouseCurState.hotY = hotspot_y;
@@ -1890,6 +1887,10 @@ void SurfaceSdlGraphicsManager::setMouseCursor(const void *buf, uint w, uint h,
_mouseCurState.w = w;
_mouseCurState.h = h;
+ if (!w || !h) {
+ return;
+ }
+
if (_mouseOrigSurface)
SDL_FreeSurface(_mouseOrigSurface);
@@ -1928,22 +1929,21 @@ void SurfaceSdlGraphicsManager::blitCursor() {
#else
byte color;
#endif
- int w, h, i, j;
- if (!_mouseOrigSurface || !_mouseData)
+ int w = _mouseCurState.w;
+ int h = _mouseCurState.h;
+
+ if (!_mouseOrigSurface || !_mouseData || !w || !h)
return;
_cursorNeedsRedraw = true;
- w = _mouseCurState.w;
- h = _mouseCurState.h;
-
SDL_LockSurface(_mouseOrigSurface);
// Make whole surface transparent
- for (i = 0; i < h + 2; i++) {
+ for (int i = 0; i < h + 2; i++) {
dstPtr = (byte *)_mouseOrigSurface->pixels + _mouseOrigSurface->pitch * i;
- for (j = 0; j < w + 2; j++) {
+ for (int j = 0; j < w + 2; j++) {
*(uint16 *)dstPtr = kMouseColorKey;
dstPtr += 2;
}
@@ -1959,8 +1959,8 @@ void SurfaceSdlGraphicsManager::blitCursor() {
else
palette = _cursorPalette;
- for (i = 0; i < h; i++) {
- for (j = 0; j < w; j++) {
+ for (int i = 0; i < h; i++) {
+ for (int j = 0; j < w; j++) {
#ifdef USE_RGB_COLOR
if (_cursorFormat.bytesPerPixel > 1) {
if (_cursorFormat.bytesPerPixel == 2)
@@ -2112,7 +2112,7 @@ void SurfaceSdlGraphicsManager::undrawMouse() {
}
void SurfaceSdlGraphicsManager::drawMouse() {
- if (!_cursorVisible || !_mouseSurface) {
+ if (!_cursorVisible || !_mouseSurface || !_mouseCurState.w || !_mouseCurState.h) {
_mouseBackup.x = _mouseBackup.y = _mouseBackup.w = _mouseBackup.h = 0;
return;
}