[Scummvm-cvs-logs] scummvm master -> f1a4f508afb7552629b8278d3cef8ed23c05998e

lordhoto lordhoto at gmail.com
Fri Feb 24 22:44:17 CET 2012


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

Summary:
f1a4f508af IPHONE: Move aspect ratio settings to VideoContext.


Commit: f1a4f508afb7552629b8278d3cef8ed23c05998e
    https://github.com/scummvm/scummvm/commit/f1a4f508afb7552629b8278d3cef8ed23c05998e
Author: Johannes Schickel (lordhoto at scummvm.org)
Date: 2012-02-24T13:43:02-08:00

Commit Message:
IPHONE: Move aspect ratio settings to VideoContext.

Changed paths:
    backends/platform/iphone/iphone_common.h
    backends/platform/iphone/iphone_video.mm
    backends/platform/iphone/osys_main.cpp



diff --git a/backends/platform/iphone/iphone_common.h b/backends/platform/iphone/iphone_common.h
index 3c0365e..19e4f2c 100644
--- a/backends/platform/iphone/iphone_common.h
+++ b/backends/platform/iphone/iphone_common.h
@@ -58,13 +58,14 @@ enum GraphicsModes {
 };
 
 struct VideoContext {
-	VideoContext() : screenWidth(), screenHeight(), overlayVisible(false),
+	VideoContext() : asprectRatioCorrection(), screenWidth(), screenHeight(), overlayVisible(false),
 	                 overlayWidth(), overlayHeight(), mouseX(), mouseY(),
 	                 mouseHotspotX(), mouseHotspotY(), mouseWidth(), mouseHeight(),
 	                 mouseIsVisible(), graphicsMode(kGraphicsModeLinear), shakeOffsetY() {
 	}
 
 	// Game screen state
+	bool asprectRatioCorrection;
 	uint screenWidth, screenHeight;
 	Graphics::Surface screenTexture;
 
@@ -86,8 +87,6 @@ struct VideoContext {
 };
 
 // On the ObjC side
-void iPhone_setAspectRatioState(bool enable); 
-bool iPhone_getAspectRatioState();
 void iPhone_updateScreen();
 bool iPhone_fetchEvent(int *outEvent, int *outX, int *outY);
 const char *iPhone_getDocumentsDir();
diff --git a/backends/platform/iphone/iphone_video.mm b/backends/platform/iphone/iphone_video.mm
index ecb514d..0ddb90b 100644
--- a/backends/platform/iphone/iphone_video.mm
+++ b/backends/platform/iphone/iphone_video.mm
@@ -41,8 +41,6 @@ static long lastTick = 0;
 static int frames = 0;
 #endif
 
-static bool _aspectRatioCorrect = false;
-
 #define printOpenGLError() printOglError(__FILE__, __LINE__)
 
 int printOglError(const char *file, int line) {
@@ -58,14 +56,6 @@ int printOglError(const char *file, int line) {
 	return retCode;
 }
 
-void iPhone_setAspectRatioState(bool enable) {
-	_aspectRatioCorrect = enable;
-}
-
-bool iPhone_getAspectRatioState() {
-	return _aspectRatioCorrect;
-}
-
 bool iPhone_isHighResDevice() {
 	return _fullHeight > 480;
 }
@@ -488,22 +478,19 @@ const char *iPhone_getDocumentsDir() {
 		[[_keyboardView inputView] removeFromSuperview];
 	}
 
-	float adjustedWidth = _videoContext.screenWidth;
-	float adjustedHeight = _videoContext.screenHeight;
-    if (_aspectRatioCorrect && ((_videoContext.screenWidth == 320 && _videoContext.screenHeight == 200)
-		|| (_videoContext.screenWidth == 640 && _videoContext.screenHeight == 400)) )  {
-		if (_videoContext.screenHeight == 200) {
+	GLfloat adjustedWidth = _videoContext.screenWidth;
+	GLfloat adjustedHeight = _videoContext.screenHeight;
+	if (_videoContext.asprectRatioCorrection) {
+		if (_videoContext.screenWidth == 320 && _videoContext.screenHeight == 200)
 			adjustedHeight = 240;
-		}
-		if (_videoContext.screenHeight == 400) {
+		else if (_videoContext.screenWidth == 640 && _videoContext.screenHeight == 400)
 			adjustedHeight = 480;
-		}
 	}
 	
 	float overlayPortraitRatio;
 
 	if (_orientation == UIDeviceOrientationLandscapeLeft || _orientation ==  UIDeviceOrientationLandscapeRight) {
-		GLfloat gameScreenRatio = (GLfloat)adjustedWidth / (GLfloat)adjustedHeight;
+		GLfloat gameScreenRatio = adjustedWidth / adjustedHeight;
 		GLfloat screenRatio = (GLfloat)screenWidth / (GLfloat)screenHeight;
 
 		// These are the width/height according to the portrait layout!
@@ -532,7 +519,7 @@ const char *iPhone_getDocumentsDir() {
 		_gameScreenRect = CGRectMake(xOffset, yOffset, rectWidth, rectHeight);
 		overlayPortraitRatio = 1.0f;
 	} else {
-		float ratio = (float)adjustedHeight / (float)adjustedWidth;
+		GLfloat ratio = adjustedHeight / adjustedWidth;
 		int height = (int)(screenWidth * ratio);
 		//printf("Making rect (%u, %u)\n", screenWidth, height);
 		_gameScreenRect = CGRectMake(0, 0, screenWidth, height);
diff --git a/backends/platform/iphone/osys_main.cpp b/backends/platform/iphone/osys_main.cpp
index 71404dc..dd34e95 100644
--- a/backends/platform/iphone/osys_main.cpp
+++ b/backends/platform/iphone/osys_main.cpp
@@ -119,7 +119,7 @@ void OSystem_IPHONE::setFeatureState(Feature f, bool enable) {
 		}
 		break;
 	case kFeatureAspectRatioCorrection:
-		iPhone_setAspectRatioState(enable);
+		_videoContext->asprectRatioCorrection = enable;
 		break;
 
 	default:
@@ -132,7 +132,7 @@ bool OSystem_IPHONE::getFeatureState(Feature f) {
 	case kFeatureCursorPalette:
 		return _mouseCursorPaletteEnabled;
 	case kFeatureAspectRatioCorrection:
-		return iPhone_getAspectRatioState();
+		return _videoContext->asprectRatioCorrection;
 
 	default:
 		return false;






More information about the Scummvm-git-logs mailing list