From ce9796baa3185417af53969e1258350648c2fc5a Mon Sep 17 00:00:00 2001 From: dhewg Date: Thu, 3 Mar 2011 20:41:04 +0100 Subject: ANDROID: Don't wipe paletted textures on reinit The content of a paletted texture is in _surface.pixels. When recreating the surface, don't wipe its data unnecessarily. This fixes gfx garbage on CLUT8 games/cursors when leaving and going back to ScummVM --- backends/platform/android/texture.cpp | 40 ++++++++++++++++++++++------------- backends/platform/android/texture.h | 1 + 2 files changed, 26 insertions(+), 15 deletions(-) (limited to 'backends/platform/android') diff --git a/backends/platform/android/texture.cpp b/backends/platform/android/texture.cpp index cb12d264b8..fb9f3bb913 100644 --- a/backends/platform/android/texture.cpp +++ b/backends/platform/android/texture.cpp @@ -109,14 +109,34 @@ void GLESTexture::release() { void GLESTexture::reinit() { GLCALL(glGenTextures(1, &_texture_name)); - // bypass allocBuffer() shortcut to reinit the texture properly - _texture_width = 0; - _texture_height = 0; + if (paletteSize()) { + // paletted textures are in a local buffer, don't wipe it + initSize(); + } else { + // bypass allocBuffer() shortcut to reinit the texture properly + _texture_width = 0; + _texture_height = 0; + + allocBuffer(_surface.w, _surface.h); + } - allocBuffer(_surface.w, _surface.h); setDirty(); } +void GLESTexture::initSize() { + // Allocate room for the texture now, but pixel data gets uploaded + // 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_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(), + _texture_width, _texture_height, + 0, glFormat(), glType(), 0)); +} + void GLESTexture::allocBuffer(GLuint w, GLuint h) { int bpp = bytesPerPixel(); _surface.w = w; @@ -137,17 +157,7 @@ void GLESTexture::allocBuffer(GLuint w, GLuint h) { _surface.pitch = _texture_width * bpp; - // Allocate room for the texture now, but pixel data gets uploaded - // 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_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(), - _texture_width, _texture_height, - 0, glFormat(), glType(), 0)); + initSize(); } void GLESTexture::updateBuffer(GLuint x, GLuint y, GLuint w, GLuint h, diff --git a/backends/platform/android/texture.h b/backends/platform/android/texture.h index f1d5cad6e9..cc1f4e3dae 100644 --- a/backends/platform/android/texture.h +++ b/backends/platform/android/texture.h @@ -44,6 +44,7 @@ public: void release(); void reinit(); + void initSize(); virtual void allocBuffer(GLuint width, GLuint height); -- cgit v1.2.3