diff options
author | dhewg | 2011-03-05 10:10:50 +0100 |
---|---|---|
committer | dhewg | 2011-03-05 11:00:36 +0100 |
commit | 83b00526d0da2265eef8d59767cafd16190ec092 (patch) | |
tree | 2c6afc0727e8187a33b9991b423049b3060ef9cf /backends | |
parent | 4ee0a9f43a3ccb70872b059a753485349529166d (diff) | |
download | scummvm-rg350-83b00526d0da2265eef8d59767cafd16190ec092.tar.gz scummvm-rg350-83b00526d0da2265eef8d59767cafd16190ec092.tar.bz2 scummvm-rg350-83b00526d0da2265eef8d59767cafd16190ec092.zip |
ANDROID: Reduce mem usage of fillBuffer()
Diffstat (limited to 'backends')
-rw-r--r-- | backends/platform/android/texture.cpp | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/backends/platform/android/texture.cpp b/backends/platform/android/texture.cpp index 6e31bc0c59..05c551803b 100644 --- a/backends/platform/android/texture.cpp +++ b/backends/platform/android/texture.cpp @@ -214,13 +214,21 @@ void GLESTexture::updateBuffer(GLuint x, GLuint y, GLuint w, GLuint h, void GLESTexture::fillBuffer(byte x) { uint rowbytes = _surface.w * _bytesPerPixel; - byte *tmp = new byte[_surface.h * rowbytes]; + byte *tmp = new byte[rowbytes]; assert(tmp); - memset(tmp, x, _surface.h * rowbytes); - updateBuffer(0, 0, _surface.w, _surface.h, tmp, rowbytes); + memset(tmp, x, rowbytes); + + GLCALL(glBindTexture(GL_TEXTURE_2D, _texture_name)); + GLCALL(glPixelStorei(GL_UNPACK_ALIGNMENT, 1)); + + for (GLuint y = 0; y < _surface.h; ++y) + GLCALL(glTexSubImage2D(GL_TEXTURE_2D, 0, 0, y, _surface.w, 1, + _glFormat, _glType, tmp)); delete[] tmp; + + setDirty(); } void GLESTexture::drawTexture(GLshort x, GLshort y, GLshort w, GLshort h) { @@ -311,12 +319,14 @@ void GLESPaletteTexture::allocBuffer(GLuint w, GLuint h) { _texture_width = nextHigher2(_surface.w); _texture_height = nextHigher2(_surface.h); } + _surface.pitch = _texture_width * _bytesPerPixel; // Texture gets uploaded later (from drawTexture()) byte *new_buffer = new byte[_paletteSize + _texture_width * _texture_height * _bytesPerPixel]; + if (_texture) { // preserve palette memcpy(new_buffer, _texture, _paletteSize); @@ -367,8 +377,6 @@ void GLESPaletteTexture::drawTexture(GLshort x, GLshort y, GLshort w, GLCALL(glCompressedTexImage2D(GL_TEXTURE_2D, 0, _glType, _texture_width, _texture_height, 0, texture_size, _texture)); - - _all_dirty = false; } GLESTexture::drawTexture(x, y, w, h); |