aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gui/ThemeEngine.cpp21
-rw-r--r--gui/ThemeEngine.h1
2 files changed, 18 insertions, 4 deletions
diff --git a/gui/ThemeEngine.cpp b/gui/ThemeEngine.cpp
index dcddce90bd..000ce21da9 100644
--- a/gui/ThemeEngine.cpp
+++ b/gui/ThemeEngine.cpp
@@ -362,6 +362,7 @@ bool ThemeEngine::init() {
// reset everything and reload the graphics
_initOk = false;
setGraphicsMode(_graphicsMode);
+ _overlayFormat = _system->getOverlayFormat();
if (_screen.pixels && _backBuffer.pixels) {
_initOk = true;
@@ -414,7 +415,21 @@ void ThemeEngine::clearAll() {
}
void ThemeEngine::refresh() {
+
+ // Flush all bitmaps if the overlay pixel format changed.
+ if (_overlayFormat != _system->getOverlayFormat()) {
+ for (ImagesMap::iterator i = _bitmaps.begin(); i != _bitmaps.end(); ++i) {
+ Graphics::Surface *surf = i->_value;
+ if (surf) {
+ surf->free();
+ delete surf;
+ }
+ }
+ _bitmaps.clear();
+ }
+
init();
+
if (_enabled) {
_system->showOverlay();
@@ -1040,8 +1055,7 @@ void ThemeEngine::drawChar(const Common::Rect &r, byte ch, const Graphics::Font
Common::Rect charArea = r;
charArea.clip(_screen.w, _screen.h);
- Graphics::PixelFormat format = _system->getOverlayFormat();
- uint32 color = format.RGBToColor(_texts[kTextDataDefault]->_color.r, _texts[kTextDataDefault]->_color.g, _texts[kTextDataDefault]->_color.b);
+ uint32 color = _overlayFormat.RGBToColor(_texts[kTextDataDefault]->_color.r, _texts[kTextDataDefault]->_color.g, _texts[kTextDataDefault]->_color.b);
restoreBackground(charArea);
font->drawChar(&_screen, ch, charArea.left, charArea.top, color);
@@ -1146,11 +1160,10 @@ bool ThemeEngine::createCursor(const Common::String &filename, int hotspotX, int
uint colorsFound = 0;
Common::HashMap<int, int> 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;
- format.colorToRGB(src[x], r, g, b);
+ _overlayFormat.colorToRGB(src[x], r, g, b);
const int col = (r << 16) | (g << 8) | b;
// Skip transparency (the transparent color actually is 0xFF00FF,
diff --git a/gui/ThemeEngine.h b/gui/ThemeEngine.h
index 164ac65a3d..49c8966a45 100644
--- a/gui/ThemeEngine.h
+++ b/gui/ThemeEngine.h
@@ -584,6 +584,7 @@ protected:
TextDrawData *_texts[kTextDataMAX];
ImagesMap _bitmaps;
+ Graphics::PixelFormat _overlayFormat;
/** List of all the dirty screens that must be blitted to the overlay. */
Common::List<Common::Rect> _dirtyScreen;