From 53ee7c551369cf00b5073f10c21b836759b8c302 Mon Sep 17 00:00:00 2001 From: dhewg Date: Sat, 5 Mar 2011 21:22:45 +0100 Subject: ANDROID: Proper fillBuffer() for non CLUT8 colors --- backends/platform/android/texture.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'backends/platform/android/texture.cpp') diff --git a/backends/platform/android/texture.cpp b/backends/platform/android/texture.cpp index e4c98e3ce0..7f3db0574b 100644 --- a/backends/platform/android/texture.cpp +++ b/backends/platform/android/texture.cpp @@ -212,13 +212,18 @@ void GLESTexture::updateBuffer(GLuint x, GLuint y, GLuint w, GLuint h, } } -void GLESTexture::fillBuffer(byte x) { +void GLESTexture::fillBuffer(uint32 color) { uint rowbytes = _surface.w * _bytesPerPixel; byte *tmp = new byte[rowbytes]; assert(tmp); - memset(tmp, x, rowbytes); + if (_bytesPerPixel == 1 || ((color & 0xff) == ((color >> 8) & 0xff))) { + memset(tmp, color & 0xff, rowbytes); + } else { + uint16 *p = (uint16 *)tmp; + Common::set_to(p, p + _surface.w, (uint16)color); + } GLCALL(glBindTexture(GL_TEXTURE_2D, _texture_name)); GLCALL(glPixelStorei(GL_UNPACK_ALIGNMENT, 1)); @@ -346,9 +351,9 @@ void GLESPaletteTexture::allocBuffer(GLuint w, GLuint h) { _surface.pixels = _texture + _paletteSize; } -void GLESPaletteTexture::fillBuffer(byte x) { +void GLESPaletteTexture::fillBuffer(uint32 color) { assert(_surface.pixels); - memset(_surface.pixels, x, _surface.pitch * _surface.h); + memset(_surface.pixels, color & 0xff, _surface.pitch * _surface.h); setDirty(); } -- cgit v1.2.3