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.
This commit is contained in:
parent
da0a8db704
commit
5d8cf6ba42
2 changed files with 25 additions and 18 deletions
|
@ -567,6 +567,18 @@ void applyColorKey(DstPixel *dst, const SrcPixel *src, uint w, uint h, uint dstP
|
||||||
} // End of anonymous namespace
|
} // 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) {
|
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;
|
Graphics::PixelFormat inputFormat;
|
||||||
#ifdef USE_RGB_COLOR
|
#ifdef USE_RGB_COLOR
|
||||||
if (format) {
|
if (format) {
|
||||||
|
@ -602,11 +614,6 @@ void OpenGLGraphicsManager::setMouseCursor(const void *buf, uint w, uint h, int
|
||||||
_cursor->enableLinearFiltering(_currentState.filtering);
|
_cursor->enableLinearFiltering(_currentState.filtering);
|
||||||
}
|
}
|
||||||
|
|
||||||
_cursorKeyColor = keycolor;
|
|
||||||
_cursorHotspotX = hotspotX;
|
|
||||||
_cursorHotspotY = hotspotY;
|
|
||||||
_cursorDontScale = dontScale;
|
|
||||||
|
|
||||||
_cursor->allocate(w, h);
|
_cursor->allocate(w, h);
|
||||||
if (inputFormat.bytesPerPixel == 1) {
|
if (inputFormat.bytesPerPixel == 1) {
|
||||||
// For CLUT8 cursors we can simply copy the input data into the
|
// For CLUT8 cursors we can simply copy the input data into the
|
||||||
|
|
|
@ -1876,9 +1876,6 @@ void SurfaceSdlGraphicsManager::setMouseCursor(const void *buf, uint w, uint h,
|
||||||
assert(keycolor <= 0xFF);
|
assert(keycolor <= 0xFF);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (w == 0 || h == 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
_mouseCurState.hotX = hotspot_x;
|
_mouseCurState.hotX = hotspot_x;
|
||||||
_mouseCurState.hotY = hotspot_y;
|
_mouseCurState.hotY = hotspot_y;
|
||||||
|
|
||||||
|
@ -1890,6 +1887,10 @@ void SurfaceSdlGraphicsManager::setMouseCursor(const void *buf, uint w, uint h,
|
||||||
_mouseCurState.w = w;
|
_mouseCurState.w = w;
|
||||||
_mouseCurState.h = h;
|
_mouseCurState.h = h;
|
||||||
|
|
||||||
|
if (!w || !h) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (_mouseOrigSurface)
|
if (_mouseOrigSurface)
|
||||||
SDL_FreeSurface(_mouseOrigSurface);
|
SDL_FreeSurface(_mouseOrigSurface);
|
||||||
|
|
||||||
|
@ -1928,22 +1929,21 @@ void SurfaceSdlGraphicsManager::blitCursor() {
|
||||||
#else
|
#else
|
||||||
byte color;
|
byte color;
|
||||||
#endif
|
#endif
|
||||||
int w, h, i, j;
|
|
||||||
|
|
||||||
if (!_mouseOrigSurface || !_mouseData)
|
int w = _mouseCurState.w;
|
||||||
|
int h = _mouseCurState.h;
|
||||||
|
|
||||||
|
if (!_mouseOrigSurface || !_mouseData || !w || !h)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_cursorNeedsRedraw = true;
|
_cursorNeedsRedraw = true;
|
||||||
|
|
||||||
w = _mouseCurState.w;
|
|
||||||
h = _mouseCurState.h;
|
|
||||||
|
|
||||||
SDL_LockSurface(_mouseOrigSurface);
|
SDL_LockSurface(_mouseOrigSurface);
|
||||||
|
|
||||||
// Make whole surface transparent
|
// 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;
|
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;
|
*(uint16 *)dstPtr = kMouseColorKey;
|
||||||
dstPtr += 2;
|
dstPtr += 2;
|
||||||
}
|
}
|
||||||
|
@ -1959,8 +1959,8 @@ void SurfaceSdlGraphicsManager::blitCursor() {
|
||||||
else
|
else
|
||||||
palette = _cursorPalette;
|
palette = _cursorPalette;
|
||||||
|
|
||||||
for (i = 0; i < h; i++) {
|
for (int i = 0; i < h; i++) {
|
||||||
for (j = 0; j < w; j++) {
|
for (int j = 0; j < w; j++) {
|
||||||
#ifdef USE_RGB_COLOR
|
#ifdef USE_RGB_COLOR
|
||||||
if (_cursorFormat.bytesPerPixel > 1) {
|
if (_cursorFormat.bytesPerPixel > 1) {
|
||||||
if (_cursorFormat.bytesPerPixel == 2)
|
if (_cursorFormat.bytesPerPixel == 2)
|
||||||
|
@ -2112,7 +2112,7 @@ void SurfaceSdlGraphicsManager::undrawMouse() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SurfaceSdlGraphicsManager::drawMouse() {
|
void SurfaceSdlGraphicsManager::drawMouse() {
|
||||||
if (!_cursorVisible || !_mouseSurface) {
|
if (!_cursorVisible || !_mouseSurface || !_mouseCurState.w || !_mouseCurState.h) {
|
||||||
_mouseBackup.x = _mouseBackup.y = _mouseBackup.w = _mouseBackup.h = 0;
|
_mouseBackup.x = _mouseBackup.y = _mouseBackup.w = _mouseBackup.h = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue