aboutsummaryrefslogtreecommitdiff
path: root/backends/platform
diff options
context:
space:
mode:
authorAngus Lees2010-10-25 07:35:40 +0000
committerAngus Lees2010-10-25 07:35:40 +0000
commit7d0598d81025793dd078722a68b429a7e807c8a8 (patch)
treef3f5dbe0a3fa49e07226205ffa7cb2a9d556ff0d /backends/platform
parent2bf64b10506a97a7e9342e5d97ad89bd33628a53 (diff)
downloadscummvm-rg350-7d0598d81025793dd078722a68b429a7e807c8a8.tar.gz
scummvm-rg350-7d0598d81025793dd078722a68b429a7e807c8a8.tar.bz2
scummvm-rg350-7d0598d81025793dd078722a68b429a7e807c8a8.zip
ANDROID: Provide an alternate partial texture update for stride != width
The new one copies into a temp buffer and only does one glTexSubImage2D. I'm led to believe that this is faster on some devices (but slower on others). Disabled for now, but someone might want to try both versions on their slow device. Also manually set glColor before calling DrawTexiOES, following mention of a bug in a discussion I stumbled across. DrawTexiOES-use is disabled for now, so this is a noop. svn-id: r53803
Diffstat (limited to 'backends/platform')
-rw-r--r--backends/platform/android/video.cpp40
1 files changed, 30 insertions, 10 deletions
diff --git a/backends/platform/android/video.cpp b/backends/platform/android/video.cpp
index d4c002fbd0..81a8f7fbc7 100644
--- a/backends/platform/android/video.cpp
+++ b/backends/platform/android/video.cpp
@@ -38,6 +38,9 @@
#include "backends/platform/android/video.h"
+// Unfortunately, Android devices are too varied to make broad assumptions :/
+#define TEXSUBIMAGE_IS_EXPENSIVE 0
+
#undef LOG_TAG
#define LOG_TAG "ScummVM-video"
@@ -158,13 +161,11 @@ void GLESTexture::allocBuffer(GLuint w, GLuint h) {
// later (perhaps with multiple TexSubImage2D operations).
CHECK_GL_ERROR();
glBindTexture(GL_TEXTURE_2D, _texture_name);
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
CHECK_GL_ERROR();
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- CHECK_GL_ERROR();
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
- CHECK_GL_ERROR();
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- CHECK_GL_ERROR();
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
CHECK_GL_ERROR();
glTexImage2D(GL_TEXTURE_2D, 0, glFormat(),
@@ -177,6 +178,7 @@ void GLESTexture::updateBuffer(GLuint x, GLuint y, GLuint w, GLuint h,
const void* buf, int pitch) {
ENTER("updateBuffer(%u, %u, %u, %u, %p, %d)", x, y, w, h, buf, pitch);
glBindTexture(GL_TEXTURE_2D, _texture_name);
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
setDirtyRect(Common::Rect(x, y, x+w, y+h));
@@ -185,7 +187,25 @@ void GLESTexture::updateBuffer(GLuint x, GLuint y, GLuint w, GLuint h,
glFormat(), glType(), buf);
} else {
// GLES removed the ability to specify pitch, so we
- // have to do this row by row.
+ // have to do this ourselves.
+ if (h == 0)
+ return;
+
+#if TEXSUBIMAGE_IS_EXPENSIVE
+ byte tmpbuf[w * h * bytesPerPixel()];
+ const byte* src = static_cast<const byte*>(buf);
+ byte* dst = tmpbuf;
+ GLuint count = h;
+ do {
+ memcpy(dst, src, w * bytesPerPixel());
+ dst += w * bytesPerPixel();
+ src += pitch;
+ } while (--count);
+ glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, w, h,
+ glFormat(), glType(), tmpbuf);
+#else
+ // This version avoids the intermediate copy at the expense of
+ // repeat glTexSubImage2D calls. On some devices this is worse.
const byte* src = static_cast<const byte*>(buf);
do {
glTexSubImage2D(GL_TEXTURE_2D, 0, x, y,
@@ -193,16 +213,15 @@ void GLESTexture::updateBuffer(GLuint x, GLuint y, GLuint w, GLuint h,
++y;
src += pitch;
} while (--h);
+#endif
}
}
void GLESTexture::fillBuffer(byte x) {
- byte tmpbuf[_surface.h * _surface.w * bytesPerPixel()];
- memset(tmpbuf, 0, _surface.h * _surface.w * bytesPerPixel());
- glBindTexture(GL_TEXTURE_2D, _texture_name);
- glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, _surface.w, _surface.h,
- glFormat(), glType(), tmpbuf);
- setDirty();
+ int rowbytes = _surface.w * bytesPerPixel();
+ byte tmpbuf[_surface.h * rowbytes];
+ memset(tmpbuf, x, _surface.h * rowbytes);
+ updateBuffer(0, 0, _surface.w, _surface.h, tmpbuf, rowbytes);
}
void GLESTexture::drawTexture(GLshort x, GLshort y, GLshort w, GLshort h) {
@@ -215,6 +234,7 @@ void GLESTexture::drawTexture(GLshort x, GLshort y, GLshort w, GLshort h) {
//glTexEnvx(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
const GLint crop[4] = {0, _surface.h, _surface.w, -_surface.h};
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_CROP_RECT_OES, crop);
+ glColor4ub(0xff, 0xff, 0xff, 0xff); // Android GLES bug?
glDrawTexiOES(x, y, 0, w, h);
} else
#endif