From c102e30e735c52b110e5f31ac0eba90727d6c405 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Tue, 24 Feb 2009 21:43:07 +0000 Subject: SDL: Tweak the way the mouse is drawn/erased, so that it is not erase and drawn again if nothing changed svn-id: r38861 --- backends/platform/sdl/graphics.cpp | 15 +++++++++------ backends/platform/sdl/sdl.cpp | 2 +- backends/platform/sdl/sdl.h | 2 +- 3 files changed, 11 insertions(+), 8 deletions(-) (limited to 'backends/platform') diff --git a/backends/platform/sdl/graphics.cpp b/backends/platform/sdl/graphics.cpp index d498c8f62a..cd8b91a8e2 100644 --- a/backends/platform/sdl/graphics.cpp +++ b/backends/platform/sdl/graphics.cpp @@ -652,6 +652,11 @@ void OSystem_SDL::internUpdateScreen() { scale1 = 1; } + // Add the area covered by the mouse cursor to the list of dirty rects if + // we have to redraw the mouse. + if (_mouseNeedsRedraw) + undrawMouse(); + // Force a full redraw if requested if (_forceFull) { _numDirtyRects = 1; @@ -659,8 +664,7 @@ void OSystem_SDL::internUpdateScreen() { _dirtyRectList[0].y = 0; _dirtyRectList[0].w = width; _dirtyRectList[0].h = height; - } else - undrawMouse(); + } // Only draw anything if necessary if (_numDirtyRects > 0) { @@ -736,14 +740,11 @@ void OSystem_SDL::internUpdateScreen() { #endif // Finally, blit all our changes to the screen SDL_UpdateRects(_hwscreen, _numDirtyRects, _dirtyRectList); - } else { - drawMouse(); - if (_numDirtyRects) - SDL_UpdateRects(_hwscreen, _numDirtyRects, _dirtyRectList); } _numDirtyRects = 0; _forceFull = false; + _mouseNeedsRedraw = false; } bool OSystem_SDL::saveScreenshot(const char *filename) { @@ -1281,6 +1282,7 @@ bool OSystem_SDL::showMouse(bool visible) { void OSystem_SDL::setMousePos(int x, int y) { if (x != _mouseCurState.x || y != _mouseCurState.y) { + _mouseNeedsRedraw = true; _mouseCurState.x = x; _mouseCurState.y = y; } @@ -1313,6 +1315,7 @@ void OSystem_SDL::setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, if (w == 0 || h == 0) return; + _mouseNeedsRedraw = true; _mouseCurState.hotX = hotspot_x; _mouseCurState.hotY = hotspot_y; diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp index 38f7203aa5..d1bf1dfc0b 100644 --- a/backends/platform/sdl/sdl.cpp +++ b/backends/platform/sdl/sdl.cpp @@ -205,7 +205,7 @@ OSystem_SDL::OSystem_SDL() _overlayscreen(0), _tmpscreen2(0), _samplesPerSec(0), _cdrom(0), _scalerProc(0), _modeChanged(false), _screenChangeCount(0), _dirtyChecksums(0), - _mouseVisible(false), _mouseDrawn(false), _mouseData(0), _mouseSurface(0), + _mouseVisible(false), _mouseNeedsRedraw(false), _mouseData(0), _mouseSurface(0), _mouseOrigSurface(0), _cursorTargetScale(1), _cursorPaletteDisabled(true), _joystick(0), _currentShakePos(0), _newShakePos(0), diff --git a/backends/platform/sdl/sdl.h b/backends/platform/sdl/sdl.h index d657a964ba..507e56400d 100644 --- a/backends/platform/sdl/sdl.h +++ b/backends/platform/sdl/sdl.h @@ -341,7 +341,7 @@ protected: // mouse KbdMouse _km; bool _mouseVisible; - bool _mouseDrawn; + bool _mouseNeedsRedraw; byte *_mouseData; SDL_Rect _mouseBackup; MousePos _mouseCurState; -- cgit v1.2.3