[Scummvm-cvs-logs] scummvm master -> 693834e8c6e9bf01925dc1731dad44d15f880be9

lordhoto lordhoto at gmail.com
Sat Dec 12 22:47:39 CET 2015


This automated email contains information about 4 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
3232050dfc OPENGL: Fix include guard name.
fe2ee9ecf5 OPENGL: Refactor screen refresh handling.
f65a8b2689 OPENGL: Only redraw screen when actual changes happened.
693834e8c6 OPENGL: Implement black borders using scissor test.


Commit: 3232050dfc3283501b33881c762a5e9b188cf985
    https://github.com/scummvm/scummvm/commit/3232050dfc3283501b33881c762a5e9b188cf985
Author: Johannes Schickel (lordhoto at scummvm.org)
Date: 2015-12-12T22:31:35+01:00

Commit Message:
OPENGL: Fix include guard name.

Changed paths:
    backends/graphics/opengl/opengl-sys.h



diff --git a/backends/graphics/opengl/opengl-sys.h b/backends/graphics/opengl/opengl-sys.h
index a3524b2..4e21894 100644
--- a/backends/graphics/opengl/opengl-sys.h
+++ b/backends/graphics/opengl/opengl-sys.h
@@ -20,8 +20,8 @@
  *
  */
 
-#ifndef BACKENDS_GRAPHICS_OPENGL_OPENGL_H
-#define BACKENDS_GRAPHICS_OPENGL_OPENGL_H
+#ifndef BACKENDS_GRAPHICS_OPENGL_OPENGL_SYS_H
+#define BACKENDS_GRAPHICS_OPENGL_OPENGL_SYS_H
 
 // The purpose of this header is to include the OpenGL headers in an uniform
 // fashion. A notable example for a non standard port is the Tizen port.


Commit: fe2ee9ecf5709d49279265f0e5d3b2d0a5688265
    https://github.com/scummvm/scummvm/commit/fe2ee9ecf5709d49279265f0e5d3b2d0a5688265
Author: Johannes Schickel (lordhoto at scummvm.org)
Date: 2015-12-12T22:31:35+01:00

Commit Message:
OPENGL: Refactor screen refresh handling.

Subclasses of OpenGLGraphicsManager are now supposed to supply a refreshScreen
function which handles actual screen updating (for example, buffer swapping).

Changed paths:
    backends/graphics/opengl/opengl-graphics.cpp
    backends/graphics/opengl/opengl-graphics.h
    backends/graphics/openglsdl/openglsdl-graphics.cpp
    backends/graphics/openglsdl/openglsdl-graphics.h
    backends/platform/tizen/graphics.cpp
    backends/platform/tizen/graphics.h



diff --git a/backends/graphics/opengl/opengl-graphics.cpp b/backends/graphics/opengl/opengl-graphics.cpp
index 5821856..301813c 100644
--- a/backends/graphics/opengl/opengl-graphics.cpp
+++ b/backends/graphics/opengl/opengl-graphics.cpp
@@ -431,6 +431,8 @@ void OpenGLGraphicsManager::updateScreen() {
 		GLCALL(glColor4f(1.0f, 1.0f, 1.0f, 1.0f));
 	}
 #endif
