aboutsummaryrefslogtreecommitdiff
path: root/backends/graphics/opengl
diff options
context:
space:
mode:
authorJohannes Schickel2015-12-11 19:54:47 +0100
committerJohannes Schickel2015-12-12 22:31:35 +0100
commitf65a8b26898db3bd870010fc3a0b0b71e50e16b7 (patch)
treef7a0e9dc621d51dadb3550d15e36fa5feb92124d /backends/graphics/opengl
parentfe2ee9ecf5709d49279265f0e5d3b2d0a5688265 (diff)
downloadscummvm-rg350-f65a8b26898db3bd870010fc3a0b0b71e50e16b7.tar.gz
scummvm-rg350-f65a8b26898db3bd870010fc3a0b0b71e50e16b7.tar.bz2
scummvm-rg350-f65a8b26898db3bd870010fc3a0b0b71e50e16b7.zip
OPENGL: Only redraw screen when actual changes happened.
Diffstat (limited to 'backends/graphics/opengl')
-rw-r--r--backends/graphics/opengl/opengl-graphics.cpp35
-rw-r--r--backends/graphics/opengl/opengl-graphics.h9
2 files changed, 42 insertions, 2 deletions
diff --git a/backends/graphics/opengl/opengl-graphics.cpp b/backends/graphics/opengl/opengl-graphics.cpp
index 301813c23f..05e24675fd 100644
--- a/backends/graphics/opengl/opengl-graphics.cpp
+++ b/backends/graphics/opengl/opengl-graphics.cpp
@@ -51,7 +51,8 @@ OpenGLGraphicsManager::OpenGLGraphicsManager()
_overlayVisible(false), _cursor(nullptr),
_cursorX(0), _cursorY(0), _cursorDisplayX(0),_cursorDisplayY(0), _cursorHotspotX(0), _cursorHotspotY(0),
_cursorHotspotXScaled(0), _cursorHotspotYScaled(0), _cursorWidthScaled(0), _cursorHeightScaled(0),
- _cursorKeyColor(0), _cursorVisible(false), _cursorDontScale(false), _cursorPaletteEnabled(false)
+ _cursorKeyColor(0), _cursorVisible(false), _cursorDontScale(false), _cursorPaletteEnabled(false),
+ _forceRedraw(false)
#ifdef USE_OSD
, _osdAlpha(0), _osdFadeStartTime(0), _osd(nullptr)
#endif
@@ -343,7 +344,10 @@ void OpenGLGraphicsManager::fillScreen(uint32 col) {
}
void OpenGLGraphicsManager::setShakePos(int shakeOffset) {
- _gameScreenShakeOffset = shakeOffset;
+ if (_gameScreenShakeOffset != shakeOffset) {
+ _gameScreenShakeOffset = shakeOffset;
+ _forceRedraw = true;
+ }
}
void OpenGLGraphicsManager::updateScreen() {
@@ -351,6 +355,16 @@ void OpenGLGraphicsManager::updateScreen() {
return;
}
+ // We only update the screen when there actually have been any changes.
+ if ( !_forceRedraw
+ && !_gameScreen->isDirty()
+ && !(_overlayVisible && _overlay->isDirty())
+ && !(_cursorVisible && _cursor && _cursor->isDirty())
+ && _osdAlpha == 0) {
+ return;
+ }
+ _forceRedraw = false;
+
// Clear the screen buffer.
GLCALL(glClear(GL_COLOR_BUFFER_BIT));
@@ -467,6 +481,7 @@ int16 OpenGLGraphicsManager::getOverlayHeight() {
void OpenGLGraphicsManager::showOverlay() {
_overlayVisible = true;
+ _forceRedraw = true;
// Update cursor position.
setMousePosition(_cursorX, _cursorY);
@@ -474,6 +489,7 @@ void OpenGLGraphicsManager::showOverlay() {
void OpenGLGraphicsManager::hideOverlay() {
_overlayVisible = false;
+ _forceRedraw = true;
// Update cursor position.
setMousePosition(_cursorX, _cursorY);
@@ -505,6 +521,12 @@ void OpenGLGraphicsManager::grabOverlay(void *buf, int pitch) {
}
bool OpenGLGraphicsManager::showMouse(bool visible) {
+ // In case the mouse cursor visibility changed we need to redraw the whole
+ // screen even when nothing else changed.
+ if (_cursorVisible != visible) {
+ _forceRedraw = true;
+ }
+
bool last = _cursorVisible;
_cursorVisible = visible;
return last;
@@ -940,6 +962,12 @@ void OpenGLGraphicsManager::adjustMousePosition(int16 &x, int16 &y) {
}
void OpenGLGraphicsManager::setMousePosition(int x, int y) {
+ // Whenever the mouse position changed we force a screen redraw to reflect
+ // changes properly.
+ if (_cursorX != x || _cursorY != y) {
+ _forceRedraw = true;
+ }
+
_cursorX = x;
_cursorY = y;
@@ -1100,6 +1128,9 @@ void OpenGLGraphicsManager::recalculateDisplayArea() {
// Update the cursor position to adjust for new display area.
setMousePosition(_cursorX, _cursorY);
+
+ // Force a redraw to assure screen is properly redrawn.
+ _forceRedraw = true;
}
void OpenGLGraphicsManager::updateCursorPalette() {
diff --git a/backends/graphics/opengl/opengl-graphics.h b/backends/graphics/opengl/opengl-graphics.h
index 3634e145ce..e88c3ae243 100644
--- a/backends/graphics/opengl/opengl-graphics.h
+++ b/backends/graphics/opengl/opengl-graphics.h
@@ -469,6 +469,15 @@ private:
*/
byte _cursorPalette[3 * 256];
+ //
+ // Misc
+ //
+
+ /**
+ * Whether the screen contents shall be forced to redrawn.
+ */
+ bool _forceRedraw;
+
/**
* Draws a rectangle
*/