diff options
author | dhewg | 2011-03-12 09:15:27 +0100 |
---|---|---|
committer | dhewg | 2011-03-12 09:36:22 +0100 |
commit | 99c0d825418de549c42f26532eb444cdfa82e507 (patch) | |
tree | ad50e163970a94b429de4c1bfa7758d55ed30010 | |
parent | 4afa2c62b979251cb4d8ff7e5a97f5385a6287fe (diff) | |
download | scummvm-rg350-99c0d825418de549c42f26532eb444cdfa82e507.tar.gz scummvm-rg350-99c0d825418de549c42f26532eb444cdfa82e507.tar.bz2 scummvm-rg350-99c0d825418de549c42f26532eb444cdfa82e507.zip |
ANDROID: Cleanup paletted textures
-rw-r--r-- | backends/platform/android/gfx.cpp | 8 | ||||
-rw-r--r-- | backends/platform/android/texture.cpp | 16 | ||||
-rw-r--r-- | backends/platform/android/texture.h | 8 |
3 files changed, 18 insertions, 14 deletions
diff --git a/backends/platform/android/gfx.cpp b/backends/platform/android/gfx.cpp index 327ef06f38..d0fc392681 100644 --- a/backends/platform/android/gfx.cpp +++ b/backends/platform/android/gfx.cpp @@ -295,7 +295,7 @@ void OSystem_Android::setPalette(const byte *colors, uint start, uint num) { ENTER("%p, %u, %u", colors, start, num); #ifdef USE_RGB_COLOR - assert(_game_texture->getPixelFormat().bytesPerPixel == 1); + assert(_game_texture->hasPalette()); #endif GLTHREADCHECK; @@ -310,7 +310,7 @@ void OSystem_Android::grabPalette(byte *colors, uint start, uint num) { ENTER("%p, %u, %u", colors, start, num); #ifdef USE_RGB_COLOR - assert(_game_texture->getPixelFormat().bytesPerPixel == 1); + assert(_game_texture->hasPalette()); #endif GLTHREADCHECK; @@ -664,7 +664,7 @@ void OSystem_Android::setCursorPalette(const byte *colors, GLTHREADCHECK; - if (_mouse_texture->getPixelFormat().bytesPerPixel != 1) { + if (!_mouse_texture->hasPalette()) { LOGD("switching to paletted mouse cursor"); _mouse_texture = _mouse_texture_palette; @@ -682,7 +682,7 @@ void OSystem_Android::disableCursorPalette(bool disable) { // when disabling the cursor palette, and we're running a clut8 game, // it expects the game palette to be used for the cursor - if (disable && _game_texture->getPixelFormat().bytesPerPixel == 1) { + if (disable && _game_texture->hasPalette()) { byte *src = _game_texture->palette(); byte *dst = _mouse_texture_palette->palette(); diff --git a/backends/platform/android/texture.cpp b/backends/platform/android/texture.cpp index 24e6549b1a..eb45de7468 100644 --- a/backends/platform/android/texture.cpp +++ b/backends/platform/android/texture.cpp @@ -83,11 +83,10 @@ void GLESTexture::initGLExtensions() { } GLESTexture::GLESTexture(byte bytesPerPixel, GLenum glFormat, GLenum glType, - size_t paletteSize, Graphics::PixelFormat pixelFormat) : + Graphics::PixelFormat pixelFormat) : _bytesPerPixel(bytesPerPixel), _glFormat(glFormat), _glType(glType), - _paletteSize(paletteSize), _texture_name(0), _surface(), _texture_width(0), @@ -111,7 +110,7 @@ void GLESTexture::release() { void GLESTexture::reinit() { GLCALL(glGenTextures(1, &_texture_name)); - if (_paletteSize) { + if (hasPalette()) { // paletted textures are in a local buffer, don't wipe it initSize(); } else { @@ -239,7 +238,7 @@ void GLESTexture::drawTexture(GLshort x, GLshort y, GLshort w, GLshort h) { #ifdef GL_OES_draw_texture // Great extension, but only works under specific conditions. // Still a work-in-progress - disabled for now. - if (false && draw_tex_supported && _paletteSize == 0) { + if (false && draw_tex_supported && !hasPalette()) { //GLCALL(glTexEnvx(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE)); const GLint crop[4] = { 0, _surface.h, _surface.w, -_surface.h }; @@ -280,21 +279,21 @@ void GLESTexture::drawTexture(GLshort x, GLshort y, GLshort w, GLshort h) { } GLES4444Texture::GLES4444Texture() : - GLESTexture(2, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, 0, getPixelFormat()) { + GLESTexture(2, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, getPixelFormat()) { } GLES4444Texture::~GLES4444Texture() { } GLES5551Texture::GLES5551Texture() : - GLESTexture(2, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, 0, getPixelFormat()) { + GLESTexture(2, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, getPixelFormat()) { } GLES5551Texture::~GLES5551Texture() { } GLES565Texture::GLES565Texture() : - GLESTexture(2, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, 0, getPixelFormat()) { + GLESTexture(2, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, getPixelFormat()) { } GLES565Texture::~GLES565Texture() { @@ -302,8 +301,9 @@ GLES565Texture::~GLES565Texture() { GLESPaletteTexture::GLESPaletteTexture(byte bytesPerPixel, GLenum glFormat, GLenum glType, size_t paletteSize) : - GLESTexture(bytesPerPixel, glFormat, glType, paletteSize, + GLESTexture(bytesPerPixel, glFormat, glType, Graphics::PixelFormat::createFormatCLUT8()), + _paletteSize(paletteSize), _texture(0) { } diff --git a/backends/platform/android/texture.h b/backends/platform/android/texture.h index 1ed16cb390..91ec9ff857 100644 --- a/backends/platform/android/texture.h +++ b/backends/platform/android/texture.h @@ -42,7 +42,7 @@ public: protected: GLESTexture(byte bytesPerPixel, GLenum glFormat, GLenum glType, - size_t paletteSize, Graphics::PixelFormat pixelFormat); + Graphics::PixelFormat pixelFormat); public: virtual ~GLESTexture(); @@ -92,6 +92,10 @@ public: return 0; }; + inline bool hasPalette() const { + return palette_const() != 0; + } + inline bool dirty() const { return _all_dirty || !_dirty_rect.isEmpty(); } @@ -125,7 +129,6 @@ protected: byte _bytesPerPixel; GLenum _glFormat; GLenum _glType; - size_t _paletteSize; GLuint _texture_name; Graphics::Surface _surface; @@ -202,6 +205,7 @@ public: protected: byte *_texture; + size_t _paletteSize; }; // RGB888 256-entry paletted texture |