aboutsummaryrefslogtreecommitdiff
path: root/backends/graphics/surfacesdl
diff options
context:
space:
mode:
authorCameron Cawley2019-07-27 14:40:50 +0100
committerFilippos Karapetis2019-08-15 02:01:21 +0300
commit1feb86ee97eaaaf326918d4945cdaa0a2f61d33f (patch)
treeee051b4732b9d65bb57940af07e3d4cf91aba7f5 /backends/graphics/surfacesdl
parent0bf74e590d6da396ae10793191fad92f4424ae6d (diff)
downloadscummvm-rg350-1feb86ee97eaaaf326918d4945cdaa0a2f61d33f.tar.gz
scummvm-rg350-1feb86ee97eaaaf326918d4945cdaa0a2f61d33f.tar.bz2
scummvm-rg350-1feb86ee97eaaaf326918d4945cdaa0a2f61d33f.zip
BACKENDS: Handle screen shaking in WindowedGraphicsManager
Diffstat (limited to 'backends/graphics/surfacesdl')
-rw-r--r--backends/graphics/surfacesdl/surfacesdl-graphics.cpp20
-rw-r--r--backends/graphics/surfacesdl/surfacesdl-graphics.h3
2 files changed, 10 insertions, 13 deletions
diff --git a/backends/graphics/surfacesdl/surfacesdl-graphics.cpp b/backends/graphics/surfacesdl/surfacesdl-graphics.cpp
index f71aa20865..bd430e8171 100644
--- a/backends/graphics/surfacesdl/surfacesdl-graphics.cpp
+++ b/backends/graphics/surfacesdl/surfacesdl-graphics.cpp
@@ -155,7 +155,7 @@ SurfaceSdlGraphicsManager::SurfaceSdlGraphicsManager(SdlEventSource *sdlEventSou
_scalerProc(0), _screenChangeCount(0),
_mouseData(nullptr), _mouseSurface(nullptr),
_mouseOrigSurface(nullptr), _cursorDontScale(false), _cursorPaletteDisabled(true),
- _currentShakePos(0), _newShakePos(0),
+ _currentShakePos(0),
_paletteDirtyStart(0), _paletteDirtyEnd(0),
_screenIsLocked(false),
_graphicsMutex(0),
@@ -825,7 +825,7 @@ int SurfaceSdlGraphicsManager::getStretchMode() const {
void SurfaceSdlGraphicsManager::initSize(uint w, uint h, const Graphics::PixelFormat *format) {
assert(_transactionMode == kTransactionActive);
- _newShakePos = 0;
+ _gameScreenShakeOffset = 0;
#ifdef USE_RGB_COLOR
//avoid redundant format changes
@@ -1205,20 +1205,24 @@ void SurfaceSdlGraphicsManager::internUpdateScreen() {
ScalerProc *scalerProc;
int scale1;
+#if !SDL_VERSION_ATLEAST(2, 0, 0)
// If the shake position changed, fill the dirty area with blackness
- if (_currentShakePos != _newShakePos ||
+ // 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)(_newShakePos * _videoMode.scaleFactor)};
+ SDL_Rect blackrect = {0, 0, (Uint16)(_videoMode.screenWidth * _videoMode.scaleFactor), (Uint16)(_gameScreenShakeOffset * _videoMode.scaleFactor)};
if (_videoMode.aspectRatioCorrection && !_overlayVisible)
blackrect.h = real2Aspect(blackrect.h - 1) + 1;
SDL_FillRect(_hwScreen, &blackrect, 0);
- _currentShakePos = _newShakePos;
+ _currentShakePos = _gameScreenShakeOffset;
_forceRedraw = true;
}
+#endif
// Check whether the palette was changed in the meantime and update the
// screen surface accordingly.
@@ -1754,12 +1758,6 @@ void SurfaceSdlGraphicsManager::setCursorPalette(const byte *colors, uint start,
blitCursor();
}
-void SurfaceSdlGraphicsManager::setShakePos(int shake_pos) {
- assert(_transactionMode == kTransactionNone);
-
- _newShakePos = shake_pos;
-}
-
void SurfaceSdlGraphicsManager::setFocusRectangle(const Common::Rect &rect) {
#ifdef USE_SDL_DEBUG_FOCUSRECT
// Only enable focus rectangle debug code, when the user wants it
diff --git a/backends/graphics/surfacesdl/surfacesdl-graphics.h b/backends/graphics/surfacesdl/surfacesdl-graphics.h
index 10054605a7..3bf0dd516f 100644
--- a/backends/graphics/surfacesdl/surfacesdl-graphics.h
+++ b/backends/graphics/surfacesdl/surfacesdl-graphics.h
@@ -126,7 +126,6 @@ public:
virtual void unlockScreen() override;
virtual void fillScreen(uint32 col) override;
virtual void updateScreen() override;
- virtual void setShakePos(int shakeOffset) override;
virtual void setFocusRectangle(const Common::Rect& rect) override;
virtual void clearFocusRectangle() override;
@@ -348,8 +347,8 @@ protected:
};
// Shake mode
+ // This is always set to 0 when building with SDL2.
int _currentShakePos;
- int _newShakePos;
// Palette data
SDL_Color *_currentPalette;