From 969a33a32dc331ec8d89da056e584a68974dfeec Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Wed, 20 Jun 2012 18:39:03 +0200 Subject: GUI: Allow GUI cursor creation to work with abitrary 2/4Bpp formats. --- gui/ThemeEngine.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'gui') diff --git a/gui/ThemeEngine.cpp b/gui/ThemeEngine.cpp index 0f8b449b58..2ba45a4bc3 100644 --- a/gui/ThemeEngine.cpp +++ b/gui/ThemeEngine.cpp @@ -1320,22 +1320,31 @@ bool ThemeEngine::createCursor(const Common::String &filename, int hotspotX, int memset(_cursor, 0xFF, sizeof(byte) * _cursorWidth * _cursorHeight); // the transparent color is 0xFF00FF - const int colTransparent = _overlayFormat.RGBToColor(0xFF, 0, 0xFF); + const uint32 colTransparent = _overlayFormat.RGBToColor(0xFF, 0, 0xFF); // Now, scan the bitmap. We have to convert it from 16 bit color mode // to 8 bit mode, and have to create a suitable palette on the fly. uint colorsFound = 0; Common::HashMap colorToIndex; - const OverlayColor *src = (const OverlayColor *)cursor->getPixels(); + const byte *src = (const byte *)cursor->getPixels(); for (uint y = 0; y < _cursorHeight; ++y) { for (uint x = 0; x < _cursorWidth; ++x) { + uint32 color = colTransparent; byte r, g, b; + if (cursor->format.bytesPerPixel == 2) { + color = READ_UINT16(src); + } else if (cursor->format.bytesPerPixel == 4) { + color = READ_UINT32(src); + } + + src += cursor->format.bytesPerPixel; + // Skip transparency - if (src[x] == colTransparent) + if (color == colTransparent) continue; - _overlayFormat.colorToRGB(src[x], r, g, b); + cursor->format.colorToRGB(color, r, g, b); const int col = (r << 16) | (g << 8) | b; // If there is no entry yet for this color in the palette: Add one @@ -1357,7 +1366,6 @@ bool ThemeEngine::createCursor(const Common::String &filename, int hotspotX, int const int index = colorToIndex[col]; _cursor[y * _cursorWidth + x] = index; } - src += _cursorWidth; } _useCursor = true; -- cgit v1.2.3 From f545a2f08fc8989fa22726ce0b74e03ece099300 Mon Sep 17 00:00:00 2001 From: Narek Mailian Date: Thu, 1 Aug 2013 01:38:22 +0200 Subject: GUI: Change name of GUI-renderers to remove "16-bit" --- gui/ThemeEngine.cpp | 12 ++++++------ gui/ThemeEngine.h | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'gui') diff --git a/gui/ThemeEngine.cpp b/gui/ThemeEngine.cpp index 2ba45a4bc3..b7199fbf68 100644 --- a/gui/ThemeEngine.cpp +++ b/gui/ThemeEngine.cpp @@ -343,9 +343,9 @@ ThemeEngine::~ThemeEngine() { *********************************************************/ const ThemeEngine::Renderer ThemeEngine::_rendererModes[] = { { _s("Disabled GFX"), _sc("Disabled GFX", "lowres"), "none", kGfxDisabled }, - { _s("Standard Renderer (16bpp)"), _s("Standard (16bpp)"), "normal_16bpp", kGfxStandard16bit }, + { _s("Standard Renderer"), _s("Standard"), "normal", kGfxStandard }, #ifndef DISABLE_FANCY_THEMES - { _s("Antialiased Renderer (16bpp)"), _s("Antialiased (16bpp)"), "aa_16bpp", kGfxAntialias16bit } + { _s("Antialiased Renderer"), _s("Antialiased"), "antialias", kGfxAntialias } #endif }; @@ -353,9 +353,9 @@ const uint ThemeEngine::_rendererModesSize = ARRAYSIZE(ThemeEngine::_rendererMod const ThemeEngine::GraphicsMode ThemeEngine::_defaultRendererMode = #ifndef DISABLE_FANCY_THEMES - ThemeEngine::kGfxAntialias16bit; + ThemeEngine::kGfxAntialias; #else - ThemeEngine::kGfxStandard16bit; + ThemeEngine::kGfxStandard; #endif ThemeEngine::GraphicsMode ThemeEngine::findMode(const Common::String &cfg) { @@ -494,9 +494,9 @@ void ThemeEngine::disable() { void ThemeEngine::setGraphicsMode(GraphicsMode mode) { switch (mode) { - case kGfxStandard16bit: + case kGfxStandard: #ifndef DISABLE_FANCY_THEMES - case kGfxAntialias16bit: + case kGfxAntialias: #endif _bytesPerPixel = sizeof(uint16); break; diff --git a/gui/ThemeEngine.h b/gui/ThemeEngine.h index 160ceb3259..c0e47a19e6 100644 --- a/gui/ThemeEngine.h +++ b/gui/ThemeEngine.h @@ -250,8 +250,8 @@ public: */ enum GraphicsMode { kGfxDisabled = 0, ///< No GFX - kGfxStandard16bit, ///< 2BPP with the standard (aliased) renderer. - kGfxAntialias16bit ///< 2BPP with the optimized AA renderer. + kGfxStandard, ///< Standard (aliased) renderer. + kGfxAntialias ///< Optimized AA renderer. }; /** Constant value to expand dirty rectangles, to make sure they are fully copied */ -- cgit v1.2.3 From 1f1d35bd3d31fe3430b9b5227b6127cfd52e52a2 Mon Sep 17 00:00:00 2001 From: Narek Mailian Date: Mon, 5 Aug 2013 17:59:36 +0200 Subject: GRAPHICS: Allow VectorRenderer and ThemeEngine to init with 4BPP --- gui/ThemeEngine.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'gui') diff --git a/gui/ThemeEngine.cpp b/gui/ThemeEngine.cpp index b7199fbf68..561c0244a2 100644 --- a/gui/ThemeEngine.cpp +++ b/gui/ThemeEngine.cpp @@ -498,9 +498,13 @@ void ThemeEngine::setGraphicsMode(GraphicsMode mode) { #ifndef DISABLE_FANCY_THEMES case kGfxAntialias: #endif - _bytesPerPixel = sizeof(uint16); - break; - + if (g_system->getOverlayFormat().bytesPerPixel == 4) { + _bytesPerPixel = sizeof(uint32); + break; + } else if (g_system->getOverlayFormat().bytesPerPixel == 2) { + _bytesPerPixel = sizeof(uint16); + break; + } default: error("Invalid graphics mode"); } -- cgit v1.2.3