aboutsummaryrefslogtreecommitdiff
path: root/backends/platform
diff options
context:
space:
mode:
authordhewg2011-03-03 20:41:04 +0100
committerdhewg2011-03-03 21:29:47 +0100
commitce9796baa3185417af53969e1258350648c2fc5a (patch)
treeb0fea3ec73c8a01ed3895a06c68c9439af6c26a9 /backends/platform
parent7157454e9b30db91462cb684dd20a61204a7fa43 (diff)
downloadscummvm-rg350-ce9796baa3185417af53969e1258350648c2fc5a.tar.gz
scummvm-rg350-ce9796baa3185417af53969e1258350648c2fc5a.tar.bz2
scummvm-rg350-ce9796baa3185417af53969e1258350648c2fc5a.zip
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
Diffstat (limited to 'backends/platform')
-rw-r--r--backends/platform/android/texture.cpp40
-rw-r--r--backends/platform/android/texture.h1
2 files changed, 26 insertions, 15 deletions
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);