[Scummvm-cvs-logs] SF.net SVN: scummvm:[49594] scummvm/trunk

anguslees at users.sourceforge.net anguslees at users.sourceforge.net
Fri Jun 11 12:54:50 CEST 2010


Revision: 49594
          http://scummvm.svn.sourceforge.net/scummvm/?rev=49594&view=rev
Author:   anguslees
Date:     2010-06-11 10:54:49 +0000 (Fri, 11 Jun 2010)

Log Message:
-----------
Add support for setFocusRectangle - enabled on 'small' Android screens.

Modified Paths:
--------------
    scummvm/trunk/backends/platform/android/android.cpp
    scummvm/trunk/backends/platform/android/org/inodes/gus/scummvm/ScummVM.java
    scummvm/trunk/backends/platform/android/org/inodes/gus/scummvm/ScummVMActivity.java
    scummvm/trunk/dists/android/AndroidManifest.xml
    scummvm/trunk/dists/android/AndroidManifest.xml.in

Property Changed:
----------------
    scummvm/trunk/dists/android/AndroidManifest.xml
    scummvm/trunk/dists/android/AndroidManifest.xml.in

Modified: scummvm/trunk/backends/platform/android/android.cpp
===================================================================
--- scummvm/trunk/backends/platform/android/android.cpp	2010-06-11 10:44:32 UTC (rev 49593)
+++ scummvm/trunk/backends/platform/android/android.cpp	2010-06-11 10:54:49 UTC (rev 49594)
@@ -178,8 +178,8 @@
 	// Game layer
 	GLESPaletteTexture* _game_texture;
 	int _shake_offset;
+	Common::Rect _focus_rect;
 	bool _full_screen_dirty;
-	Common::Array<Common::Rect> _dirty_rects;
 
 	// Overlay layer
 	GLES4444Texture* _overlay_texture;
@@ -199,6 +199,7 @@
 	pthread_t _timer_thread;
 	static void* timerThreadFunc(void* arg);
 
+	bool _enable_zoning;
 	bool _virtkeybd_on;
 
 	Common::SaveFileManager *_savefile;
@@ -221,6 +222,7 @@
 	static OSystem_Android* fromJavaObject(JNIEnv* env, jobject obj);
 	virtual void initBackend();
 	void addPluginDirectories(Common::FSList &dirs) const;
+	void enableZoning(bool enable) { _enable_zoning = enable; }
 
 	virtual bool hasFeature(Feature f);
 	virtual void setFeatureState(Feature f, bool enable);
@@ -311,6 +313,7 @@
 	  _use_mouse_palette(false),
 	  _show_mouse(false),
 	  _show_overlay(false),
+	  _enable_zoning(false),
 	  _savefile(0),
 	  _mixer(0),
 	  _timer(0),
@@ -649,16 +652,15 @@
 		_mouse_texture->reinitGL();
 
 	glViewport(0, 0, _egl_surface_width, _egl_surface_height);
+
 	glMatrixMode(GL_PROJECTION);
 	glLoadIdentity();
 	glOrthof(0, _egl_surface_width, _egl_surface_height, 0, -1, 1);
-
 	glMatrixMode(GL_MODELVIEW);
 	glLoadIdentity();
 
+	clearFocusRectangle();
 	CHECK_GL_ERROR();
-
-	_force_redraw = true;
 }
 
 void OSystem_Android::destroyScummVMSurface() {
@@ -680,7 +682,7 @@
 	_overlay_texture->allocBuffer(overlay_width, overlay_height);
 
 	// Don't know mouse size yet - it gets reallocated in
-	// setMouseCursor.	We need the palette allocated before
+	// setMouseCursor.  We need the palette allocated before
 	// setMouseCursor however, so just take a guess at the desired
 	// size (it's small).
 	_mouse_texture->allocBuffer(20, 20);
@@ -695,7 +697,7 @@
 }
 
 void OSystem_Android::setPalette(const byte* colors, uint start, uint num) {
-		ENTER("setPalette(%p, %u, %u)", colors, start, num);
+	ENTER("setPalette(%p, %u, %u)", colors, start, num);
 
 	if (!_use_mouse_palette)
 		_setCursorPalette(colors, start, num);
@@ -753,15 +755,39 @@
 		glTranslatex(0, -_shake_offset << 16, 0);
 	}
 