+
+	refreshScreen();
 }
 
 Graphics::Surface *OpenGLGraphicsManager::lockScreen() {
diff --git a/backends/graphics/opengl/opengl-graphics.h b/backends/graphics/opengl/opengl-graphics.h
index cec970e..3634e14 100644
--- a/backends/graphics/opengl/opengl-graphics.h
+++ b/backends/graphics/opengl/opengl-graphics.h
@@ -263,6 +263,11 @@ protected:
 	virtual bool loadVideoMode(uint requestedWidth, uint requestedHeight, const Graphics::PixelFormat &format) = 0;
 
 	/**
+	 * Refresh the screen contents.
+	 */
+	virtual void refreshScreen() = 0;
+
+	/**
 	 * Save a screenshot of the full display as BMP to the given file. This
 	 * uses Common::DumpFile for writing the screenshot.
 	 *
diff --git a/backends/graphics/openglsdl/openglsdl-graphics.cpp b/backends/graphics/openglsdl/openglsdl-graphics.cpp
index 4232719..892dfc6 100644
--- a/backends/graphics/openglsdl/openglsdl-graphics.cpp
+++ b/backends/graphics/openglsdl/openglsdl-graphics.cpp
@@ -236,13 +236,6 @@ void OpenGLSdlGraphicsManager::updateScreen() {
 	}
 
 	OpenGLGraphicsManager::updateScreen();
-
-	// Swap OpenGL buffers
-#if SDL_VERSION_ATLEAST(2, 0, 0)
-	SDL_GL_SwapWindow(_window->getSDLWindow());
-#else
-	SDL_GL_SwapBuffers();
-#endif
 }
 
 void OpenGLSdlGraphicsManager::notifyVideoExpose() {
@@ -301,6 +294,15 @@ bool OpenGLSdlGraphicsManager::loadVideoMode(uint requestedWidth, uint requested
 	return setupMode(requestedWidth, requestedHeight);
 }
 
+void OpenGLSdlGraphicsManager::refreshScreen() {
+	// Swap OpenGL buffers
+#if SDL_VERSION_ATLEAST(2, 0, 0)
+	SDL_GL_SwapWindow(_window->getSDLWindow());
+#else
+	SDL_GL_SwapBuffers();
+#endif
+}
+
 bool OpenGLSdlGraphicsManager::setupMode(uint width, uint height) {
 	// In case we request a fullscreen mode we will use the mode the user
 	// has chosen last time or the biggest mode available.
diff --git a/backends/graphics/openglsdl/openglsdl-graphics.h b/backends/graphics/openglsdl/openglsdl-graphics.h
index 845880e..1552593 100644
--- a/backends/graphics/openglsdl/openglsdl-graphics.h
+++ b/backends/graphics/openglsdl/openglsdl-graphics.h
@@ -65,6 +65,8 @@ protected:
 	virtual void setInternalMousePosition(int x, int y);
 
 	virtual bool loadVideoMode(uint requestedWidth, uint requestedHeight, const Graphics::PixelFormat &format);
+
+	virtual void refreshScreen();
 private:
 	bool setupMode(uint width, uint height);
 
diff --git a/backends/platform/tizen/graphics.cpp b/backends/platform/tizen/graphics.cpp
index 9b23e3f..759c4e5 100644
--- a/backends/platform/tizen/graphics.cpp
+++ b/backends/platform/tizen/graphics.cpp
@@ -127,7 +127,6 @@ void TizenGraphicsManager::setReady() {
 void TizenGraphicsManager::updateScreen() {
 	if (!_initState) {
 		OpenGLGraphicsManager::updateScreen();
-		eglSwapBuffers(_eglDisplay, _eglSurface);
 	}
 }
 
@@ -203,3 +202,7 @@ bool TizenGraphicsManager::loadVideoMode(uint requestedWidth, uint requestedHeig
 	// using a fixed output size we do nothing like that here.
 	return true;
 }
+
+void TizenGraphicsManager::refreshScreen() {
+	eglSwapBuffers(_eglDisplay, _eglSurface);
+}
diff --git a/backends/platform/tizen/graphics.h b/backends/platform/tizen/graphics.h
index f1d4498..1522d66 100644
--- a/backends/platform/tizen/graphics.h
+++ b/backends/platform/tizen/graphics.h
@@ -61,6 +61,8 @@ protected:
 
 	bool loadVideoMode(uint requestedWidth, uint requestedHeight, const Graphics::PixelFormat &format);
 
+	void refreshScreen();
+
 	const Graphics::Font *getFontOSD();
 
 private:


Commit: f65a8b26898db3bd870010fc3a0b0b71e50e16b7
    https://github.com/scummvm/scummvm/commit/f65a8b26898db3bd870010fc3a0b0b71e50e16b7
Author: Johannes Schickel (lordhoto at scummvm.org)
Date: 2015-12-12T22:31:35+01:00

Commit Message:
OPENGL: Only redraw screen when actual changes happened.

Changed paths:
    backends/graphics/opengl/opengl-graphics.cpp
    backends/graphics/opengl/opengl-graphics.h



diff --git a/backends/graphics/opengl/opengl-graphics.cpp b/backends/graphics/opengl/opengl-graphics.cpp
index 301813c..05e2467 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 3634e14..e88c3ae 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
 	 */


Commit: 693834e8c6e9bf01925dc1731dad44d15f880be9
    https://github.com/scummvm/scummvm/commit/693834e8c6e9bf01925dc1731dad44d15f880be9
Author: Johannes Schickel (lordhoto at scummvm.org)
Date: 2015-12-12T22:40:20+01:00

Commit Message:
OPENGL: Implement black borders using scissor test.

Changed paths:
    backends/graphics/opengl/opengl-graphics.cpp
    backends/graphics/opengl/opengl-graphics.h



diff --git a/backends/graphics/opengl/opengl-graphics.cpp b/backends/graphics/opengl/opengl-graphics.cpp
index 05e2467..df74e11 100644
--- a/backends/graphics/opengl/opengl-graphics.cpp
+++ b/backends/graphics/opengl/opengl-graphics.cpp
@@ -52,7 +52,7 @@ OpenGLGraphicsManager::OpenGLGraphicsManager()
       _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),
