[Scummvm-cvs-logs] scummvm master -> 1f90d232e3b4911f725fe22489aaa2cc2253426d

dhewg dhewg at wiibrew.org
Mon Mar 7 19:57:51 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:
42c6a785c7 ANDROID: Texture cleanup
1f90d232e3 ANDROID: Save the game when the process is paused


Commit: 42c6a785c74c200b19ceef6db5003f334c3edf29
    https://github.com/scummvm/scummvm/commit/42c6a785c74c200b19ceef6db5003f334c3edf29
Author: dhewg (dhewg at wiibrew.org)
Date: 2011-03-07T10:56:29-08:00

Commit Message:
ANDROID: Texture cleanup

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



diff --git a/backends/platform/android/texture.cpp b/backends/platform/android/texture.cpp
index ee41d3a..24e6549 100644
--- a/backends/platform/android/texture.cpp
+++ b/backends/platform/android/texture.cpp
@@ -88,19 +88,15 @@ GLESTexture::GLESTexture(byte bytesPerPixel, GLenum glFormat, GLenum glType,
 	_glFormat(glFormat),
 	_glType(glType),
 	_paletteSize(paletteSize),
-	_pixelFormat(pixelFormat),
+	_texture_name(0),
+	_surface(),
 	_texture_width(0),
 	_texture_height(0),
-	_all_dirty(true)
+	_all_dirty(false),
+	_dirty_rect(),
+	_pixelFormat(pixelFormat)
 {
 	GLCALL(glGenTextures(1, &_texture_name));
-
-	// This all gets reset later in allocBuffer:
-	_surface.w = 0;
-	_surface.h = 0;
-	_surface.pitch = 0;
-	_surface.pixels = 0;
-	_surface.bytesPerPixel = 0;
 }
 
 GLESTexture::~GLESTexture() {
@@ -280,8 +276,7 @@ void GLESTexture::drawTexture(GLshort x, GLshort y, GLshort w, GLshort h) {
 		GLCALL(glDrawArrays(GL_TRIANGLE_STRIP, 0, ARRAYSIZE(vertices) / 2));
 	}
 
-	_all_dirty = false;
-	_dirty_rect = Common::Rect();
+	clearDirty();
 }
 
 GLES4444Texture::GLES4444Texture() :
@@ -318,28 +313,13 @@ GLESPaletteTexture::~GLESPaletteTexture() {
 }
 
 void GLESPaletteTexture::allocBuffer(GLuint w, GLuint h) {
-	_surface.w = w;
-	_surface.h = h;
-	_surface.bytesPerPixel = _bytesPerPixel;
-
-	// Already allocated a sufficiently large buffer?
-	if (w <= _texture_width && h <= _texture_height)
-		return;
-
-	if (npot_supported) {
-		_texture_width = _surface.w;
-		_texture_height = _surface.h;
-	} else {
-		_texture_width = nextHigher2(_surface.w);
-		_texture_height = nextHigher2(_surface.h);
-	}
-
-	_surface.pitch = _texture_width * _bytesPerPixel;
+	GLESTexture::allocBuffer(w, h);
 
 	// Texture gets uploaded later (from drawTexture())
 
 	byte *new_buffer = new byte[_paletteSize +
 		_texture_width * _texture_height * _bytesPerPixel];
+	assert(new_buffer);
 
 	if (_texture) {
 		// preserve palette
@@ -357,10 +337,9 @@ void GLESPaletteTexture::fillBuffer(uint32 color) {
 	setDirty();
 }
 
-void GLESPaletteTexture::updateBuffer(GLuint x, GLuint y,
-										GLuint w, GLuint h,
+void GLESPaletteTexture::updateBuffer(GLuint x, GLuint y, GLuint w, GLuint h,
 										const void *buf, int pitch_buf) {
-	_all_dirty = true;
+	setDirtyRect(Common::Rect(x, y, x + w, y + h));
 
 	const byte * src = static_cast<const byte *>(buf);
 	byte *dst = static_cast<byte *>(_surface.getBasePtr(x, y));
@@ -374,16 +353,8 @@ void GLESPaletteTexture::updateBuffer(GLuint x, GLuint y,
 
 void GLESPaletteTexture::drawTexture(GLshort x, GLshort y, GLshort w,
 										GLshort h) {
-	if (_all_dirty) {
+	if (dirty()) {
 		GLCALL(glBindTexture(GL_TEXTURE_2D, _texture_name));
-		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_WRAP_S,
-								GL_CLAMP_TO_EDGE));
-		GLCALL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T,
-								GL_CLAMP_TO_EDGE));
 
 		const size_t texture_size =
 			_paletteSize + _texture_width * _texture_height * _bytesPerPixel;
diff --git a/backends/platform/android/texture.h b/backends/platform/android/texture.h
index f2c79d4..78df43a 100644
--- a/backends/platform/android/texture.h
+++ b/backends/platform/android/texture.h
@@ -95,7 +95,14 @@ public:
 protected:
 	inline void setDirty() {
 		_all_dirty = true;
-		_dirty_rect = Common::Rect();
+	}
+
+	inline void clearDirty() {
+		_all_dirty = false;
+		_dirty_rect.top = 0;
+		_dirty_rect.left = 0;
+		_dirty_rect.bottom = 0;
+		_dirty_rect.right = 0;
 	}
 
 	inline void setDirtyRect(const Common::Rect& r) {
@@ -116,9 +123,9 @@ protected:
 	Graphics::Surface _surface;
 	GLuint _texture_width;
 	GLuint _texture_height;
-	bool _all_dirty;
 
 	// Covers dirty area
+	bool _all_dirty;
 	Common::Rect _dirty_rect;
 
 	Graphics::PixelFormat _pixelFormat;


Commit: 1f90d232e3b4911f725fe22489aaa2cc2253426d
    https://github.com/scummvm/scummvm/commit/1f90d232e3b4911f725fe22489aaa2cc2253426d
Author: dhewg (dhewg at wiibrew.org)
Date: 2011-03-07T10:56:29-08:00

Commit Message:
ANDROID: Save the game when the process is paused

The OS can kill the activity at will after onPause() or onStop()
to free up memory for other application. Provide a parachute when
the engine allows it.

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



diff --git a/backends/platform/android/jni.cpp b/backends/platform/android/jni.cpp
index 73b7439..6bfe9c2 100644
--- a/backends/platform/android/jni.cpp
+++ b/backends/platform/android/jni.cpp
@@ -631,7 +631,13 @@ void JNI::setPause(JNIEnv *env, jobject self, jboolean value) {
 
 	if (g_engine) {
 		LOGD("pauseEngine: %d", value);
+
 		g_engine->pauseEngine(value);
+
+		if (value &&
+				g_engine->hasFeature(Engine::kSupportsSavingDuringRuntime) &&
+				g_engine->canSaveGameStateCurrently())
+			g_engine->saveGameState(0, "Android parachute");
 	}
 
 	pause = value;






More information about the Scummvm-git-logs mailing list