aboutsummaryrefslogtreecommitdiff
path: root/backends/platform/android
diff options
context:
space:
mode:
authordhewg2011-03-06 21:27:34 +0100
committerdhewg2011-03-07 19:56:29 +0100
commit42c6a785c74c200b19ceef6db5003f334c3edf29 (patch)
treedd64b334ca93d8703e791b565edf766ced224ebf /backends/platform/android
parent29b5b4afa66287dc382adbd2bfcb8add620d2a0d (diff)
downloadscummvm-rg350-42c6a785c74c200b19ceef6db5003f334c3edf29.tar.gz
scummvm-rg350-42c6a785c74c200b19ceef6db5003f334c3edf29.tar.bz2
scummvm-rg350-42c6a785c74c200b19ceef6db5003f334c3edf29.zip
ANDROID: Texture cleanup
Diffstat (limited to 'backends/platform/android')
-rw-r--r--backends/platform/android/texture.cpp51
-rw-r--r--backends/platform/android/texture.h11
2 files changed, 20 insertions, 42 deletions
diff --git a/backends/platform/android/texture.cpp b/backends/platform/android/texture.cpp
index ee41d3aeee..24e6549b1a 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 f2c79d4007..78df43aea9 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;