-      _forceRedraw(false)
+      _forceRedraw(false), _scissorOverride(3)
 #ifdef USE_OSD
       , _osdAlpha(0), _osdFadeStartTime(0), _osd(nullptr)
 #endif
@@ -366,7 +366,19 @@ void OpenGLGraphicsManager::updateScreen() {
 	_forceRedraw = false;
 
 	// Clear the screen buffer.
-	GLCALL(glClear(GL_COLOR_BUFFER_BIT));
+	if (_scissorOverride) {
+		// In certain cases we need to assure that the whole screen area is
+		// cleared. For example, when switching from overlay visible to
+		// invisible, we need to assure that all contents are cleared to
+		// properly remove all overlay contents.
+		GLCALL(glDisable(GL_SCISSOR_TEST));
+		GLCALL(glClear(GL_COLOR_BUFFER_BIT));
+		GLCALL(glEnable(GL_SCISSOR_TEST));
+
+		--_scissorOverride;
+	} else {
+		GLCALL(glClear(GL_COLOR_BUFFER_BIT));
+	}
 
 	const GLfloat shakeOffset = _gameScreenShakeOffset * (GLfloat)_displayHeight / _gameScreen->getHeight();
 
@@ -389,37 +401,8 @@ void OpenGLGraphicsManager::updateScreen() {
 		              _cursorWidthScaled, _cursorHeightScaled);
 	}
 
-	// Fourth step: Draw black borders around the game screen when no overlay
-	// is visible. This makes sure that the mouse cursor etc. is only drawn
-	// in the actual game screen area in this case.
-	if (!_overlayVisible) {
-		GLCALL(glColor4f(0.0f, 0.0f, 0.0f, 1.0f));
-
-		GLCALL(glDisable(GL_TEXTURE_2D));
-		GLCALL(glDisableClientState(GL_TEXTURE_COORD_ARRAY));
-
-		// Top border.
-		drawRect(0, 0, _outputScreenWidth, _displayY);
-
-		// Left border.
-		drawRect(0, 0, _displayX, _outputScreenHeight);
-
-		// Bottom border.
-		const int y = _displayY + _displayHeight;
-		drawRect(0, y, _outputScreenWidth, _outputScreenHeight - y);
-
-		// Right border.
-		const int x = _displayX + _displayWidth;
-		drawRect(x, 0, _outputScreenWidth - x, _outputScreenHeight);
-
-		GLCALL(glEnableClientState(GL_TEXTURE_COORD_ARRAY));
-		GLCALL(glEnable(GL_TEXTURE_2D));
-
-		GLCALL(glColor4f(1.0f, 1.0f, 1.0f, 1.0f));
-	}
-
 #ifdef USE_OSD
