diff options
Diffstat (limited to 'backends')
-rw-r--r-- | backends/graphics/opengl/opengl-graphics.cpp | 28 | ||||
-rw-r--r-- | backends/graphics/sdl/sdl-graphics.cpp | 13 | ||||
-rw-r--r-- | backends/platform/android/android.cpp | 30 | ||||
-rw-r--r-- | backends/platform/wii/osystem_gfx.cpp | 18 |
4 files changed, 33 insertions, 56 deletions
diff --git a/backends/graphics/opengl/opengl-graphics.cpp b/backends/graphics/opengl/opengl-graphics.cpp index cee80f9dc0..d4978b9e19 100644 --- a/backends/graphics/opengl/opengl-graphics.cpp +++ b/backends/graphics/opengl/opengl-graphics.cpp @@ -62,8 +62,8 @@ OpenGLGraphicsManager::OpenGLGraphicsManager() _videoMode.fullscreen = ConfMan.getBool("fullscreen"); _videoMode.antialiasing = false; - _gamePalette = (byte *)calloc(sizeof(byte) * 4, 256); - _cursorPalette = (byte *)calloc(sizeof(byte) * 4, 256); + _gamePalette = (byte *)calloc(sizeof(byte) * 3, 256); + _cursorPalette = (byte *)calloc(sizeof(byte) * 3, 256); } OpenGLGraphicsManager::~OpenGLGraphicsManager() { @@ -314,7 +314,7 @@ void OpenGLGraphicsManager::setPalette(const byte *colors, uint start, uint num) #endif // Save the screen palette - memcpy(_gamePalette + start * 4, colors, num * 4); + memcpy(_gamePalette + start * 3, colors, num * 3); _screenNeedsRedraw = true; @@ -330,7 +330,7 @@ void OpenGLGraphicsManager::grabPalette(byte *colors, uint start, uint num) { #endif // Copies current palette to buffer - memcpy(colors, _gamePalette + start * 4, num * 4); + memcpy(colors, _gamePalette + start * 3, num * 3); } void OpenGLGraphicsManager::copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h) { @@ -580,7 +580,7 @@ void OpenGLGraphicsManager::setCursorPalette(const byte *colors, uint start, uin assert(colors); // Save the cursor palette - memcpy(_cursorPalette + start * 4, colors, num * 4); + memcpy(_cursorPalette + start * 3, colors, num * 3); _cursorPaletteDisabled = false; _cursorNeedsRedraw = true; @@ -686,9 +686,9 @@ void OpenGLGraphicsManager::refreshGameScreen() { byte *dst = surface; for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { - dst[0] = _gamePalette[src[j] * 4]; - dst[1] = _gamePalette[src[j] * 4 + 1]; - dst[2] = _gamePalette[src[j] * 4 + 2]; + dst[0] = _gamePalette[src[j] * 3]; + dst[1] = _gamePalette[src[j] * 3 + 1]; + dst[2] = _gamePalette[src[j] * 3 + 2]; dst += 3; } src += _screenData.pitch; @@ -728,9 +728,9 @@ void OpenGLGraphicsManager::refreshOverlay() { byte *dst = surface; for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { - dst[0] = _gamePalette[src[j] * 4]; - dst[1] = _gamePalette[src[j] * 4 + 1]; - dst[2] = _gamePalette[src[j] * 4 + 2]; + dst[0] = _gamePalette[src[j] * 3]; + dst[1] = _gamePalette[src[j] * 3 + 1]; + dst[2] = _gamePalette[src[j] * 3 + 2]; dst += 3; } src += _screenData.pitch; @@ -772,9 +772,9 @@ void OpenGLGraphicsManager::refreshCursor() { for (int i = 0; i < _cursorState.w * _cursorState.h; i++) { // Check for keycolor if (src[i] != _cursorKeyColor) { - dst[0] = palette[src[i] * 4]; - dst[1] = palette[src[i] * 4 + 1]; - dst[2] = palette[src[i] * 4 + 2]; + dst[0] = palette[src[i] * 3]; + dst[1] = palette[src[i] * 3 + 1]; + dst[2] = palette[src[i] * 3 + 2]; dst[3] = 255; } dst += 4; diff --git a/backends/graphics/sdl/sdl-graphics.cpp b/backends/graphics/sdl/sdl-graphics.cpp index 480cf2e795..15d896c57a 100644 --- a/backends/graphics/sdl/sdl-graphics.cpp +++ b/backends/graphics/sdl/sdl-graphics.cpp @@ -1337,11 +1337,10 @@ void SdlGraphicsManager::setPalette(const byte *colors, uint start, uint num) { const byte *b = colors; uint i; SDL_Color *base = _currentPalette + start; - for (i = 0; i < num; i++) { + for (i = 0; i < num; i++, b += 3) { base[i].r = b[0]; base[i].g = b[1]; base[i].b = b[2]; - b += 4; } if (start < _paletteDirtyStart) @@ -1365,10 +1364,9 @@ void SdlGraphicsManager::grabPalette(byte *colors, uint start, uint num) { const SDL_Color *base = _currentPalette + start; for (uint i = 0; i < num; ++i) { - colors[i * 4] = base[i].r; - colors[i * 4 + 1] = base[i].g; - colors[i * 4 + 2] = base[i].b; - colors[i * 4 + 3] = 0xFF; + colors[i * 3] = base[i].r; + colors[i * 3 + 1] = base[i].g; + colors[i * 3 + 2] = base[i].b; } } @@ -1377,11 +1375,10 @@ void SdlGraphicsManager::setCursorPalette(const byte *colors, uint start, uint n const byte *b = colors; uint i; SDL_Color *base = _cursorPalette + start; - for (i = 0; i < num; i++) { + for (i = 0; i < num; i++, b += 3) { base[i].r = b[0]; base[i].g = b[1]; base[i].b = b[2]; - b += 4; } _cursorPaletteDisabled = false; diff --git a/backends/platform/android/android.cpp b/backends/platform/android/android.cpp index efcee488a5..fe52936ad9 100644 --- a/backends/platform/android/android.cpp +++ b/backends/platform/android/android.cpp @@ -679,26 +679,12 @@ void OSystem_Android::setPalette(const byte* colors, uint start, uint num) { if (!_use_mouse_palette) _setCursorPalette(colors, start, num); - byte* palette = _game_texture->palette() + start*3; - do { - for (int i = 0; i < 3; ++i) - palette[i] = colors[i]; - palette += 3; - colors += 4; - } while (--num); + memcpy(_game_texture->palette() + start * 3, colors, num * 3); } void OSystem_Android::grabPalette(byte *colors, uint start, uint num) { ENTER("grabPalette(%p, %u, %u)", colors, start, num); - const byte* palette = _game_texture->palette_const() + start*3; - do { - for (int i = 0; i < 3; ++i) - colors[i] = palette[i]; - colors[3] = 0xff; // alpha - - palette += 3; - colors += 4; - } while (--num); + memcpy(colors, _game_texture->palette() + start * 3, num * 3); } void OSystem_Android::copyRectToScreen(const byte *buf, int pitch, @@ -934,13 +920,16 @@ void OSystem_Android::setMouseCursor(const byte *buf, uint w, uint h, // Update palette alpha based on keycolor byte* palette = _mouse_texture->palette(); - int i = 256; + + uint i = 256; do { palette[3] = 0xff; palette += 4; } while (--i); + palette = _mouse_texture->palette(); - palette[keycolor*4 + 3] = 0x00; + palette[keycolor * 4 + 3] = 0; + _mouse_texture->updateBuffer(0, 0, w, h, buf, w); _mouse_hotspot = Common::Point(hotspotX, hotspotY); @@ -949,14 +938,15 @@ void OSystem_Android::setMouseCursor(const byte *buf, uint w, uint h, void OSystem_Android::_setCursorPalette(const byte *colors, uint start, uint num) { - byte* palette = _mouse_texture->palette() + start*4; + byte* palette = _mouse_texture->palette() + start * 4; + do { for (int i = 0; i < 3; ++i) palette[i] = colors[i]; // Leave alpha untouched to preserve keycolor palette += 4; - colors += 4; + colors += 3; } while (--num); } diff --git a/backends/platform/wii/osystem_gfx.cpp b/backends/platform/wii/osystem_gfx.cpp index 4a925a60c9..8dc18464a8 100644 --- a/backends/platform/wii/osystem_gfx.cpp +++ b/backends/platform/wii/osystem_gfx.cpp @@ -326,19 +326,13 @@ void OSystem_Wii::setPalette(const byte *colors, uint start, uint num) { const byte *s = colors; u16 *d = _texGame.palette; - for (uint i = 0; i < num; ++i) { + for (uint i = 0; i < num; ++i, s +=3) d[start + i] = Graphics::RGBToColor<Graphics::ColorMasks<565> >(s[0], s[1], s[2]); - s += 4; - } gfx_tex_flush_palette(&_texGame); - s = colors; - d = _cursorPalette; - - for (uint i = 0; i < num; ++i) { + for (uint i = 0; i < num; ++i, s += 3) { d[start + i] = Graphics::ARGBToColor<Graphics::ColorMasks<3444> >(0xff, s[0], s[1], s[2]); - s += 4; } if (_cursorPaletteDisabled) { @@ -360,13 +354,11 @@ void OSystem_Wii::grabPalette(byte *colors, uint start, uint num) { byte *d = colors; u8 r, g, b; - for (uint i = 0; i < num; ++i) { + for (uint i = 0; i < num; ++i, d += 3) { Graphics::colorToRGB<Graphics::ColorMasks<565> >(s[start + i], r, g, b); d[0] = r; d[1] = g; d[2] = b; - d[3] = 0xff; - d += 4; } } @@ -391,10 +383,8 @@ void OSystem_Wii::setCursorPalette(const byte *colors, uint start, uint num) { const byte *s = colors; u16 *d = _texMouse.palette; - for (uint i = 0; i < num; ++i) { + for (uint i = 0; i < num; ++i, s += 3) d[start + i] = Graphics::ARGBToColor<Graphics::ColorMasks<3444> >(0xff, s[0], s[1], s[2]); - s += 4; - } _cursorPaletteDirty = true; } |