-	_game_texture->drawTexture(0, 0,
-				   _egl_surface_width, _egl_surface_height);
+	if (_focus_rect.isEmpty()) {
+		_game_texture->drawTexture(0, 0,
+								   _egl_surface_width, _egl_surface_height);
+	} else {
+		// Need to ensure any exposed out-of-bounds region doesn't go
+		// all hall-of-mirrors.  If _shake_offset != 0, we've already
+		// done this above.
+		const Common::Rect
+			screen_bounds(_game_texture->width(), _game_texture->height());
+		if (!screen_bounds.contains(_focus_rect) && _shake_offset != 0) {
+			glClearColorx(0, 0, 0, 1 << 16);
+			glClear(GL_COLOR_BUFFER_BIT);
+		}
 
+		glPushMatrix();
+		glScalex(xdiv(_egl_surface_width, _focus_rect.width()),
+				 xdiv(_egl_surface_height, _focus_rect.height()),
+				 1 << 16);
+		glTranslatex(-_focus_rect.left << 16, -_focus_rect.top << 16, 0);
+		glScalex(xdiv(_game_texture->width(), _egl_surface_width),
+				 xdiv(_game_texture->height(), _egl_surface_height),
+				 1 << 16);
+		_game_texture->drawTexture(0, 0,
+								   _egl_surface_width, _egl_surface_height);
+		glPopMatrix();
+	}
+
 	CHECK_GL_ERROR();
 
 	if (_show_overlay) {
 		_overlay_texture->drawTexture(0, 0,
-						  _egl_surface_width,
-						  _egl_surface_height);
+									  _egl_surface_width,
+									  _egl_surface_height);
 		CHECK_GL_ERROR();
 	}
 
@@ -769,8 +795,8 @@
 		glPushMatrix();
 
 		glTranslatex(-_mouse_hotspot.x << 16,
-				 -_mouse_hotspot.y << 16,
-				 0);
+					 -_mouse_hotspot.y << 16,
+					 0);
 
 		// Scale up ScummVM -> OpenGL (pixel) coordinates
 		int texwidth, texheight;
@@ -782,8 +808,8 @@
 			texheight = getHeight();
 		}
 		glScalex(xdiv(_egl_surface_width, texwidth),
-			 xdiv(_egl_surface_height, texheight),
-			 1 << 16);
+				 xdiv(_egl_surface_height, texheight),
+				 1 << 16);
 
 		// Note the extra half texel to position the mouse in
 		// the middle of the x,y square:
@@ -845,26 +871,18 @@
 void OSystem_Android::setFocusRectangle(const Common::Rect& rect) {
 	ENTER("setFocusRectangle(%d,%d,%d,%d)",
 		  rect.left, rect.top, rect.right, rect.bottom);
-#if 0
-	glMatrixMode(GL_PROJECTION);
-	glLoadIdentity();
-	glOrthof(rect.left, rect.right, rect.top, rect.bottom, 0, 1);
-	glMatrixMode(GL_MODELVIEW);
-
-	_force_redraw = true;
-#endif
+	if (_enable_zoning) {
+		_focus_rect = rect;
+		_force_redraw = true;
+	}
 }
 
 void OSystem_Android::clearFocusRectangle() {
 	ENTER("clearFocusRectangle()");
-#if 0
-	glMatrixMode(GL_PROJECTION);
-	glLoadIdentity();
-	glOrthof(0, _egl_surface_width, _egl_surface_height, 0, -1, 1);
-	glMatrixMode(GL_MODELVIEW);
-
-	_force_redraw = true;
-#endif
+	if (_enable_zoning) {
+		_focus_rect = Common::Rect();
+		_force_redraw = true;
+	}
 }
 
 void OSystem_Android::showOverlay() {
@@ -1342,6 +1360,11 @@
 }
 #endif
 