-	// Fifth step: Draw the OSD.
+	// Fourth step: Draw the OSD.
 	if (_osdAlpha > 0) {
 		Common::StackLock lock(_osdMutex);
 
@@ -483,6 +466,9 @@ void OpenGLGraphicsManager::showOverlay() {
 	_overlayVisible = true;
 	_forceRedraw = true;
 
+	// Allow drawing inside full screen area.
+	GLCALL(glDisable(GL_SCISSOR_TEST));
+
 	// Update cursor position.
 	setMousePosition(_cursorX, _cursorY);
 }
@@ -491,6 +477,10 @@ void OpenGLGraphicsManager::hideOverlay() {
 	_overlayVisible = false;
 	_forceRedraw = true;
 
+	// Limit drawing to screen area.
+	GLCALL(glEnable(GL_SCISSOR_TEST));
+	_scissorOverride = 3;
+
 	// Update cursor position.
 	setMousePosition(_cursorX, _cursorY);
 }
@@ -875,6 +865,16 @@ void OpenGLGraphicsManager::notifyContextCreate(const Graphics::PixelFormat &def
 
 	GLCALL(glEnable(GL_TEXTURE_2D));
 
+	// Setup scissor state accordingly.
+	if (_overlayVisible) {
+		GLCALL(glDisable(GL_SCISSOR_TEST));
+	} else {
+		GLCALL(glEnable(GL_SCISSOR_TEST));
+	}
+	// Clear the whole screen for the first three frames to assure any
+	// leftovers are cleared.
+	_scissorOverride = 3;
+
 	// We use a "pack" alignment (when reading from textures) to 4 here,
 	// since the only place where we really use it is the BMP screenshot
 	// code and that requires the same alignment too.
@@ -1126,6 +1126,16 @@ void OpenGLGraphicsManager::recalculateDisplayArea() {
 	_displayX = (_outputScreenWidth  - _displayWidth ) / 2;
 	_displayY = (_outputScreenHeight - _displayHeight) / 2;
 
+	// Setup drawing limitation for game graphics.
+	// This invovles some trickery because OpenGL's viewport coordinate system
+	// is upside down compared to ours.
+	GLCALL(glScissor(_displayX,
+	                 _outputScreenHeight - _displayHeight - _displayY,
+	                 _displayWidth,
+	                 _displayHeight));
+	// Clear the whole screen for the first three frames to remove leftovers.
+	_scissorOverride = 3;
+
 	// Update the cursor position to adjust for new display area.
 	setMousePosition(_cursorX, _cursorY);
 
@@ -1248,20 +1258,4 @@ void OpenGLGraphicsManager::saveScreenshot(const Common::String &filename) const
 	delete[] pixels;
 }
 
-void OpenGLGraphicsManager::drawRect(GLfloat x, GLfloat y, GLfloat w, GLfloat h) {
-	if (w < 0 || h < 0) {
-		return;
-	}
-
-	const GLfloat vertices[4*2] = {
-		x,     y,
-		x + w, y,
-		x,     y + h,
-		x + w, y + h
-	};
-	GLCALL(glVertexPointer(2, GL_FLOAT, 0, vertices));
-
-	GLCALL(glDrawArrays(GL_TRIANGLE_STRIP, 0, 4));
-}
-
 } // End of namespace OpenGL
diff --git a/backends/graphics/opengl/opengl-graphics.h b/backends/graphics/opengl/opengl-graphics.h
index e88c3ae..9578839 100644
--- a/backends/graphics/opengl/opengl-graphics.h
+++ b/backends/graphics/opengl/opengl-graphics.h
@@ -479,9 +479,9 @@ private:
 	bool _forceRedraw;
 
 	/**
-	 * Draws a rectangle
+	 * Number of frames glClear shall ignore scissor testing.
 	 */
-	void drawRect(GLfloat x, GLfloat y, GLfloat w, GLfloat h);
+	uint _scissorOverride;
 
 #ifdef USE_OSD
 	//






More information about the Scummvm-git-logs mailing list