diff options
Diffstat (limited to 'backends/graphics')
-rw-r--r-- | backends/graphics/gph/gph-graphics.cpp | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/backends/graphics/gph/gph-graphics.cpp b/backends/graphics/gph/gph-graphics.cpp index 1a81cf142c..cc8ef38f98 100644 --- a/backends/graphics/gph/gph-graphics.cpp +++ b/backends/graphics/gph/gph-graphics.cpp @@ -167,6 +167,7 @@ void GPHGraphicsManager::drawMouse() { // scaling, shake position and aspect ratio correction manually. if (!_overlayVisible) { + dst.x += _currentShakeXOffset; dst.y += _currentShakeYOffset; } @@ -219,6 +220,19 @@ void GPHGraphicsManager::internUpdateScreen() { #endif // If the shake position changed, fill the dirty area with blackness + if (_currentShakeXOffset != _gameScreenShakeXOffset || + (_cursorNeedsRedraw && _mouseBackup.x <= _currentShakeXOffset)) { + SDL_Rect blackrect = {0, 0, (Uint16)(_gameScreenShakeXOffset * _videoMode.scaleFactor), (Uint16)(_videoMode.screenHeight * _videoMode.scaleFactor)}; + + if (_videoMode.aspectRatioCorrection && !_overlayVisible) + blackrect.h = real2Aspect(blackrect.h - 1) + 1; + + SDL_FillRect(_hwScreen, &blackrect, 0); + + _currentShakeXOffset = _gameScreenShakeXOffset; + + _forceRedraw = true; + } if (_currentShakeYOffset != _gameScreenShakeYOffset || (_cursorNeedsRedraw && _mouseBackup.y <= _currentShakeYOffset)) { SDL_Rect blackrect = {0, 0, (Uint16)(_videoMode.screenWidth * _videoMode.scaleFactor), (Uint16)(_gameScreenShakeYOffset * _videoMode.scaleFactor)}; @@ -308,13 +322,17 @@ void GPHGraphicsManager::internUpdateScreen() { for (r = _dirtyRectList; r != lastRect; ++r) { int dst_y = r->y + _currentShakeYOffset; int dst_h = 0; - int dst_w = r->w; + int dst_w = 0; int orig_dst_y = 0; - int dst_x = r->x; + int dst_x = r->x + _currentShakeXOffset; int src_y; int src_x; - if (dst_y < height) { + if (dst_x < width && dst_y < height) { + dst_w = r->w; + if (dst_w > width - dst_x) + dst_w = width - dst_x; + dst_h = r->h; if (dst_h > height - dst_y) dst_h = height - dst_y; @@ -346,15 +364,15 @@ void GPHGraphicsManager::internUpdateScreen() { (byte *)_hwScreen->pixels + dst_x * 2 + dst_y * dstPitch, dstPitch, dst_w, dst_h); } else { scalerProc((byte *)srcSurf->pixels + (r->x * 2 + 2) + (r->y + 1) * srcPitch, srcPitch, - (byte *)_hwScreen->pixels + r->x * 2 + dst_y * dstPitch, dstPitch, r->w, dst_h); + (byte *)_hwScreen->pixels + dst_x * 2 + dst_y * dstPitch, dstPitch, dst_w, dst_h); } } if (_videoMode.mode == GFX_HALF && scalerProc == DownscaleAllByHalf) { - r->w = r->w / 2; + r->w = dst_w / 2; r->h = dst_h / 2; } else { - r->w = r->w; + r->w = dst_w; r->h = dst_h; } @@ -373,7 +391,9 @@ void GPHGraphicsManager::internUpdateScreen() { // Readjust the dirty rect list in case we are doing a full update. // This is necessary if shaking is active. if (_forceRedraw) { + _dirtyRectList[0].x = 0; _dirtyRectList[0].y = 0; + _dirtyRectList[0].w = (_videoMode.mode == GFX_HALF) ? _videoMode.hardwareWidth / 2 : _videoMode.hardwareWidth; _dirtyRectList[0].h = (_videoMode.mode == GFX_HALF) ? _videoMode.hardwareHeight / 2 : _videoMode.hardwareHeight; } |