From edf9f249260b1fd4364f6727fa622991e81e8cf3 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Thu, 6 Nov 2008 15:02:50 +0000 Subject: Got rid of OSystem::colorToRGB and RGBToColor; added implementations for OSystem::getOverlayFormat to several ports (pending testing by the porters) svn-id: r34912 --- backends/platform/PalmOS/Src/base_gfx.cpp | 2 +- backends/platform/PalmOS/Src/be_base.h | 3 +-- backends/platform/PalmOS/Src/be_os5.h | 2 -- backends/platform/PalmOS/Src/be_zodiac.h | 2 -- backends/platform/PalmOS/Src/os5_gfx.cpp | 4 ++-- backends/platform/PalmOS/Src/os5_overlay.cpp | 10 ---------- backends/platform/PalmOS/Src/zodiac_gfx.cpp | 4 ++-- backends/platform/PalmOS/Src/zodiac_overlay.cpp | 10 ---------- backends/platform/dc/dc.h | 7 +------ backends/platform/ds/arm9/source/osystem_ds.h | 19 +------------------ backends/platform/gp2x/gp2x-common.h | 5 ----- backends/platform/gp2x/graphics.cpp | 8 -------- backends/platform/iphone/osys_iphone.cpp | 2 +- backends/platform/iphone/osys_iphone.h | 1 + backends/platform/null/null.cpp | 10 +--------- backends/platform/ps2/systemps2.cpp | 10 ---------- backends/platform/ps2/systemps2.h | 4 +--- backends/platform/psp/osys_psp.cpp | 10 ---------- backends/platform/psp/osys_psp.h | 2 -- backends/platform/sdl/graphics.cpp | 8 -------- backends/platform/sdl/sdl.h | 5 ----- backends/platform/wii/osystem.h | 4 +--- backends/platform/wii/osystem_gfx.cpp | 17 +++-------------- backends/platform/wince/wince-sdl.cpp | 2 +- common/system.cpp | 8 -------- common/system.h | 18 ------------------ engines/sword1/animation.cpp | 5 +++-- engines/sword2/animation.cpp | 8 +++++--- graphics/mpeg_player.cpp | 7 ++++--- graphics/thumbnail.cpp | 11 +++-------- gui/ThemeEngine.cpp | 8 +++++--- 31 files changed, 37 insertions(+), 179 deletions(-) diff --git a/backends/platform/PalmOS/Src/base_gfx.cpp b/backends/platform/PalmOS/Src/base_gfx.cpp index c96a258d52..cb40bb55e5 100644 --- a/backends/platform/PalmOS/Src/base_gfx.cpp +++ b/backends/platform/PalmOS/Src/base_gfx.cpp @@ -152,7 +152,7 @@ void OSystem_PalmBase::updateScreen() { void OSystem_PalmBase::clearScreen() { WinSetDrawWindow(WinGetDisplayWindow()); - WinSetBackColor(RGBToColor(0,0,0)); + WinSetBackColor(Graphics::RGBToColor >(0,0,0)); WinEraseWindow(); } diff --git a/backends/platform/PalmOS/Src/be_base.h b/backends/platform/PalmOS/Src/be_base.h index 03a9d56fb4..009c5a9997 100644 --- a/backends/platform/PalmOS/Src/be_base.h +++ b/backends/platform/PalmOS/Src/be_base.h @@ -230,8 +230,7 @@ public: void setPalette(const byte *colors, uint start, uint num); void grabPalette(byte *colors, uint start, uint num); - virtual OverlayColor RGBToColor(uint8 r, uint8 g, uint8 b) = 0; - virtual void colorToRGB(OverlayColor color, uint8 &r, uint8 &g, uint8 &b) = 0; + virtual Graphics::PixelFormat getOverlayFormat() const { return Graphics::createPixelFormat<565>(); } bool pollEvent(Common::Event &event); diff --git a/backends/platform/PalmOS/Src/be_os5.h b/backends/platform/PalmOS/Src/be_os5.h index 99d1dd9dc1..c56688b98f 100644 --- a/backends/platform/PalmOS/Src/be_os5.h +++ b/backends/platform/PalmOS/Src/be_os5.h @@ -181,8 +181,6 @@ public: virtual void clearOverlay(); virtual void grabOverlay(OverlayColor *buf, int pitch); virtual void copyRectToOverlay(const OverlayColor *buf, int pitch, int x, int y, int w, int h); - virtual OverlayColor RGBToColor(uint8 r, uint8 g, uint8 b); - virtual void colorToRGB(OverlayColor color, uint8 &r, uint8 &g, uint8 &b); void setWindowCaption(const char *caption); diff --git a/backends/platform/PalmOS/Src/be_zodiac.h b/backends/platform/PalmOS/Src/be_zodiac.h index 58e2ca88ac..28fcf29ddd 100644 --- a/backends/platform/PalmOS/Src/be_zodiac.h +++ b/backends/platform/PalmOS/Src/be_zodiac.h @@ -71,8 +71,6 @@ public: void clearOverlay(); void grabOverlay(OverlayColor *buf, int pitch); void copyRectToOverlay(const OverlayColor *buf, int pitch, int x, int y, int w, int h); - OverlayColor RGBToColor(uint8 r, uint8 g, uint8 b); - void colorToRGB(OverlayColor color, uint8 &r, uint8 &g, uint8 &b); }; #endif diff --git a/backends/platform/PalmOS/Src/os5_gfx.cpp b/backends/platform/PalmOS/Src/os5_gfx.cpp index 2d26419dff..c02e1f7db4 100644 --- a/backends/platform/PalmOS/Src/os5_gfx.cpp +++ b/backends/platform/PalmOS/Src/os5_gfx.cpp @@ -77,8 +77,8 @@ void OSystem_PalmOS5::load_gfx_mode() { __68K(PINSetInputTriggerState(pinInputTriggerDisabled)); } - gVars->indicator.on = RGBToColor(0,255,0); - gVars->indicator.off = RGBToColor(0,0,0); + gVars->indicator.on = Graphics::RGBToColor >(0,255,0); + gVars->indicator.off = Graphics::RGBToColor >(0,0,0); _overlayH = alloc_screen(_screenWidth, _screenHeight); _overlayP = (OverlayColor *)(BmpGetBits(WinGetBitmap(_overlayH))); diff --git a/backends/platform/PalmOS/Src/os5_overlay.cpp b/backends/platform/PalmOS/Src/os5_overlay.cpp index 5555c7ef08..2ffc082547 100644 --- a/backends/platform/PalmOS/Src/os5_overlay.cpp +++ b/backends/platform/PalmOS/Src/os5_overlay.cpp @@ -74,13 +74,3 @@ void OSystem_PalmOS5::copyRectToOverlay(const OverlayColor *buf, int pitch, int buf += pitch; } while (--h); } - -OverlayColor OSystem_PalmOS5::RGBToColor(uint8 r, uint8 g, uint8 b) { - return gfxMakeDisplayRGB(r, g, b); -} - -void OSystem_PalmOS5::colorToRGB(OverlayColor color, uint8 &r, uint8 &g, uint8 &b) { - r = ((color >> 8) & 0xF8); - g = ((color >> 3) & 0xFC); - b = ((color << 3) & 0xF8); -} diff --git a/backends/platform/PalmOS/Src/zodiac_gfx.cpp b/backends/platform/PalmOS/Src/zodiac_gfx.cpp index e7f7adb773..866ee086f7 100644 --- a/backends/platform/PalmOS/Src/zodiac_gfx.cpp +++ b/backends/platform/PalmOS/Src/zodiac_gfx.cpp @@ -71,8 +71,8 @@ void OSystem_PalmZodiac::load_gfx_mode() { SysSetOrientationTriggerState(sysOrientationTriggerDisabled); PINSetInputTriggerState(pinInputTriggerDisabled); - gVars->indicator.on = RGBToColor(0,255,0); - gVars->indicator.off = RGBToColor(0,0,0); + gVars->indicator.on = Graphics::RGBToColor >(0,255,0); + gVars->indicator.off = Graphics::RGBToColor >(0,0,0); _screenH = WinGetDisplayWindow(); _screenP = (byte *)BmpGetBits(WinGetBitmap(_screenH)); diff --git a/backends/platform/PalmOS/Src/zodiac_overlay.cpp b/backends/platform/PalmOS/Src/zodiac_overlay.cpp index 34390853fc..f8322e8fa5 100644 --- a/backends/platform/PalmOS/Src/zodiac_overlay.cpp +++ b/backends/platform/PalmOS/Src/zodiac_overlay.cpp @@ -65,13 +65,3 @@ void OSystem_PalmZodiac::copyRectToOverlay(const OverlayColor *buf, int pitch, i }; e = TwGfxDrawBitmap(_overlayP, &pos, &bmp); } - -OverlayColor OSystem_PalmZodiac::RGBToColor(uint8 r, uint8 g, uint8 b) { - return TwGfxMakeDisplayRGB(r, g, b); -} - -void OSystem_PalmZodiac::colorToRGB(OverlayColor color, uint8 &r, uint8 &g, uint8 &b) { - r = ((color >> 8) & 0xF8); - g = ((color >> 3) & 0xFC); - b = ((color << 3) & 0xF8); -} diff --git a/backends/platform/dc/dc.h b/backends/platform/dc/dc.h index 8b99457310..f8e16a4d4f 100644 --- a/backends/platform/dc/dc.h +++ b/backends/platform/dc/dc.h @@ -155,12 +155,7 @@ class OSystem_Dreamcast : public OSystem, public FilesystemFactory { void clearOverlay(); void grabOverlay(int16 *buf, int pitch); void copyRectToOverlay(const int16 *buf, int pitch, int x, int y, int w, int h); - OverlayColor RGBToColor(uint8 r, uint8 g, uint8 b) { return (0xf000|((r&0xf0)<<4)|(g&0xf0)|(b>>4); } - void colorToRGB(OverlayColor color, uint8 &r, uint8 &g, uint8 &b) { - r = ((color>>4)&0xf0)|((color>>8)&0x0f); - g = (color&0xf0)|((color>>4)&0x0f); - b = ((color<<4)&0xf0)|(color&0x0f); - } + virtual Graphics::PixelFormat getOverlayFormat() const { return Graphics::createPixelFormat<4444>(); } // Mutex handling MutexRef createMutex(); diff --git a/backends/platform/ds/arm9/source/osystem_ds.h b/backends/platform/ds/arm9/source/osystem_ds.h index 16c8f41491..27adf88198 100644 --- a/backends/platform/ds/arm9/source/osystem_ds.h +++ b/backends/platform/ds/arm9/source/osystem_ds.h @@ -113,9 +113,7 @@ public: virtual void copyRectToOverlay(const OverlayColor *buf, int pitch, int x, int y, int w, int h); virtual int16 getOverlayHeight(); virtual int16 getOverlayWidth(); - - inline virtual OverlayColor RGBToColor(uint8 r, uint8 g, uint8 b); - inline virtual void colorToRGB(OverlayColor color, uint8 &r, uint8 &g, uint8 &b); + virtual Graphics::PixelFormat getOverlayFormat() const { return Graphics::createPixelFormat<1555>(); } virtual bool showMouse(bool visible); @@ -190,19 +188,4 @@ static const OSystem::GraphicsMode s_supportedGraphicsModes[] = { {0, 0, 0}, }; -OverlayColor OSystem_DS::RGBToColor(uint8 r, uint8 g, uint8 b) -{ - return 0x8000 | (r >> 3) | ((g >> 3) << 5) | ((b >> 3) << 10); - //consolePrintf("rgbtocol\n"); - //return 0; -} - -void OSystem_DS::colorToRGB(OverlayColor color, uint8 &r, uint8 &g, uint8 &b) -{ - r = (color & 0x001F) << 3; - g = ((color & 0x03E0) >> 5) << 3; - b = ((color & 0x7C00) >> 10) << 3; - //consolePrintf("coltorgb\n"); -} - #endif diff --git a/backends/platform/gp2x/gp2x-common.h b/backends/platform/gp2x/gp2x-common.h index 063696548c..de305923a0 100644 --- a/backends/platform/gp2x/gp2x-common.h +++ b/backends/platform/gp2x/gp2x-common.h @@ -163,11 +163,6 @@ public: int16 getOverlayHeight() { return _overlayHeight; } int16 getOverlayWidth() { return _overlayWidth; } - // Methods that convert RGB to/from colors suitable for the overlay. - OverlayColor RGBToColor(uint8 r, uint8 g, uint8 b); - void colorToRGB(OverlayColor color, uint8 &r, uint8 &g, uint8 &b); - - const GraphicsMode *getSupportedGraphicsModes() const; int getDefaultGraphicsMode() const; bool setGraphicsMode(int mode); diff --git a/backends/platform/gp2x/graphics.cpp b/backends/platform/gp2x/graphics.cpp index 2f16cf7068..7fa0fddeb1 100644 --- a/backends/platform/gp2x/graphics.cpp +++ b/backends/platform/gp2x/graphics.cpp @@ -1160,14 +1160,6 @@ void OSystem_GP2X::copyRectToOverlay(const OverlayColor *buf, int pitch, int x, SDL_UnlockSurface(_overlayscreen); } -OverlayColor OSystem_GP2X::RGBToColor(uint8 r, uint8 g, uint8 b) { - return SDL_MapRGB(_overlayscreen->format, r, g, b); -} - -void OSystem_GP2X::colorToRGB(OverlayColor color, uint8 &r, uint8 &g, uint8 &b) { - SDL_GetRGB(color, _overlayscreen->format, &r, &g, &b); -} - #pragma mark - #pragma mark --- Mouse --- diff --git a/backends/platform/iphone/osys_iphone.cpp b/backends/platform/iphone/osys_iphone.cpp index 6ca5a52928..d5c126e73b 100644 --- a/backends/platform/iphone/osys_iphone.cpp +++ b/backends/platform/iphone/osys_iphone.cpp @@ -180,7 +180,7 @@ void OSystem_IPHONE::setPalette(const byte *colors, uint start, uint num) { const byte *b = colors; for (uint i = start; i < start + num; ++i) { - _palette[i] = RGBToColor(b[0], b[1], b[2]); + _palette[i] = Graphics::RGBToColor >(b[0], b[1], b[2]); b += 4; } diff --git a/backends/platform/iphone/osys_iphone.h b/backends/platform/iphone/osys_iphone.h index c743039860..c3d62b7c9c 100644 --- a/backends/platform/iphone/osys_iphone.h +++ b/backends/platform/iphone/osys_iphone.h @@ -143,6 +143,7 @@ public: virtual void copyRectToOverlay(const OverlayColor *buf, int pitch, int x, int y, int w, int h); virtual int16 getOverlayHeight(); virtual int16 getOverlayWidth(); + virtual Graphics::PixelFormat getOverlayFormat() const { return Graphics::createPixelFormat<565>(); } virtual bool showMouse(bool visible); diff --git a/backends/platform/null/null.cpp b/backends/platform/null/null.cpp index 610f1d3a42..456ee12539 100644 --- a/backends/platform/null/null.cpp +++ b/backends/platform/null/null.cpp @@ -91,9 +91,7 @@ public: virtual void copyRectToOverlay(const OverlayColor *buf, int pitch, int x, int y, int w, int h); virtual int16 getOverlayHeight(); virtual int16 getOverlayWidth(); - - virtual OverlayColor RGBToColor(uint8 r, uint8 g, uint8 b); - virtual void colorToRGB(OverlayColor color, uint8 &r, uint8 &g, uint8 &b); + virtual Graphics::PixelFormat getOverlayFormat() const { return Graphics::createPixelFormat<565>(); } virtual bool showMouse(bool visible); @@ -257,12 +255,6 @@ int16 OSystem_NULL::getOverlayWidth() { return getWidth(); } -OverlayColor OSystem_NULL::RGBToColor(uint8 r, uint8 g, uint8 b) { - return 0; -} - -void OSystem_NULL::colorToRGB(OverlayColor color, uint8 &r, uint8 &g, uint8 &b) { -} bool OSystem_NULL::showMouse(bool visible) { return true; diff --git a/backends/platform/ps2/systemps2.cpp b/backends/platform/ps2/systemps2.cpp index 85eb303e86..aac399ee23 100644 --- a/backends/platform/ps2/systemps2.cpp +++ b/backends/platform/ps2/systemps2.cpp @@ -641,16 +641,6 @@ bool OSystem_PS2::pollEvent(Common::Event &event) { return res; } -OverlayColor OSystem_PS2::RGBToColor(uint8 r, uint8 g, uint8 b) { - return (r >> 3) | ((g >> 3) << 5) | ((b >> 3) << 10); -} - -void OSystem_PS2::colorToRGB(OverlayColor color, uint8 &r, uint8 &g, uint8 &b) { - r = (color & 0x1F) << 3; - g = ((color >> 5) & 0x1F) << 3; - b = ((color >> 10) & 0x1F) << 3; -} - int16 OSystem_PS2::getHeight(void) { return _screen->getHeight(); } diff --git a/backends/platform/ps2/systemps2.h b/backends/platform/ps2/systemps2.h index 9539baf4f5..e4ac410caa 100644 --- a/backends/platform/ps2/systemps2.h +++ b/backends/platform/ps2/systemps2.h @@ -110,9 +110,7 @@ public: virtual Common::SeekableReadStream *openConfigFileForReading(); virtual Common::WriteStream *openConfigFileForWriting(); - virtual OverlayColor RGBToColor(uint8 r, uint8 g, uint8 b); - - virtual void colorToRGB(OverlayColor color, uint8 &r, uint8 &g, uint8 &b); + virtual Graphics::PixelFormat getOverlayFormat() const { return Graphics::createPixelFormat<555>(); } virtual Common::SaveFileManager *getSavefileManager(); virtual FilesystemFactory *getFilesystemFactory(); diff --git a/backends/platform/psp/osys_psp.cpp b/backends/platform/psp/osys_psp.cpp index 8670456e55..7f38e3c4bb 100644 --- a/backends/platform/psp/osys_psp.cpp +++ b/backends/platform/psp/osys_psp.cpp @@ -353,16 +353,6 @@ int16 OSystem_PSP::getOverlayHeight() { return _overlayHeight; } -OverlayColor OSystem_PSP::RGBToColor(uint8 r, uint8 g, uint8 b) { - return (((r >> 3) & 0x1F) | (((g >> 3) & 0x1F) << 5) | (((b >> 3) & 0x1F) << 10 ) ) | 0x8000; -} - -void OSystem_PSP::colorToRGB(OverlayColor color, uint8 &r, uint8 &g, uint8 &b) { - r = ((color & 0x1F) << 3); - g = (((color >> 5) & 0x1F) << 3); - b = (((color >> 10) & 0x1F) << 3); -} - void OSystem_PSP::grabPalette(byte *colors, uint start, uint num) { uint i; diff --git a/backends/platform/psp/osys_psp.h b/backends/platform/psp/osys_psp.h index 783bb87b9c..d91526e41c 100644 --- a/backends/platform/psp/osys_psp.h +++ b/backends/platform/psp/osys_psp.h @@ -107,8 +107,6 @@ public: virtual void copyRectToOverlay(const OverlayColor *buf, int pitch, int x, int y, int w, int h); virtual int16 getOverlayHeight(); virtual int16 getOverlayWidth(); - virtual OverlayColor RGBToColor(uint8 r, uint8 g, uint8 b); - virtual void colorToRGB(OverlayColor color, uint8 &r, uint8 &g, uint8 &b); virtual void grabPalette(byte *colors, uint start, uint num); virtual Graphics::PixelFormat getOverlayFormat() const { return Graphics::createPixelFormat<1555>(); } diff --git a/backends/platform/sdl/graphics.cpp b/backends/platform/sdl/graphics.cpp index 1dde92af72..c2a6285001 100644 --- a/backends/platform/sdl/graphics.cpp +++ b/backends/platform/sdl/graphics.cpp @@ -1239,14 +1239,6 @@ void OSystem_SDL::copyRectToOverlay(const OverlayColor *buf, int pitch, int x, i SDL_UnlockSurface(_overlayscreen); } -OverlayColor OSystem_SDL::RGBToColor(uint8 r, uint8 g, uint8 b) { - return SDL_MapRGB(_overlayscreen->format, r, g, b); -} - -void OSystem_SDL::colorToRGB(OverlayColor color, uint8 &r, uint8 &g, uint8 &b) { - SDL_GetRGB(color, _overlayscreen->format, &r, &g, &b); -} - #pragma mark - #pragma mark --- Mouse --- diff --git a/backends/platform/sdl/sdl.h b/backends/platform/sdl/sdl.h index cb625f130c..6005b14e1c 100644 --- a/backends/platform/sdl/sdl.h +++ b/backends/platform/sdl/sdl.h @@ -182,11 +182,6 @@ public: virtual int16 getOverlayHeight() { return _overlayHeight; } virtual int16 getOverlayWidth() { return _overlayWidth; } - // Methods that convert RGB to/from colors suitable for the overlay. - virtual OverlayColor RGBToColor(uint8 r, uint8 g, uint8 b); - virtual void colorToRGB(OverlayColor color, uint8 &r, uint8 &g, uint8 &b); - - virtual const GraphicsMode *getSupportedGraphicsModes() const; virtual int getDefaultGraphicsMode() const; virtual bool setGraphicsMode(int mode); diff --git a/backends/platform/wii/osystem.h b/backends/platform/wii/osystem.h index f17644ba1b..bedfadd934 100644 --- a/backends/platform/wii/osystem.h +++ b/backends/platform/wii/osystem.h @@ -136,9 +136,7 @@ public: int x, int y, int w, int h); virtual int16 getOverlayWidth(); virtual int16 getOverlayHeight(); - - virtual OverlayColor RGBToColor(uint8 r, uint8 g, uint8 b); - virtual void colorToRGB(OverlayColor color, uint8 &r, uint8 &g, uint8 &b); + virtual Graphics::PixelFormat getOverlayFormat() const { return Graphics::createPixelFormat<565>(); } virtual bool showMouse(bool visible); diff --git a/backends/platform/wii/osystem_gfx.cpp b/backends/platform/wii/osystem_gfx.cpp index f6406a88ed..9ce70e70c3 100644 --- a/backends/platform/wii/osystem_gfx.cpp +++ b/backends/platform/wii/osystem_gfx.cpp @@ -197,7 +197,7 @@ int16 OSystem_Wii::getHeight() { void OSystem_Wii::setPalette(const byte *colors, uint start, uint num) { const byte *p = colors; for (uint i = 0; i < num; ++i) { - _palette[start + i] = RGBToColor(p[0], p[1], p[2]); + _palette[start + i] = Graphics::RGBToColor >(p[0], p[1], p[2]); p += 4; } } @@ -206,7 +206,7 @@ void OSystem_Wii::grabPalette(byte *colors, uint start, uint num) { byte *p = colors; u8 r, g, b; for (uint i = 0; i < num; ++i) { - colorToRGB(_palette[start + i], r, g, b); + Graphics::colorToRGB >(_palette[start + i], r, g, b); p[0] = r; p[1] = g; p[2] = b; @@ -218,7 +218,7 @@ void OSystem_Wii::grabPalette(byte *colors, uint start, uint num) { void OSystem_Wii::setCursorPalette(const byte *colors, uint start, uint num) { const byte *p = colors; for (uint i = 0; i < num; ++i) { - _cursorPalette[start + i] = RGBToColor(p[0], p[1], p[2]); + _cursorPalette[start + i] = Graphics::RGBToColor >(p[0], p[1], p[2]); p += 4; } @@ -443,17 +443,6 @@ int16 OSystem_Wii::getOverlayHeight() { return _overlayHeight; } -OverlayColor OSystem_Wii::RGBToColor(uint8 r, uint8 g, uint8 b) { - return (((r >> 3) & 0x1f) << 11) | (((g >> 2) & 0x3f) << 5 ) | - ((b >> 3) & 0x1f); -} - -void OSystem_Wii::colorToRGB(OverlayColor color, uint8 &r, uint8 &g, uint8 &b) { - r = ((color >> 11) & 0x1f) << 3; - g = ((color >> 5) & 0x3f) << 2; - b = (color & 0x1f) << 3; -} - bool OSystem_Wii::showMouse(bool visible) { bool last = _mouseVisible; _mouseVisible = visible; diff --git a/backends/platform/wince/wince-sdl.cpp b/backends/platform/wince/wince-sdl.cpp index f09a483086..45935d1696 100644 --- a/backends/platform/wince/wince-sdl.cpp +++ b/backends/platform/wince/wince-sdl.cpp @@ -1973,7 +1973,7 @@ void OSystem_WINCE3::internDrawMouse() { *bak++ = *(uint16 *)dst; color = *src++; if (color != 0xFF) // 0xFF = transparent, don't draw - *(uint16 *)dst = RGBToColor(_currentPalette[color].r, _currentPalette[color].g, _currentPalette[color].b); + *(uint16 *)dst = SDL_MapRGB(_overlayscreen->format, _currentPalette[color].r, _currentPalette[color].g, _currentPalette[color].b); dst += 2; width--; } diff --git a/common/system.cpp b/common/system.cpp index 1c9f0cd352..e7dee4ced6 100644 --- a/common/system.cpp +++ b/common/system.cpp @@ -61,14 +61,6 @@ bool OSystem::setGraphicsMode(const char *name) { return false; } -OverlayColor OSystem::RGBToColor(uint8 r, uint8 g, uint8 b) { - return Graphics::RGBToColor >(r, g, b); -} - -void OSystem::colorToRGB(OverlayColor color, uint8 &r, uint8 &g, uint8 &b) { - Graphics::colorToRGB >(color, r, g, b); -} - void OSystem::displayMessageOnOSD(const char *msg) { // Display the message for 1.5 seconds GUI::TimedMessageDialog dialog(msg, 1500); diff --git a/common/system.h b/common/system.h index c24ca2f343..a6880e5423 100644 --- a/common/system.h +++ b/common/system.h @@ -617,24 +617,6 @@ public: */ virtual int16 getOverlayWidth() { return getWidth(); } - /** - * Convert the given RGB triplet into an OverlayColor. A OverlayColor can - * be 8bit, 16bit or 32bit, depending on the target system. The default - * implementation generates a 16 bit color value, in the 565 format - * (that is, 5 bits red, 6 bits green, 5 bits blue). - * @see colorToRGB - */ - virtual OverlayColor RGBToColor(uint8 r, uint8 g, uint8 b); - - /** - * Convert the given OverlayColor into a RGB triplet. An OverlayColor can - * be 8bit, 16bit or 32bit, depending on the target system. The default - * implementation takes a 16 bit color value and assumes it to be in 565 format - * (that is, 5 bits red, 6 bits green, 5 bits blue). - * @see RGBToColor - */ - virtual void colorToRGB(OverlayColor color, uint8 &r, uint8 &g, uint8 &b); - //@} diff --git a/engines/sword1/animation.cpp b/engines/sword1/animation.cpp index a033abbc3d..c0cd85a7c2 100644 --- a/engines/sword1/animation.cpp +++ b/engines/sword1/animation.cpp @@ -555,9 +555,10 @@ bool MoviePlayerMPEG::initOverlays(uint32 id) { _logoOvls[fcnt][cnt] = _logoOvls[fcnt - 1][cnt]; } uint8 *pal = ovlFile.fetchFile(12); - _introPal = (OverlayColor*)malloc(256 * sizeof(OverlayColor)); + _introPal = (OverlayColor *)malloc(256 * sizeof(OverlayColor)); + Graphics::PixelFormat format = _system->getOverlayFormat(); for (uint16 cnt = 0; cnt < 256; cnt++) - _introPal[cnt] = _system->RGBToColor(pal[cnt * 3 + 0], pal[cnt * 3 + 1], pal[cnt * 3 + 2]); + _introPal[cnt] = Graphics::RGBToColor(pal[cnt * 3 + 0], pal[cnt * 3 + 1], pal[cnt * 3 + 2], format); } return true; diff --git a/engines/sword2/animation.cpp b/engines/sword2/animation.cpp index fb5642a816..1452cc61dc 100644 --- a/engines/sword2/animation.cpp +++ b/engines/sword2/animation.cpp @@ -654,8 +654,9 @@ void AnimationState::drawTextObject(SpriteInfo *s, byte *src) { OverlayColor *dst = _overlay + textY * moviePitch + textX; - OverlayColor pen = _sys->RGBToColor(255, 255, 255); - OverlayColor border = _sys->RGBToColor(0, 0, 0); + Graphics::PixelFormat format = _sys->getOverlayFormat(); + OverlayColor pen = Graphics::RGBToColor(255, 255, 255, format); + OverlayColor border = Graphics::RGBToColor(0, 0, 0, format); // TODO: Use the AdvMame scalers for the text? Pre-scale it? @@ -702,7 +703,8 @@ void AnimationState::clearFrame() { #ifdef BACKEND_8BIT memset(_vm->_screen->getScreen(), 0, _movieWidth * _movieHeight); #else - OverlayColor black = _sys->RGBToColor(0, 0, 0); + Graphics::PixelFormat format = _sys->getOverlayFormat(); + OverlayColor black = Graphics::RGBToColor(0, 0, 0, format); for (int i = 0; i < _movieScale * _movieWidth * _movieScale * _movieHeight; i++) _overlay[i] = black; diff --git a/graphics/mpeg_player.cpp b/graphics/mpeg_player.cpp index 3c0fd08cb3..7432887360 100644 --- a/graphics/mpeg_player.cpp +++ b/graphics/mpeg_player.cpp @@ -389,10 +389,11 @@ void BaseAnimationState::buildLookup() { } // Set up entries 0-255 in rgb-to-pixel value tables. + Graphics::PixelFormat format = _sys->getOverlayFormat(); for (i = 0; i < 256; i++) { - r_2_pix_alloc[i + 256] = _sys->RGBToColor(i, 0, 0); - g_2_pix_alloc[i + 256] = _sys->RGBToColor(0, i, 0); - b_2_pix_alloc[i + 256] = _sys->RGBToColor(0, 0, i); + r_2_pix_alloc[i + 256] = Graphics::RGBToColor(i, 0, 0, format); + g_2_pix_alloc[i + 256] = Graphics::RGBToColor(0, i, 0, format); + b_2_pix_alloc[i + 256] = Graphics::RGBToColor(0, 0, i, format); } // Spread out the values we have to the rest of the array so that we do diff --git a/graphics/thumbnail.cpp b/graphics/thumbnail.cpp index 905fea3d93..709ba9ea54 100644 --- a/graphics/thumbnail.cpp +++ b/graphics/thumbnail.cpp @@ -42,12 +42,6 @@ struct ThumbnailHeader { #define ThumbnailHeaderSize (4+4+1+2+2+1) -inline void colorToRGB(uint16 color, uint8 &r, uint8 &g, uint8 &b) { - r = (((color >> 11) & 0x1F) << 3); - g = (((color >> 5) & 0x3F) << 2); - b = ((color&0x1F) << 3); -} - bool loadHeader(Common::SeekableReadStream &in, ThumbnailHeader &header, bool outputWarnings) { header.type = in.readUint32BE(); // We also accept the bad 'BMHT' header here, for the sake of compatibility @@ -114,13 +108,14 @@ bool loadThumbnail(Common::SeekableReadStream &in, Graphics::Surface &to) { to.create(header.width, header.height, sizeof(OverlayColor)); OverlayColor *pixels = (OverlayColor *)to.pixels; + Graphics::PixelFormat format = g_system->getOverlayFormat(); for (int y = 0; y < to.h; ++y) { for (int x = 0; x < to.w; ++x) { uint8 r, g, b; - colorToRGB(in.readUint16BE(), r, g, b); + colorToRGB >(in.readUint16BE(), r, g, b); // converting to current OSystem Color - *pixels++ = g_system->RGBToColor(r, g, b); + *pixels++ = Graphics::RGBToColor(r, g, b, format); } } diff --git a/gui/ThemeEngine.cpp b/gui/ThemeEngine.cpp index cbcd32fd4c..20638b827d 100644 --- a/gui/ThemeEngine.cpp +++ b/gui/ThemeEngine.cpp @@ -290,7 +290,7 @@ void ThemeEngine::clearAll() { return; _system->clearOverlay(); - _system->grabOverlay((OverlayColor*)_screen->pixels, _screen->w); + _system->grabOverlay((OverlayColor *)_screen->pixels, _screen->w); } void ThemeEngine::refresh() { @@ -941,7 +941,8 @@ void ThemeEngine::drawChar(const Common::Rect &r, byte ch, const Graphics::Font Common::Rect charArea = r; charArea.clip(_screen->w, _screen->h); - uint32 color = _system->RGBToColor(_texts[kTextDataDefault]->_color.r, _texts[kTextDataDefault]->_color.g, _texts[kTextDataDefault]->_color.b); + Graphics::PixelFormat format = _system->getOverlayFormat(); + uint32 color = Graphics::RGBToColor(_texts[kTextDataDefault]->_color.r, _texts[kTextDataDefault]->_color.g, _texts[kTextDataDefault]->_color.b, format); restoreBackground(charArea); font->drawChar(_screen, ch, charArea.left, charArea.top, color); @@ -1053,10 +1054,11 @@ bool ThemeEngine::createCursor(const Common::String &filename, int hotspotX, int uint colorsFound = 0; Common::HashMap colorToIndex; const OverlayColor *src = (const OverlayColor*)cursor->pixels; + Graphics::PixelFormat format = _system->getOverlayFormat(); for (uint y = 0; y < _cursorHeight; ++y) { for (uint x = 0; x < _cursorWidth; ++x) { byte r, g, b; - _system->colorToRGB(src[x], r, g, b); + Graphics::colorToRGB(src[x], r, g, b, format); const int col = (r << 16) | (g << 8) | b; // Skip transparency (the transparent color actually is 0xFF00FF, -- cgit v1.2.3