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

dhewg dhewg at wiibrew.org
Sun Mar 13 23:31:15 CET 2011


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

Summary:
4267011e3a ANDROID: Some texture convinience functions
79d991081d ANDROID: Add support for video feature flags
2dd669d808 ANDROID: Remove leftover TODO
c63c2a9e59 ANDROID: Fix texture clear color
df9167c6b3 ANDROID: Add graphics mode for linear filtering


Commit: 4267011e3a42b3f633f86e3df6af12c456aa0f60
    https://github.com/scummvm/scummvm/commit/4267011e3a42b3f633f86e3df6af12c456aa0f60
Author: dhewg (dhewg at wiibrew.org)
Date: 2011-03-13T15:30:15-07:00

Commit Message:
ANDROID: Some texture convinience functions

Changed paths:
    backends/platform/android/gfx.cpp
    backends/platform/android/texture.cpp
    backends/platform/android/texture.h



diff --git a/backends/platform/android/gfx.cpp b/backends/platform/android/gfx.cpp
index 34981dd..2543ac7 100644
--- a/backends/platform/android/gfx.cpp
+++ b/backends/platform/android/gfx.cpp
@@ -250,6 +250,8 @@ void OSystem_Android::initOverlay() {
 	LOGI("overlay size is %ux%u", overlay_width, overlay_height);
 
 	_overlay_texture->allocBuffer(overlay_width, overlay_height);
+	_overlay_texture->setDrawRect(0, 0,
+									_egl_surface_width, _egl_surface_height);
 }
 
 void OSystem_Android::initSize(uint width, uint height,
@@ -264,6 +266,9 @@ void OSystem_Android::initSize(uint width, uint height,
 	_game_texture->allocBuffer(width, height);
 	_game_texture->fillBuffer(0);
 #endif
+
+	_game_texture->setDrawRect(0, 0, _egl_surface_width, _egl_surface_height);
+
 	// Don't know mouse size yet - it gets reallocated in
 	// setMouseCursor.  We need the palette allocated before
 	// setMouseCursor however, so just take a guess at the desired
@@ -364,8 +369,7 @@ void OSystem_Android::updateScreen() {
 	}
 
 	if (_focus_rect.isEmpty()) {
-		_game_texture->drawTexture(0, 0, _egl_surface_width,
-									_egl_surface_height);
+		_game_texture->drawTextureRect();
 	} else {
 		GLCALL(glPushMatrix());
 		GLCALL(glScalex(xdiv(_egl_surface_width, _focus_rect.width()),
@@ -377,8 +381,7 @@ void OSystem_Android::updateScreen() {
 						xdiv(_game_texture->height(), _egl_surface_height),
 						1 << 16));
 
-		_game_texture->drawTexture(0, 0, _egl_surface_width,
-									_egl_surface_height);
+		_game_texture->drawTextureRect();
 		GLCALL(glPopMatrix());
 	}
 
@@ -388,8 +391,7 @@ void OSystem_Android::updateScreen() {
 		// ugly, but the modern theme sets a wacko factor, only god knows why
 		cs = 1;
 
-		GLCALL(_overlay_texture->drawTexture(0, 0, _egl_surface_width,
-													_egl_surface_height));
+		GLCALL(_overlay_texture->drawTextureRect());
 	}
 
 	if (_show_mouse) {
@@ -422,7 +424,7 @@ void OSystem_Android::updateScreen() {
 
 		GLCALL(glScalex(cs << 16, cs << 16, 1 << 16));
 
-		_mouse_texture->drawTexture();
+		_mouse_texture->drawTextureOrigin();
 
 		GLCALL(glPopMatrix());
 	}
diff --git a/backends/platform/android/texture.cpp b/backends/platform/android/texture.cpp
index c309bd5..499de00 100644
--- a/backends/platform/android/texture.cpp
+++ b/backends/platform/android/texture.cpp
@@ -87,6 +87,7 @@ GLESBaseTexture::GLESBaseTexture(GLenum glFormat, GLenum glType,
 	_surface(),
 	_texture_width(0),
 	_texture_height(0),
+	_draw_rect(),
 	_all_dirty(false),
 	_dirty_rect(),
 	_pixelFormat(pixelFormat),
diff --git a/backends/platform/android/texture.h b/backends/platform/android/texture.h
index e8f2013..5470519 100644
--- a/backends/platform/android/texture.h
+++ b/backends/platform/android/texture.h
@@ -59,8 +59,29 @@ public:
 
 	virtual void drawTexture(GLshort x, GLshort y, GLshort w, GLshort h);
 
-	inline void drawTexture() {
-		drawTexture(0, 0, _surface.w, _surface.h);
+	inline void setDrawRect(const Common::Rect &rect) {
+		_draw_rect = rect;
+	}
+
+	inline void setDrawRect(int16 w, int16 h) {
+		_draw_rect = Common::Rect(w, h);
+	}
+
+	inline void setDrawRect(int16 x1, int16 y1, int16 x2, int16 y2) {
+		_draw_rect = Common::Rect(x1, y1, x2, y2);
+	}
+
+	inline const Common::Rect &getDrawRect() {
+		return _draw_rect;
+	}
+
+	inline void drawTextureRect() {
+		drawTexture(_draw_rect.left, _draw_rect.top,
+					_draw_rect.width(), _draw_rect.height());
+	}
+
+	inline void drawTextureOrigin() {
+			drawTexture(0, 0, _surface.w, _surface.h);
 	}
 
 	inline GLuint width() const {
@@ -136,7 +157,8 @@ protected:
 	GLuint _texture_width;
 	GLuint _texture_height;
 
-	// Covers dirty area
+	Common::Rect _draw_rect;
+
 	bool _all_dirty;
 	Common::Rect _dirty_rect;
 
@@ -160,10 +182,6 @@ public:
 
 	virtual void drawTexture(GLshort x, GLshort y, GLshort w, GLshort h);
 
-	inline void drawTexture() {
-		drawTexture(0, 0, _surface.w, _surface.h);
-	}
-
 protected:
 	byte *_pixels;
 	byte *_buf;
@@ -217,10 +235,6 @@ public:
 
 	virtual void drawTexture(GLshort x, GLshort y, GLshort w, GLshort h);
 
-	inline void drawTexture() {
-		drawTexture(0, 0, _surface.w, _surface.h);
-	}
-
 	virtual const byte *palette_const() const {
 		return _texture;
 	};
@@ -285,10 +299,6 @@ public:
 
 	virtual void drawTexture(GLshort x, GLshort y, GLshort w, GLshort h);
 
-	inline void drawTexture() {
-		drawTexture(0, 0, _surface.w, _surface.h);
-	}
-
 	virtual const byte *palette_const() const {
 		return (byte *)_palette;
 	};


Commit: 79d991081dbeaddd0294c6bbf01675d1ec1fbb72
    https://github.com/scummvm/scummvm/commit/79d991081dbeaddd0294c6bbf01675d1ec1fbb72
Author: dhewg (dhewg at wiibrew.org)
Date: 2011-03-13T15:30:16-07:00

Commit Message:
ANDROID: Add support for video feature flags

kFeatureFullscreenMode and kFeatureAspectRatioCorrection are supported
now. The former prevents scaling to the full display - it scales one
axis and keeps the game AR.

Changed paths:
    backends/platform/android/android.cpp
    backends/platform/android/android.h
    backends/platform/android/gfx.cpp
    backends/platform/android/jni.cpp
    backends/platform/android/jni.h
    backends/platform/android/org/inodes/gus/scummvm/ScummVM.java
    backends/platform/android/org/inodes/gus/scummvm/ScummVMActivity.java



diff --git a/backends/platform/android/android.cpp b/backends/platform/android/android.cpp
index 4391cf5..ba57456 100644
--- a/backends/platform/android/android.cpp
+++ b/backends/platform/android/android.cpp
@@ -115,6 +115,8 @@ OSystem_Android::OSystem_Android(int audio_sample_rate, int audio_buffer_size) :
 	_mouse_hotspot(),
 	_mouse_keycolor(0),
 	_use_mouse_palette(false),
+	_fullscreen(false),
+	_ar_correction(false),
 	_show_mouse(false),
 	_show_overlay(false),
 	_enable_zoning(false),
@@ -302,6 +304,9 @@ void OSystem_Android::initBackend() {
 
 	_main_thread = pthread_self();
 
+	ConfMan.registerDefault("fullscreen", true);
+	ConfMan.registerDefault("aspect_ratio", true);
+
 	ConfMan.setInt("autosave_period", 0);
 	ConfMan.setBool("FM_high_quality", false);
 	ConfMan.setBool("FM_medium_quality", true);
@@ -351,7 +356,9 @@ void OSystem_Android::addPluginDirectories(Common::FSList &dirs) const {
 }
 
 bool OSystem_Android::hasFeature(Feature f) {
-	return (f == kFeatureCursorHasPalette ||
+	return (f == kFeatureFullscreenMode ||
+			f == kFeatureAspectRatioCorrection ||
+			f == kFeatureCursorHasPalette ||
 			f == kFeatureVirtualKeyboard ||
 			f == kFeatureOverlaySupportsAlpha);
 }
@@ -360,6 +367,14 @@ void OSystem_Android::setFeatureState(Feature f, bool enable) {
 	ENTER("%d, %d", f, enable);
 
 	switch (f) {
+	case kFeatureFullscreenMode:
+		_fullscreen = enable;
+		updateScreenRect();
+		break;
+	case kFeatureAspectRatioCorrection:
+		_ar_correction = enable;
+		updateScreenRect();
+		break;
 	case kFeatureVirtualKeyboard:
 		_virtkeybd_on = enable;
 		showVirtualKeyboard(enable);
@@ -490,17 +505,28 @@ bool OSystem_Android::pollEvent(Common::Event &event) {
 		} else {
 			// Touchscreen events need to be converted
 			// from device to game coords first.
-			const GLESBaseTexture *tex;
-			if (_show_overlay)
-				tex = _overlay_texture;
-			else
-				tex = _game_texture;
-
-			event.mouse.x = scalef(event.mouse.x, tex->width(),
-									_egl_surface_width);
-			event.mouse.y = scalef(event.mouse.y, tex->height(),
-									_egl_surface_height);
-			event.mouse.x -= _shake_offset;
+			if (_show_overlay) {
+				event.mouse.x = scalef(event.mouse.x,
+										_overlay_texture->width(),
+										_egl_surface_width);
+				event.mouse.y = scalef(event.mouse.y,
+										_overlay_texture->height(),
+										_egl_surface_height);
+			} else {
+				const Common::Rect &r = _game_texture->getDrawRect();
+
+				event.mouse.x -= r.left;
+				event.mouse.y -= r.top;
+
+				event.mouse.x = scalef(event.mouse.x,
+										_game_texture->width(),
+										r.width());
+				event.mouse.y = scalef(event.mouse.y,
+										_game_texture->height(),
+										r.height());
+
+				event.mouse.x -= _shake_offset;
+			}
 		}
 		break;
 	}
diff --git a/backends/platform/android/android.h b/backends/platform/android/android.h
index 11a24a5..26245e6 100644
--- a/backends/platform/android/android.h
+++ b/backends/platform/android/android.h
@@ -121,6 +121,9 @@ private:
 	bool _show_mouse;
 	bool _use_mouse_palette;
 
+	bool _fullscreen;
+	bool _ar_correction;
+
 	Common::Queue<Common::Event> _event_queue;
 	MutexRef _event_queue_lock;
 
@@ -183,6 +186,8 @@ public:
 
 	virtual void initSize(uint width, uint height,
 							const Graphics::PixelFormat *format);
+	void clearScreen(bool swapBuffers);
+	void updateScreenRect();
 	virtual int getScreenChangeID() const;
 
 	virtual int16 getHeight();
diff --git a/backends/platform/android/gfx.cpp b/backends/platform/android/gfx.cpp
index 2543ac7..2053433 100644
--- a/backends/platform/android/gfx.cpp
+++ b/backends/platform/android/gfx.cpp
@@ -267,7 +267,7 @@ void OSystem_Android::initSize(uint width, uint height,
 	_game_texture->fillBuffer(0);
 #endif
 
-	_game_texture->setDrawRect(0, 0, _egl_surface_width, _egl_surface_height);
+	updateScreenRect();
 
 	// Don't know mouse size yet - it gets reallocated in
 	// setMouseCursor.  We need the palette allocated before
@@ -275,10 +275,54 @@ void OSystem_Android::initSize(uint width, uint height,
 	// size (it's small).
 	_mouse_texture_palette->allocBuffer(20, 20);
 
+	clearScreen(true);
+}
+
+void OSystem_Android::clearScreen(bool swapBuffers) {
 	// clear screen
 	GLCALL(glClearColorx(0, 0, 0, 1 << 16));
 	GLCALL(glClear(GL_COLOR_BUFFER_BIT));
-	JNI::swapBuffers();
+
+	if (swapBuffers)
+		JNI::swapBuffers();
+}
+
+void OSystem_Android::updateScreenRect() {
+	uint16 w = _game_texture->width();
+	uint16 h = _game_texture->height();
+
+	Common::Rect rect(0, 0, _egl_surface_width, _egl_surface_height);
+
+	if (!_fullscreen) {
+		if (_ar_correction && w == 320 && h == 200)
+			h = 240;
+
+		float dpi[2];
+		JNI::getDPI(dpi);
+
+		float screen_ar;
+		if (dpi[0] != 0.0 && dpi[1] != 0.0) {
+			// horizontal orientation
+			screen_ar = (dpi[1] * _egl_surface_width) /
+						(dpi[0] * _egl_surface_height);
+		} else {
+			screen_ar = float(_egl_surface_width) / float(_egl_surface_height);
+		}
+
+		float game_ar = float(w) / float(h);
+
+		if (screen_ar > game_ar) {
+			rect.setWidth(round(_egl_surface_height * game_ar));
+			rect.moveTo((_egl_surface_width - rect.width()) / 2, 0);
+		} else {
+			rect.setHeight(round(_egl_surface_width / game_ar));
+			rect.moveTo((_egl_surface_height - rect.height()) / 2, 0);
+		}
+	}
+
+	glScissor(rect.left, rect.top, rect.width(), rect.height());
+
+	_game_texture->setDrawRect(rect);
 }
 
 int OSystem_Android::getScreenChangeID() const {
@@ -353,6 +397,10 @@ void OSystem_Android::updateScreen() {
 
 	_force_redraw = false;
 
+	// clear pointer leftovers in dead areas
+	if (_show_overlay && !_fullscreen)
+		clearScreen(false);
+
 	GLCALL(glPushMatrix());
 
 	if (_shake_offset != 0 ||
@@ -361,8 +409,7 @@ void OSystem_Android::updateScreen() {
 							_game_texture->height()).contains(_focus_rect))) {
 		// These are the only cases where _game_texture doesn't
 		// cover the entire screen.
-		GLCALL(glClearColorx(0, 0, 0, 1 << 16));
-		GLCALL(glClear(GL_COLOR_BUFFER_BIT));
+		clearScreen(false);
 
 		// Move everything up by _shake_offset (game) pixels
 		GLCALL(glTranslatex(0, -_shake_offset << 16, 0));
@@ -397,28 +444,32 @@ void OSystem_Android::updateScreen() {
 	if (_show_mouse) {
 		GLCALL(glPushMatrix());
 
-		// Scale up ScummVM -> OpenGL (pixel) coordinates
-		int texwidth, texheight;
+		Common::Point mouse = getEventManager()->getMousePos();
 
+		// Scale up ScummVM -> OpenGL (pixel) coordinates
 		if (_show_overlay) {
-			texwidth = getOverlayWidth();
-			texheight = getOverlayHeight();
+			GLCALL(glScalex(xdiv(_egl_surface_width,
+									_overlay_texture->width()),
+							xdiv(_egl_surface_height,
+									_overlay_texture->height()),
+							1 << 16));
 		} else {
-			texwidth = getWidth();
-			texheight = getHeight();
+			const Common::Rect &r = _game_texture->getDrawRect();
+
+			GLCALL(glTranslatex(r.left << 16,
+								r.top << 16,
+								0));
+			GLCALL(glScalex(xdiv(r.width(), _game_texture->width()),
+							xdiv(r.height(), _game_texture->height()),
+							1 << 16));
 		}
 
-		GLCALL(glScalex(xdiv(_egl_surface_width, texwidth),
-						xdiv(_egl_surface_height, texheight),
-						1 << 16));
-
 		GLCALL(glTranslatex((-_mouse_hotspot.x * cs) << 16,
 							(-_mouse_hotspot.y * cs) << 16,
 							0));
 
 		// Note the extra half texel to position the mouse in
 		// the middle of the x,y square:
-		const Common::Point& mouse = getEventManager()->getMousePos();
 		GLCALL(glTranslatex((mouse.x << 16) | 1 << 15,
 							(mouse.y << 16) | 1 << 15, 0));
 
@@ -494,6 +545,8 @@ void OSystem_Android::showOverlay() {
 
 	_show_overlay = true;
 	_force_redraw = true;
+
+	GLCALL(glDisable(GL_SCISSOR_TEST));
 }
 
 void OSystem_Android::hideOverlay() {
@@ -501,6 +554,10 @@ void OSystem_Android::hideOverlay() {
 
 	_show_overlay = false;
 	_force_redraw = true;
+
+	clearScreen(false);
+
+	GLCALL(glEnable(GL_SCISSOR_TEST));
 }
 
 void OSystem_Android::clearOverlay() {
diff --git a/backends/platform/android/jni.cpp b/backends/platform/android/jni.cpp
index 6bfe9c2..0628d92 100644
--- a/backends/platform/android/jni.cpp
+++ b/backends/platform/android/jni.cpp
@@ -65,6 +65,7 @@ jfieldID JNI::_FID_Event_mouse_x = 0;
 jfieldID JNI::_FID_Event_mouse_y = 0;
 jfieldID JNI::_FID_Event_mouse_relative = 0;
 
+jmethodID JNI::_MID_getDPI = 0;
 jmethodID JNI::_MID_displayMessageOnOSD = 0;
 jmethodID JNI::_MID_setWindowCaption = 0;
 jmethodID JNI::_MID_showVirtualKeyboard = 0;
@@ -214,6 +215,35 @@ void JNI::throwRuntimeException(JNIEnv *env, const char *msg) {
 
 // calls to the dark side
 
+void JNI::getDPI(float *values) {
+	values[0] = 0.0;
+	values[1] = 0.0;
+
+	JNIEnv *env = JNI::getEnv();
+
+	jfloatArray array = env->NewFloatArray(2);
+
+	env->CallVoidMethod(_jobj, _MID_getDPI, array);
+
+	if (env->ExceptionCheck()) {
+		LOGE("Failed to get DPIs");
+
+		env->ExceptionDescribe();
+		env->ExceptionClear();
+	} else {
+		jfloat *res = env->GetFloatArrayElements(array, 0);
+
+		if (res) {
+			values[0] = res[0];
+			values[1] = res[1];
+
+			env->ReleaseFloatArrayElements(array, res, 0);
+		}
+	}
+
+	env->DeleteLocalRef(array);
+}
+
 void JNI::displayMessageOnOSD(const char *msg) {
 	JNIEnv *env = JNI::getEnv();
 	jstring java_msg = env->NewStringUTF(msg);
@@ -445,6 +475,7 @@ void JNI::create(JNIEnv *env, jobject self, jobject asset_manager,
 	} while (0)
 
 	FIND_METHOD(, setWindowCaption, "(Ljava/lang/String;)V");
+	FIND_METHOD(, getDPI, "([F)V");
 	FIND_METHOD(, displayMessageOnOSD, "(Ljava/lang/String;)V");
 	FIND_METHOD(, showVirtualKeyboard, "(Z)V");
 	FIND_METHOD(, getSysArchives, "()[Ljava/lang/String;");
diff --git a/backends/platform/android/jni.h b/backends/platform/android/jni.h
index 1469386..5746c01 100644
--- a/backends/platform/android/jni.h
+++ b/backends/platform/android/jni.h
@@ -60,6 +60,7 @@ public:
 
 	static void getPluginDirectories(Common::FSList &dirs);
 	static void setWindowCaption(const char *caption);
+	static void getDPI(float *values);
 	static void displayMessageOnOSD(const char *msg);
 	static void showVirtualKeyboard(bool enable);
 	static void addSysArchivesToSearchSet(Common::SearchSet &s, int priority);
@@ -100,6 +101,7 @@ private:
 	static jfieldID _FID_Event_mouse_relative;
 	static jfieldID _FID_ScummVM_nativeScummVM;
 
+	static jmethodID _MID_getDPI;
 	static jmethodID _MID_displayMessageOnOSD;
 	static jmethodID _MID_setWindowCaption;
 	static jmethodID _MID_showVirtualKeyboard;
diff --git a/backends/platform/android/org/inodes/gus/scummvm/ScummVM.java b/backends/platform/android/org/inodes/gus/scummvm/ScummVM.java
index f263b89..0bc5f3c 100644
--- a/backends/platform/android/org/inodes/gus/scummvm/ScummVM.java
+++ b/backends/platform/android/org/inodes/gus/scummvm/ScummVM.java
@@ -52,6 +52,7 @@ public abstract class ScummVM implements SurfaceHolder.Callback, Runnable {
 	final public native void pushEvent(Event e);
 
 	// Callbacks from C++ peer instance
+	abstract protected void getDPI(float[] values);
 	abstract protected void displayMessageOnOSD(String msg);
 	abstract protected void setWindowCaption(String caption);
 	abstract protected String[] getPluginDirectories();
diff --git a/backends/platform/android/org/inodes/gus/scummvm/ScummVMActivity.java b/backends/platform/android/org/inodes/gus/scummvm/ScummVMActivity.java
index 8cb3d80..2cf6f58 100644
--- a/backends/platform/android/org/inodes/gus/scummvm/ScummVMActivity.java
+++ b/backends/platform/android/org/inodes/gus/scummvm/ScummVMActivity.java
@@ -59,6 +59,15 @@ public class ScummVMActivity extends Activity {
 		}
 
 		@Override
+		protected void getDPI(float[] values) {
+			DisplayMetrics metrics = new DisplayMetrics();
+			getWindowManager().getDefaultDisplay().getMetrics(metrics);
+
+			values[0] = metrics.xdpi;
+			values[1] = metrics.ydpi;
+		}
+
+		@Override
 		protected void displayMessageOnOSD(String msg) {
 			Log.i(LOG_TAG, "OSD: " + msg);
 			Toast.makeText(ScummVMActivity.this, msg, Toast.LENGTH_LONG).show();


Commit: 2dd669d808b89f0d3777d196091b404a4e9baf05
    https://github.com/scummvm/scummvm/commit/2dd669d808b89f0d3777d196091b404a4e9baf05
Author: dhewg (dhewg at wiibrew.org)
Date: 2011-03-13T15:30:17-07:00

Commit Message:
ANDROID: Remove leftover TODO

Resolved with a93229c and 2721e28

Changed paths:
    backends/platform/android/android.cpp



diff --git a/backends/platform/android/android.cpp b/backends/platform/android/android.cpp
index ba57456..9f57eb3 100644
--- a/backends/platform/android/android.cpp
+++ b/backends/platform/android/android.cpp
@@ -480,7 +480,6 @@ bool OSystem_Android::pollEvent(Common::Event &event) {
 
 	switch (event.type) {
 	case Common::EVENT_MOUSEMOVE:
-		// TODO: only dirty/redraw move bounds
 		_force_redraw = true;
 		// fallthrough
 	case Common::EVENT_LBUTTONDOWN:


Commit: c63c2a9e59ab9f9013a5e0e1f6c443352ce4f20f
    https://github.com/scummvm/scummvm/commit/c63c2a9e59ab9f9013a5e0e1f6c443352ce4f20f
Author: dhewg (dhewg at wiibrew.org)
Date: 2011-03-13T15:30:17-07:00

Commit Message:
ANDROID: Fix texture clear color

Changed paths:
    backends/platform/android/gfx.cpp
    backends/platform/android/texture.cpp
    backends/platform/android/texture.h



diff --git a/backends/platform/android/gfx.cpp b/backends/platform/android/gfx.cpp
index 2053433..3324423 100644
--- a/backends/platform/android/gfx.cpp
+++ b/backends/platform/android/gfx.cpp
@@ -143,7 +143,7 @@ void OSystem_Android::initTexture(GLESBaseTexture **texture,
 	}
 
 	(*texture)->allocBuffer(width, height);
-	(*texture)->fillBuffer(0);
+	(*texture)->clearBuffer();
 }
 #endif
 
@@ -264,7 +264,7 @@ void OSystem_Android::initSize(uint width, uint height,
 	initTexture(&_game_texture, width, height, format);
 #else
 	_game_texture->allocBuffer(width, height);
-	_game_texture->fillBuffer(0);
+	_game_texture->clearBuffer();
 #endif
 
 	updateScreenRect();
@@ -686,7 +686,7 @@ void OSystem_Android::setMouseCursor(const byte *buf, uint w, uint h,
 
 			delete[] tmp;
 
-			_mouse_texture->fillBuffer(0);
+			_mouse_texture->clearBuffer();
 
 			return;
 		}
diff --git a/backends/platform/android/texture.cpp b/backends/platform/android/texture.cpp
index 499de00..b129b5e 100644
--- a/backends/platform/android/texture.cpp
+++ b/backends/platform/android/texture.cpp
@@ -267,6 +267,10 @@ void GLESTexture::fillBuffer(uint32 color) {
 	setDirty();
 }
 
+void GLESTexture::clearBuffer() {
+	fillBuffer(_pixelFormat.ARGBToColor(0xff, 0, 0, 0));
+}
+
 void GLESTexture::drawTexture(GLshort x, GLshort y, GLshort w, GLshort h) {
 	if (_all_dirty) {
 		_dirty_rect.top = 0;
@@ -377,6 +381,10 @@ void GLESPaletteTexture::fillBuffer(uint32 color) {
 	setDirty();
 }
 
+void GLESPaletteTexture::clearBuffer() {
+	fillBuffer(0);
+}
+
 void GLESPaletteTexture::updateBuffer(GLuint x, GLuint y, GLuint w, GLuint h,
 										const void *buf, int pitch_buf) {
 	setDirtyRect(Common::Rect(x, y, x + w, y + h));
@@ -497,6 +505,10 @@ void GLESFakePaletteTexture::fillBuffer(uint32 color) {
 	setDirty();
 }
 
+void GLESFakePaletteTexture::clearBuffer() {
+	fillBuffer(_palettePixelFormat.ARGBToColor(0xff, 0, 0, 0));
+}
+
 void GLESFakePaletteTexture::updateBuffer(GLuint x, GLuint y, GLuint w,
 											GLuint h, const void *buf,
 											int pitch_buf) {
diff --git a/backends/platform/android/texture.h b/backends/platform/android/texture.h
index 5470519..9b41627 100644
--- a/backends/platform/android/texture.h
+++ b/backends/platform/android/texture.h
@@ -56,6 +56,7 @@ public:
 	virtual void updateBuffer(GLuint x, GLuint y, GLuint width, GLuint height,
 								const void *buf, int pitch_buf) = 0;
 	virtual void fillBuffer(uint32 color) = 0;
+	virtual void clearBuffer() = 0;
 
 	virtual void drawTexture(GLshort x, GLshort y, GLshort w, GLshort h);
 
@@ -179,6 +180,7 @@ public:
 	virtual void updateBuffer(GLuint x, GLuint y, GLuint width, GLuint height,
 								const void *buf, int pitch_buf);
 	virtual void fillBuffer(uint32 color);
+	virtual void clearBuffer();
 
 	virtual void drawTexture(GLshort x, GLshort y, GLshort w, GLshort h);
 
@@ -232,6 +234,7 @@ public:
 	virtual void updateBuffer(GLuint x, GLuint y, GLuint width, GLuint height,
 								const void *buf, int pitch_buf);
 	virtual void fillBuffer(uint32 color);
+	virtual void clearBuffer();
 
 	virtual void drawTexture(GLshort x, GLshort y, GLshort w, GLshort h);
 
@@ -296,6 +299,7 @@ public:
 	virtual void updateBuffer(GLuint x, GLuint y, GLuint width, GLuint height,
 								const void *buf, int pitch_buf);
 	virtual void fillBuffer(uint32 color);
+	virtual void clearBuffer();
 
 	virtual void drawTexture(GLshort x, GLshort y, GLshort w, GLshort h);
 


Commit: df9167c6b33fbfcb259480c14b08be5c32de6fd3
    https://github.com/scummvm/scummvm/commit/df9167c6b33fbfcb259480c14b08be5c32de6fd3
Author: dhewg (dhewg at wiibrew.org)
Date: 2011-03-13T15:30:17-07:00

Commit Message:
ANDROID: Add graphics mode for linear filtering

Changed paths:
    backends/platform/android/android.cpp
    backends/platform/android/android.h
    backends/platform/android/gfx.cpp
    backends/platform/android/texture.cpp
    backends/platform/android/texture.h



diff --git a/backends/platform/android/android.cpp b/backends/platform/android/android.cpp
index 9f57eb3..606b825 100644
--- a/backends/platform/android/android.cpp
+++ b/backends/platform/android/android.cpp
@@ -116,6 +116,7 @@ OSystem_Android::OSystem_Android(int audio_sample_rate, int audio_buffer_size) :
 	_mouse_keycolor(0),
 	_use_mouse_palette(false),
 	_fullscreen(false),
+	_graphicsMode(0),
 	_ar_correction(false),
 	_show_mouse(false),
 	_show_overlay(false),
diff --git a/backends/platform/android/android.h b/backends/platform/android/android.h
index 26245e6..8e6d72f 100644
--- a/backends/platform/android/android.h
+++ b/backends/platform/android/android.h
@@ -121,6 +121,7 @@ private:
 	bool _show_mouse;
 	bool _use_mouse_palette;
 
+	int _graphicsMode;
 	bool _fullscreen;
 	bool _ar_correction;
 
@@ -175,7 +176,6 @@ public:
 
 	virtual const GraphicsMode *getSupportedGraphicsModes() const;
 	virtual int getDefaultGraphicsMode() const;
-	bool setGraphicsMode(const char *name);
 	virtual bool setGraphicsMode(int mode);
 	virtual int getGraphicsMode() const;
 
diff --git a/backends/platform/android/gfx.cpp b/backends/platform/android/gfx.cpp
index 3324423..06387e0 100644
--- a/backends/platform/android/gfx.cpp
+++ b/backends/platform/android/gfx.cpp
@@ -38,7 +38,8 @@ static inline GLfixed xdiv(int numerator, int denominator) {
 
 const OSystem::GraphicsMode *OSystem_Android::getSupportedGraphicsModes() const {
 	static const OSystem::GraphicsMode s_supportedGraphicsModes[] = {
-		{ "default", "Default", 1 },
+		{ "default", "Default", 0 },
+		{ "filter", "Linear filtering", 1 },
 		{ 0, 0, 0 },
 	};
 
@@ -46,23 +47,25 @@ const OSystem::GraphicsMode *OSystem_Android::getSupportedGraphicsModes() const
 }
 
 int OSystem_Android::getDefaultGraphicsMode() const {
-	return 1;
-}
-
-bool OSystem_Android::setGraphicsMode(const char *mode) {
-	ENTER("%s", mode);
-
-	return true;
+	return 0;
 }
 
 bool OSystem_Android::setGraphicsMode(int mode) {
 	ENTER("%d", mode);
 
+	if (_game_texture)
+		_game_texture->setLinearFilter(mode == 1);
+
+	if (_overlay_texture)
+		_overlay_texture->setLinearFilter(mode == 1);
+
+	_graphicsMode = mode;
+
 	return true;
 }
 
 int OSystem_Android::getGraphicsMode() const {
-	return 1;
+	return _graphicsMode;
 }
 
 #ifdef USE_RGB_COLOR
diff --git a/backends/platform/android/texture.cpp b/backends/platform/android/texture.cpp
index b129b5e..bbfd1f0 100644
--- a/backends/platform/android/texture.cpp
+++ b/backends/platform/android/texture.cpp
@@ -83,6 +83,7 @@ GLESBaseTexture::GLESBaseTexture(GLenum glFormat, GLenum glType,
 									Graphics::PixelFormat pixelFormat) :
 	_glFormat(glFormat),
 	_glType(glType),
+	_glFilter(GL_NEAREST),
 	_texture_name(0),
 	_surface(),
 	_texture_width(0),
@@ -127,8 +128,8 @@ void GLESBaseTexture::initSize() {
 	// later (perhaps with multiple TexSubImage2D operations).
 	GLCALL(glBindTexture(GL_TEXTURE_2D, _texture_name));
 	GLCALL(glPixelStorei(GL_UNPACK_ALIGNMENT, 1));
-	GLCALL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST));
-	GLCALL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST));
+	GLCALL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, _glFilter));
+	GLCALL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, _glFilter));
 	GLCALL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE));
 	GLCALL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE));
 	GLCALL(glTexImage2D(GL_TEXTURE_2D, 0, _glFormat,
@@ -136,6 +137,18 @@ void GLESBaseTexture::initSize() {
 						0, _glFormat, _glType, 0));
 }
 
+void GLESBaseTexture::setLinearFilter(bool value) {
+	if (value)
+		_glFilter = GL_LINEAR;
+	else
+		_glFilter = GL_NEAREST;
+
+	GLCALL(glBindTexture(GL_TEXTURE_2D, _texture_name));
+
+	GLCALL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, _glFilter));
+	GLCALL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, _glFilter));
+}
+
 void GLESBaseTexture::allocBuffer(GLuint w, GLuint h) {
 	_surface.w = w;
 	_surface.h = h;
diff --git a/backends/platform/android/texture.h b/backends/platform/android/texture.h
index 9b41627..1fe18bf 100644
--- a/backends/platform/android/texture.h
+++ b/backends/platform/android/texture.h
@@ -51,6 +51,8 @@ public:
 	void reinit();
 	void initSize();
 
+	void setLinearFilter(bool value);
+
 	virtual void allocBuffer(GLuint w, GLuint h);
 
 	virtual void updateBuffer(GLuint x, GLuint y, GLuint width, GLuint height,
@@ -152,6 +154,7 @@ protected:
 
 	GLenum _glFormat;
 	GLenum _glType;
+	GLint _glFilter;
 
 	GLuint _texture_name;
 	Graphics::Surface _surface;






More information about the Scummvm-git-logs mailing list