aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--backends/platform/android/android.cpp31
-rw-r--r--backends/platform/android/gfx.cpp15
-rw-r--r--backends/platform/android/texture.cpp7
-rw-r--r--backends/platform/android/texture.h4
4 files changed, 32 insertions, 25 deletions
diff --git a/backends/platform/android/android.cpp b/backends/platform/android/android.cpp
index d4a2253c30..491e5fbc72 100644
--- a/backends/platform/android/android.cpp
+++ b/backends/platform/android/android.cpp
@@ -124,10 +124,6 @@ OSystem_Android::OSystem_Android(int audio_sample_rate, int audio_buffer_size) :
OSystem_Android::~OSystem_Android() {
ENTER();
- delete _game_texture;
- delete _overlay_texture;
- delete _mouse_texture;
-
delete _savefile;
delete _timer;
delete _mixer;
@@ -323,6 +319,10 @@ void OSystem_Android::initBackend() {
setupSurface();
+ _game_texture = new GLESPaletteTexture();
+ _overlay_texture = new GLES4444Texture();
+ _mouse_texture = new GLESPaletteATexture();
+
// renice this thread to boost the audio thread
if (setpriority(PRIO_PROCESS, 0, 19) < 0)
warning("couldn't renice the main thread");
@@ -400,9 +400,17 @@ bool OSystem_Android::pollEvent(Common::Event &event) {
if (JNI::egl_surface_width > 0 && JNI::egl_surface_height > 0) {
LOGD("initializing surface");
+ _game_texture->release();
+ _overlay_texture->release();
+ _mouse_texture->release();
+
JNI::deinitSurface();
setupSurface();
+ _game_texture->reinit();
+ _overlay_texture->reinit();
+ _mouse_texture->reinit();
+
event.type = Common::EVENT_SCREEN_CHANGED;
return true;
@@ -410,15 +418,20 @@ bool OSystem_Android::pollEvent(Common::Event &event) {
LOGD("deinitialiting surface");
+ _game_texture->release();
+ _overlay_texture->release();
+ _mouse_texture->release();
+
_screen_changeid = JNI::surface_changeid;
JNI::deinitSurface();
}
if (JNI::pause) {
// release some resources
- // TODO
- // free textures? they're garbled anyway since no engine
- // respects EVENT_SCREEN_CHANGED
+ _game_texture->release();
+ _overlay_texture->release();
+ _mouse_texture->release();
+
LOGD("deinitialiting surface");
JNI::deinitSurface();
@@ -573,6 +586,10 @@ void OSystem_Android::quit() {
_timer_thread_exit = true;
pthread_join(_timer_thread, 0);
+ delete _game_texture;
+ delete _overlay_texture;
+ delete _mouse_texture;
+
JNI::deinitSurface();
}
diff --git a/backends/platform/android/gfx.cpp b/backends/platform/android/gfx.cpp
index 15e517a07f..e2cc854a1d 100644
--- a/backends/platform/android/gfx.cpp
+++ b/backends/platform/android/gfx.cpp
@@ -94,21 +94,6 @@ void OSystem_Android::setupSurface() {
GLCALL(glEnable(GL_TEXTURE_2D));
- if (!_game_texture)
- _game_texture = new GLESPaletteTexture();
- else
- _game_texture->reinitGL();
-
- if (!_overlay_texture)
- _overlay_texture = new GLES4444Texture();
- else
- _overlay_texture->reinitGL();
-
- if (!_mouse_texture)
- _mouse_texture = new GLESPaletteATexture();
- else
- _mouse_texture->reinitGL();
-
GLCALL(glViewport(0, 0, _egl_surface_width, _egl_surface_height));
GLCALL(glMatrixMode(GL_PROJECTION));
diff --git a/backends/platform/android/texture.cpp b/backends/platform/android/texture.cpp
index 9840e7d5c5..ea8a89df78 100644
--- a/backends/platform/android/texture.cpp
+++ b/backends/platform/android/texture.cpp
@@ -98,12 +98,15 @@ GLESTexture::GLESTexture() :
}
GLESTexture::~GLESTexture() {
+ release();
+}
+
+void GLESTexture::release() {
debug("Destroying texture %u", _texture_name);
GLCALL(glDeleteTextures(1, &_texture_name));
}
-void GLESTexture::reinitGL() {
- GLCALL(glDeleteTextures(1, &_texture_name));
+void GLESTexture::reinit() {
GLCALL(glGenTextures(1, &_texture_name));
// bypass allocBuffer() shortcut to reinit the texture properly
diff --git a/backends/platform/android/texture.h b/backends/platform/android/texture.h
index 12274621a1..f1d5cad6e9 100644
--- a/backends/platform/android/texture.h
+++ b/backends/platform/android/texture.h
@@ -42,7 +42,9 @@ public:
GLESTexture();
virtual ~GLESTexture();
- virtual void reinitGL();
+ void release();
+ void reinit();
+
virtual void allocBuffer(GLuint width, GLuint height);
virtual void updateBuffer(GLuint x, GLuint y, GLuint width, GLuint height,