[Scummvm-cvs-logs] scummvm master -> 758aa78acc129c78942246df0e6425f03f2fa968

lordhoto lordhoto at gmail.com
Thu Mar 17 19:56:49 CET 2011


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

Summary:
96979f73fc OPENGL: Slight refactoring.
758aa78acc OPENGL: Get rid of _aspectRatioCorrection.


Commit: 96979f73fc10679fc0112cfbc55d6b661d744b05
    https://github.com/scummvm/scummvm/commit/96979f73fc10679fc0112cfbc55d6b661d744b05
Author: Johannes Schickel (lordhoto at scummvm.org)
Date: 2011-03-17T11:55:06-07:00

Commit Message:
OPENGL: Slight refactoring.

First step into making all state variables of the OpenGL backend private, to
help making the backend more maintainable, by disallowing subclasses to just
mess with everything...

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



diff --git a/backends/graphics/opengl/opengl-graphics.cpp b/backends/graphics/opengl/opengl-graphics.cpp
index e9942b8..5d23405 100644
--- a/backends/graphics/opengl/opengl-graphics.cpp
+++ b/backends/graphics/opengl/opengl-graphics.cpp
@@ -100,7 +100,12 @@ bool OpenGLGraphicsManager::hasFeature(OSystem::Feature f) {
 void OpenGLGraphicsManager::setFeatureState(OSystem::Feature f, bool enable) {
 	switch (f) {
 	case OSystem::kFeatureAspectRatioCorrection:
-		_videoMode.mode = OpenGL::GFX_4_3;
+		// TODO: If we enable aspect ratio correction, we automatically set
+		// the video mode to 4/3. That is quity messy, but since we have that
+		// messy OpenGL mode use there's not much to do about it right now...
+		// Think of a way to get rid of this mess.
+		if (enable)
+			_videoMode.mode = OpenGL::GFX_4_3;
 		_aspectRatioCorrection = enable;
 		break;
 	default:
@@ -109,7 +114,12 @@ void OpenGLGraphicsManager::setFeatureState(OSystem::Feature f, bool enable) {
 }
 
 bool OpenGLGraphicsManager::getFeatureState(OSystem::Feature f) {
-	return false;
+	switch (f) {
+	case OSystem::kFeatureAspectRatioCorrection:
+		return _aspectRatioCorrection || (_videoMode.mode == OpenGL::GFX_4_3);
+	default:
+		return false;
+	}
 }
 
 //
@@ -1216,6 +1226,13 @@ void OpenGLGraphicsManager::setScale(int newScale) {
 	_transactionDetails.sizeChanged = true;
 }
 
+void OpenGLGraphicsManager::toggleAntialiasing() {
+	assert(_transactionMode == kTransactionActive);
+
+	_videoMode.antialiasing = !_videoMode.antialiasing;
+	_transactionDetails.filterChanged = true;
+}
+
 uint OpenGLGraphicsManager::getAspectRatio() {
 	if (_videoMode.mode == OpenGL::GFX_NORMAL)
 		return _videoMode.hardwareWidth * 10000 / _videoMode.hardwareHeight;
diff --git a/backends/graphics/opengl/opengl-graphics.h b/backends/graphics/opengl/opengl-graphics.h
index baebb9c..3eeb52f 100644
--- a/backends/graphics/opengl/opengl-graphics.h
+++ b/backends/graphics/opengl/opengl-graphics.h
@@ -178,6 +178,23 @@ protected:
 
 	virtual void setScale(int newScale);
 
+	/**
+	 * Query the scale factor.
+	 */
+	inline int getScale() const { return _videoMode.scaleFactor; }
+
+	/**
+	 * Toggle the antialiasing state of the current video mode.
+	 *
+	 * This can only be used in a GFX transaction.
+	 */
+	void toggleAntialiasing();
+
+	/**
+	 * Query the antialiasing state.
+	 */
+	inline bool getAntialiasingState() const { return _videoMode.antialiasing; }
+
 	// Drawing coordinates for the current display mode and scale
 	int _displayX;
 	int _displayY;
@@ -195,13 +212,13 @@ protected:
 	virtual void calculateDisplaySize(int &width, int &height);
 	virtual void refreshDisplaySize();
 
-	bool _aspectRatioCorrection;
-
 	/**
 	 * Returns the current target aspect ratio x 10000
 	 */
 	virtual uint getAspectRatio();
 
+	bool _aspectRatioCorrection;
+
 	bool _formatBGR;
 
 	//
@@ -232,7 +249,7 @@ protected:
 	bool _overlayVisible;
 	bool _overlayNeedsRedraw;
 	Common::Rect _overlayDirtyRect;
-	
+
 	virtual void refreshOverlay();
 
 	//
diff --git a/backends/graphics/openglsdl/openglsdl-graphics.cpp b/backends/graphics/openglsdl/openglsdl-graphics.cpp
index c2ec43b..bdea64b 100644
--- a/backends/graphics/openglsdl/openglsdl-graphics.cpp
+++ b/backends/graphics/openglsdl/openglsdl-graphics.cpp
@@ -298,7 +298,7 @@ bool OpenGLSdlGraphicsManager::setupFullscreenMode() {
 
 bool OpenGLSdlGraphicsManager::loadGFXMode() {
 	// Force 4/3 if feature enabled
-	if (_aspectRatioCorrection)
+	if (getFeatureState(OSystem::kFeatureAspectRatioCorrection))
 		_videoMode.mode = OpenGL::GFX_4_3;
 
 	// If the screen was resized, do not change its size
@@ -522,11 +522,14 @@ bool OpenGLSdlGraphicsManager::notifyEvent(const Common::Event &event) {
 			// Ctrl-Alt-f toggles antialiasing
 			if (event.kbd.keycode == 'f') {
 				beginGFXTransaction();
-					_videoMode.antialiasing = !_videoMode.antialiasing;
-					_transactionDetails.filterChanged = true;
+					toggleAntialiasing();
 				endGFXTransaction();
+
 #ifdef USE_OSD
-				if (_videoMode.antialiasing)
+				// TODO: This makes guesses about what internal antialiasing
+				// modes we use, we might want to consider a better way of
+				// displaying information to the user.
+				if (getAntialiasingState())
 					displayMessageOnOSD("Active filter mode: Linear");
 				else
 					displayMessageOnOSD("Active filter mode: Nearest");
@@ -568,10 +571,16 @@ bool OpenGLSdlGraphicsManager::notifyEvent(const Common::Event &event) {
 #ifdef USE_OSD
 					int lastMode = _videoMode.mode;
 #endif
+					// We need to query the scale and set it up, because
+					// setGraphicsMode sets the default scale to 2
+					int oldScale = getScale();
 					beginGFXTransaction();
-						_videoMode.mode = sdlKey - (isNormalNumber ? SDLK_1 : SDLK_KP1);
-						_transactionDetails.needRefresh = true;
-						_aspectRatioCorrection = false;
+						setGraphicsMode(sdlKey - (isNormalNumber ? SDLK_1 : SDLK_KP1));
+						setScale(oldScale);
+						// TODO: We disable the aspect ratio correction here,
+						// we might switch to mode which ignores it...
+						// We should really fix this mess up.
+						setFeatureState(OSystem::kFeatureAspectRatioCorrection, false);
 					endGFXTransaction();
 #ifdef USE_OSD
 					if (lastMode != _videoMode.mode)


Commit: 758aa78acc129c78942246df0e6425f03f2fa968
    https://github.com/scummvm/scummvm/commit/758aa78acc129c78942246df0e6425f03f2fa968
Author: Johannes Schickel (lordhoto at scummvm.org)
Date: 2011-03-17T11:55:06-07:00

Commit Message:
OPENGL: Get rid of _aspectRatioCorrection.

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 5d23405..468c40a 100644
--- a/backends/graphics/opengl/opengl-graphics.cpp
+++ b/backends/graphics/opengl/opengl-graphics.cpp
@@ -53,8 +53,7 @@ OpenGLGraphicsManager::OpenGLGraphicsManager()
 	_cursorVisible(false), _cursorKeyColor(0),
 	_cursorTargetScale(1),
 	_formatBGR(false),
-	_displayX(0), _displayY(0), _displayWidth(0), _displayHeight(0),
-	_aspectRatioCorrection(false) {
+	_displayX(0), _displayY(0), _displayWidth(0), _displayHeight(0) {
 
 	memset(&_oldVideoMode, 0, sizeof(_oldVideoMode));
 	memset(&_videoMode, 0, sizeof(_videoMode));
@@ -103,10 +102,11 @@ void OpenGLGraphicsManager::setFeatureState(OSystem::Feature f, bool enable) {
 		// TODO: If we enable aspect ratio correction, we automatically set
 		// the video mode to 4/3. That is quity messy, but since we have that
 		// messy OpenGL mode use there's not much to do about it right now...
+		// Of course in case we disasble the aspect ratio correction, we
+		// might want to setup a different mode, but which one?
 		// Think of a way to get rid of this mess.
 		if (enable)
 			_videoMode.mode = OpenGL::GFX_4_3;
-		_aspectRatioCorrection = enable;
 		break;
 	default:
 		break;
@@ -116,7 +116,7 @@ void OpenGLGraphicsManager::setFeatureState(OSystem::Feature f, bool enable) {
 bool OpenGLGraphicsManager::getFeatureState(OSystem::Feature f) {
 	switch (f) {
 	case OSystem::kFeatureAspectRatioCorrection:
-		return _aspectRatioCorrection || (_videoMode.mode == OpenGL::GFX_4_3);
+		return _videoMode.mode == OpenGL::GFX_4_3;
 	default:
 		return false;
 	}
@@ -1365,7 +1365,6 @@ void OpenGLGraphicsManager::switchDisplayMode(int mode) {
 			_videoMode.mode = mode;
 
 		_transactionDetails.needRefresh = true;
-		_aspectRatioCorrection = false;
 	}
 }
 
diff --git a/backends/graphics/opengl/opengl-graphics.h b/backends/graphics/opengl/opengl-graphics.h
index 3eeb52f..3518d07 100644
--- a/backends/graphics/opengl/opengl-graphics.h
+++ b/backends/graphics/opengl/opengl-graphics.h
@@ -217,8 +217,6 @@ protected:
 	 */
 	virtual uint getAspectRatio();
 
-	bool _aspectRatioCorrection;
-
 	bool _formatBGR;
 
 	//






More information about the Scummvm-git-logs mailing list