aboutsummaryrefslogtreecommitdiff
path: root/backends/graphics
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
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')
-rw-r--r--backends/graphics/graphics.h2
-rw-r--r--backends/graphics/null/null-graphics.h2
-rw-r--r--backends/graphics/opengl/opengl-graphics.cpp3
-rw-r--r--backends/graphics/surfacesdl/surfacesdl-graphics.cpp19
-rw-r--r--backends/graphics/surfacesdl/surfacesdl-graphics.h3
-rw-r--r--backends/graphics/windowed.h21
6 files changed, 30 insertions, 20 deletions
diff --git a/backends/graphics/graphics.h b/backends/graphics/graphics.h
index e7be2369ed..df4fb6a9e2 100644
--- a/backends/graphics/graphics.h
+++ b/backends/graphics/graphics.h
@@ -81,7 +81,7 @@ public:
virtual void unlockScreen() = 0;
virtual void fillScreen(uint32 col) = 0;
virtual void updateScreen() = 0;
- virtual void setShakePos(int shakeOffset) = 0;
+ virtual void setShakePos(int shakeXOffset, int shakeYOffset) = 0;
virtual void setFocusRectangle(const Common::Rect& rect) = 0;
virtual void clearFocusRectangle() = 0;
diff --git a/backends/graphics/null/null-graphics.h b/backends/graphics/null/null-graphics.h
index 4c628568ff..3972904578 100644
--- a/backends/graphics/null/null-graphics.h
+++ b/backends/graphics/null/null-graphics.h
@@ -63,7 +63,7 @@ public:
void unlockScreen() override {}
void fillScreen(uint32 col) override {}
void updateScreen() override {}
- void setShakePos(int shakeOffset) override {}
+ void setShakePos(int shakeXOffset, int shakeYOffset) override {}
void setFocusRectangle(const Common::Rect& rect) override {}
void clearFocusRectangle() override {}
diff --git a/backends/graphics/opengl/opengl-graphics.cpp b/backends/graphics/opengl/opengl-graphics.cpp
index f40b84c2bf..a01047e268 100644
--- a/backends/graphics/opengl/opengl-graphics.cpp
+++ b/backends/graphics/opengl/opengl-graphics.cpp
@@ -436,7 +436,8 @@ void OpenGLGraphicsManager::initSize(uint width, uint height, const Graphics::Pi
_currentState.gameWidth = width;
_currentState.gameHeight = height;
- _gameScreenShakeOffset = 0;
+ _gameScreenShakeXOffset = 0;
+ _gameScreenShakeYOffset = 0;
}
int16 OpenGLGraphicsManager::getWidth() const {
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;
diff --git a/backends/graphics/windowed.h b/backends/graphics/windowed.h
index 549739d987..7d9198d6b8 100644
--- a/backends/graphics/windowed.h
+++ b/backends/graphics/windowed.h
@@ -44,7 +44,8 @@ public:
_windowWidth(0),
_windowHeight(0),
_overlayVisible(false),
- _gameScreenShakeOffset(0),
+ _gameScreenShakeXOffset(0),
+ _gameScreenShakeYOffset(0),
_forceRedraw(false),
_cursorVisible(false),
_cursorX(0),
@@ -76,9 +77,10 @@ public:
_forceRedraw = true;
}
- virtual void setShakePos(int shakeOffset) override {
- if (_gameScreenShakeOffset != shakeOffset) {
- _gameScreenShakeOffset = shakeOffset;
+ virtual void setShakePos(int shakeXOffset, int shakeYOffset) override {
+ if (_gameScreenShakeXOffset != shakeXOffset || _gameScreenShakeYOffset != shakeYOffset) {
+ _gameScreenShakeXOffset = shakeXOffset;
+ _gameScreenShakeYOffset = shakeYOffset;
recalculateDisplayAreas();
_cursorNeedsRedraw = true;
}
@@ -291,9 +293,14 @@ protected:
bool _overlayVisible;
/**
- * The offset by which the screen is moved vertically.
+ * The offset by which the screen is moved horizontally.
*/
- int _gameScreenShakeOffset;
+ int _gameScreenShakeXOffset;
+
+ /**
+ * The offset by which the screen is moved vertically.
+ */
+ int _gameScreenShakeYOffset;
/**
* The scaled draw rectangle for the game surface within the window.
@@ -400,7 +407,7 @@ private:
}
drawRect.left = ((_windowWidth - width) / 2);
- drawRect.top = ((_windowHeight - height) / 2) + _gameScreenShakeOffset;
+ drawRect.top = ((_windowHeight - height) / 2) + _gameScreenShakeYOffset;
drawRect.setWidth(width);
drawRect.setHeight(height);
}