aboutsummaryrefslogtreecommitdiff
path: root/backends/graphics/surfacesdl
diff options
context:
space:
mode:
authorsluicebox2019-11-15 01:38:21 -0800
committerEugene Sandulenko2019-11-19 00:20:40 +0100
commitb8390fa161c0c324af0e52a4f3a740cca9e9a479 (patch)
treee88f1e7cbb2c35c1b1c3319c9481c4edafca734d /backends/graphics/surfacesdl
parent3238e523ee2ac442c7562830a85b347400b7da88 (diff)
downloadscummvm-rg350-b8390fa161c0c324af0e52a4f3a740cca9e9a479.tar.gz
scummvm-rg350-b8390fa161c0c324af0e52a4f3a740cca9e9a479.tar.bz2
scummvm-rg350-b8390fa161c0c324af0e52a4f3a740cca9e9a479.zip
GRAPHICS: Add interface for horizontal shake
Diffstat (limited to 'backends/graphics/surfacesdl')
-rw-r--r--backends/graphics/surfacesdl/surfacesdl-graphics.cpp19
-rw-r--r--backends/graphics/surfacesdl/surfacesdl-graphics.h3
2 files changed, 12 insertions, 10 deletions
diff --git a/backends/graphics/surfacesdl/surfacesdl-graphics.cpp b/backends/graphics/surfacesdl/surfacesdl-graphics.cpp
index 92540d93f7..95c7ddc918 100644
--- a/backends/graphics/surfacesdl/surfacesdl-graphics.cpp
+++ b/backends/graphics/surfacesdl/surfacesdl-graphics.cpp
@@ -158,7 +158,7 @@ SurfaceSdlGraphicsManager::SurfaceSdlGraphicsManager(SdlEventSource *sdlEventSou
_scalerProc(0), _screenChangeCount(0),
_mouseData(nullptr), _mouseSurface(nullptr),
_mouseOrigSurface(nullptr), _cursorDontScale(false), _cursorPaletteDisabled(true),
- _currentShakePos(0),
+ _currentShakeXOffset(0), _currentShakeYOffset(0),
_paletteDirtyStart(0), _paletteDirtyEnd(0),
_screenIsLocked(false),
_graphicsMutex(0),
@@ -822,7 +822,8 @@ int SurfaceSdlGraphicsManager::getStretchMode() const {
void SurfaceSdlGraphicsManager::initSize(uint w, uint h, const Graphics::PixelFormat *format) {
assert(_transactionMode == kTransactionActive);
- _gameScreenShakeOffset = 0;
+ _gameScreenShakeXOffset = 0;
+ _gameScreenShakeYOffset = 0;
#ifdef USE_RGB_COLOR
//avoid redundant format changes
@@ -1206,16 +1207,16 @@ void SurfaceSdlGraphicsManager::internUpdateScreen() {
// If the shake position changed, fill the dirty area with blackness
// When building with SDL2, the shake offset is added to the active rect instead,
// so this isn't needed there.
- if (_currentShakePos != _gameScreenShakeOffset ||
- (_cursorNeedsRedraw && _mouseBackup.y <= _currentShakePos)) {
- SDL_Rect blackrect = {0, 0, (Uint16)(_videoMode.screenWidth * _videoMode.scaleFactor), (Uint16)(_gameScreenShakeOffset * _videoMode.scaleFactor)};
+ if (_currentShakeYOffset != _gameScreenShakeYOffset ||
+ (_cursorNeedsRedraw && _mouseBackup.y <= _currentShakeYOffset)) {
+ SDL_Rect blackrect = {0, 0, (Uint16)(_videoMode.screenWidth * _videoMode.scaleFactor), (Uint16)(_gameScreenShakeYOffset * _videoMode.scaleFactor)};
if (_videoMode.aspectRatioCorrection && !_overlayVisible)
blackrect.h = real2Aspect(blackrect.h - 1) + 1;
SDL_FillRect(_hwScreen, &blackrect, 0);
- _currentShakePos = _gameScreenShakeOffset;
+ _currentShakeYOffset = _gameScreenShakeYOffset;
_forceRedraw = true;
}
@@ -1293,7 +1294,7 @@ void SurfaceSdlGraphicsManager::internUpdateScreen() {
dstPitch = _hwScreen->pitch;
for (r = _dirtyRectList; r != lastRect; ++r) {
- int dst_y = r->y + _currentShakePos;
+ int dst_y = r->y + _currentShakeYOffset;
int dst_h = 0;
#ifdef USE_SCALERS
int orig_dst_y = 0;
@@ -1349,7 +1350,7 @@ void SurfaceSdlGraphicsManager::internUpdateScreen() {
// Of course when the overlay is visible we do not show it, since it is only for game
// specific focus.
if (_enableFocusRect && !_overlayVisible) {
- int y = _focusRect.top + _currentShakePos;
+ int y = _focusRect.top + _currentShakeYOffset;
int h = 0;
int x = _focusRect.left * scale1;
int w = _focusRect.width() * scale1;
@@ -2276,7 +2277,7 @@ void SurfaceSdlGraphicsManager::drawMouse() {
// We draw the pre-scaled cursor image, so now we need to adjust for
// scaling, shake position and aspect ratio correction manually.
- dst.y += _currentShakePos;
+ dst.y += _currentShakeYOffset;
if (_videoMode.aspectRatioCorrection && !_overlayVisible)
dst.y = real2Aspect(dst.y);
diff --git a/backends/graphics/surfacesdl/surfacesdl-graphics.h b/backends/graphics/surfacesdl/surfacesdl-graphics.h
index a51aa22e9b..6b8ae36b87 100644
--- a/backends/graphics/surfacesdl/surfacesdl-graphics.h
+++ b/backends/graphics/surfacesdl/surfacesdl-graphics.h
@@ -387,7 +387,8 @@ protected:
// Shake mode
// This is always set to 0 when building with SDL2.
- int _currentShakePos;
+ int _currentShakeXOffset;
+ int _currentShakeYOffset;
// Palette data
SDL_Color *_currentPalette;