+static void ScummVM_enableZoning(JNIEnv* env, jobject self, jboolean enable) {
+	OSystem_Android* cpp_obj = OSystem_Android::fromJavaObject(env, self);
+	cpp_obj->enableZoning(enable);
+}
+
 const static JNINativeMethod gMethods[] = {
 	{ "create", "(Landroid/content/res/AssetManager;)V",
 	  (void*)ScummVM_create },
@@ -1356,6 +1379,8 @@
 	  (void*)ScummVM_setConfManInt },
 	{ "setConfMan", "(Ljava/lang/String;Ljava/lang/String;)V",
 	  (void*)ScummVM_setConfManString },
+	{ "enableZoning", "(Z)V",
+	  (void*)ScummVM_enableZoning },
 };
 
 JNIEXPORT jint JNICALL

Modified: scummvm/trunk/backends/platform/android/org/inodes/gus/scummvm/ScummVM.java
===================================================================
--- scummvm/trunk/backends/platform/android/org/inodes/gus/scummvm/ScummVM.java	2010-06-11 10:44:32 UTC (rev 49593)
+++ scummvm/trunk/backends/platform/android/org/inodes/gus/scummvm/ScummVM.java	2010-06-11 10:54:49 UTC (rev 49594)
@@ -162,6 +162,7 @@
 	final public native static void loadConfigFile(String path);
 	final public native static void setConfMan(String key, int value);
 	final public native static void setConfMan(String key, String value);
+	final public native void enableZoning(boolean enable);
 
 	// Feed an event to ScummVM.  Safe to call from other threads.
 	final public native void pushEvent(Event e);

Modified: scummvm/trunk/backends/platform/android/org/inodes/gus/scummvm/ScummVMActivity.java
===================================================================
--- scummvm/trunk/backends/platform/android/org/inodes/gus/scummvm/ScummVMActivity.java	2010-06-11 10:44:32 UTC (rev 49593)
+++ scummvm/trunk/backends/platform/android/org/inodes/gus/scummvm/ScummVMActivity.java	2010-06-11 10:54:49 UTC (rev 49594)
@@ -1,7 +1,7 @@
 package org.inodes.gus.scummvm;
 
+import android.app.Activity;
 import android.app.AlertDialog;
-import android.app.Activity;
 import android.content.DialogInterface;
 import android.content.res.Configuration;
 import android.media.AudioManager;
@@ -9,13 +9,14 @@
 import android.os.Environment;
 import android.os.Handler;
 import android.os.Message;
+import android.util.DisplayMetrics;
 import android.util.Log;
-import android.view.inputmethod.InputMethodManager;
 import android.view.KeyEvent;
 import android.view.MotionEvent;
 import android.view.SurfaceView;
 import android.view.View;
 import android.view.ViewConfiguration;
+import android.view.inputmethod.InputMethodManager;
 import android.widget.Toast;
 
 import java.io.IOException;
@@ -33,6 +34,12 @@
 
 		public MyScummVM() {
 			super(ScummVMActivity.this);
+
+			// Enable ScummVM zoning on 'small' screens.
+			// This 'density' term is very confusing.
+			DisplayMetrics metrics = new DisplayMetrics();
+			getWindowManager().getDefaultDisplay().getMetrics(metrics);
+			enableZoning(metrics.densityDpi <= DisplayMetrics.DENSITY_LOW);
 		}
 
 		@Override

Modified: scummvm/trunk/dists/android/AndroidManifest.xml
===================================================================
(Binary files differ)


Property changes on: scummvm/trunk/dists/android/AndroidManifest.xml
___________________________________________________________________
Modified: svn:mime-type
   - application/xml
   + text/xml

Modified: scummvm/trunk/dists/android/AndroidManifest.xml.in
===================================================================
(Binary files differ)


Property changes on: scummvm/trunk/dists/android/AndroidManifest.xml.in
___________________________________________________________________
Modified: svn:mime-type
   - application/xml
   + text/xml


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list