aboutsummaryrefslogtreecommitdiff
path: root/backends/graphics
diff options
context:
space:
mode:
authorJohannes Schickel2011-02-19 21:42:34 +0100
committerJohannes Schickel2011-02-19 21:46:45 +0100
commite21d6e0d1120e917a4a019a4070ec4db5e988b9b (patch)
tree1142828b72ccf17d513c621e108d749f148fd32b /backends/graphics
parent32d0e4c15fb33f80db194087850466664a43516a (diff)
parentb26f30b98793c522265a3eeb48fb3b41034663c6 (diff)
downloadscummvm-rg350-e21d6e0d1120e917a4a019a4070ec4db5e988b9b.tar.gz
scummvm-rg350-e21d6e0d1120e917a4a019a4070ec4db5e988b9b.tar.bz2
scummvm-rg350-e21d6e0d1120e917a4a019a4070ec4db5e988b9b.zip
Merge branch 'osystem-palette' of https://github.com/lordhoto/scummvm into master
Conflicts: backends/platform/android/android.cpp engines/sci/graphics/screen.cpp engines/sci/graphics/transitions.cpp
Diffstat (limited to 'backends/graphics')
-rw-r--r--backends/graphics/default-palette.h6
-rw-r--r--backends/graphics/opengl/opengl-graphics.cpp28
-rw-r--r--backends/graphics/sdl/sdl-graphics.cpp13
3 files changed, 22 insertions, 25 deletions
diff --git a/backends/graphics/default-palette.h b/backends/graphics/default-palette.h
index 6e3a75350e..12436aae51 100644
--- a/backends/graphics/default-palette.h
+++ b/backends/graphics/default-palette.h
@@ -38,7 +38,7 @@
*/
class DefaultPaletteManager : public PaletteManager {
protected:
- byte _palette[4 * 256];
+ byte _palette[3 * 256];
/**
* Subclasses should only implement this method and none of the others.
@@ -51,12 +51,12 @@ protected:
public:
void setPalette(const byte *colors, uint start, uint num) {
assert(start + num <= 256);
- memcpy(_palette + 4 * start, colors, 4 * num);
+ memcpy(_palette + 3 * start, colors, 3 * num);
setPaletteIntern(colors, start, num);
}
void grabPalette(byte *colors, uint start, uint num) {
assert(start + num <= 256);
- memcpy(colors, _palette + 4 * start, 4 * num);
+ memcpy(colors, _palette + 3 * start, 3 * num);
}
};
diff --git a/backends/graphics/opengl/opengl-graphics.cpp b/backends/graphics/opengl/opengl-graphics.cpp
index a1b2e00f51..beac2f6d3e 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;