aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gui/ThemeRenderer.cpp47
-rw-r--r--gui/ThemeRenderer.h19
-rw-r--r--gui/newgui.cpp23
-rw-r--r--gui/theme.h1
4 files changed, 42 insertions, 48 deletions
diff --git a/gui/ThemeRenderer.cpp b/gui/ThemeRenderer.cpp
index 9b3d115576..10736a033f 100644
--- a/gui/ThemeRenderer.cpp
+++ b/gui/ThemeRenderer.cpp
@@ -77,7 +77,7 @@ const char *ThemeRenderer::kDrawDataStrings[] = {
ThemeRenderer::ThemeRenderer(Common::String themeName, GraphicsMode mode) :
_vectorRenderer(0), _system(0), _graphicsMode(kGfxDisabled),
_screen(0), _backBuffer(0), _bytesPerPixel(0), _initOk(false),
- _themeOk(false), _enabled(false), _dialogCount(0), _cachedDialog(0) {
+ _themeOk(false), _enabled(false), _buffering(false) {
_system = g_system;
_parser = new ThemeParser(this);
@@ -214,9 +214,16 @@ bool ThemeRenderer::addDrawData(DrawData data_id, bool cached) {
_widgets[data_id] = new WidgetDrawData;
_widgets[data_id]->_cached = cached;
+ _widgets[data_id]->_buffer = false;
_widgets[data_id]->_surfaceCache = 0;
_widgets[data_id]->_hasText = false;
+ // TODO: set this only when needed
+ // possibly add an option to the parser to set this
+ // on each drawdata...
+ if (data_id >= kDDMainDialogBackground && data_id <= kDDWidgetBackgroundSlider)
+ _widgets[data_id]->_buffer = true;
+
return true;
}
@@ -303,7 +310,11 @@ void ThemeRenderer::drawDD(DrawData type, const Common::Rect &r, uint32 dynamicD
extendedRect.right += _widgets[type]->_backgroundOffset;
extendedRect.bottom += _widgets[type]->_backgroundOffset;
- restoreBackground(extendedRect);
+ if (_buffering && _widgets[type]->_buffer)
+ _vectorRenderer->setSurface(_backBuffer);
+ else
+ restoreBackground(extendedRect);
+
addDirtyRect(extendedRect);
if (isWidgetCached(type, r)) {
@@ -313,6 +324,11 @@ void ThemeRenderer::drawDD(DrawData type, const Common::Rect &r, uint32 dynamicD
step != _widgets[type]->_steps.end(); ++step)
_vectorRenderer->drawStep(r, *step, dynamicData);
}
+
+ if (_buffering && _widgets[type]->_buffer) {
+ _vectorRenderer->setSurface(_screen);
+ memcpy(_screen->pixels, _backBuffer->pixels, _screen->w * _screen->h * _screen->bytesPerPixel);
+ }
}
void ThemeRenderer::drawDDText(DrawData type, const Common::Rect &r, const Common::String &text) {
@@ -336,7 +352,7 @@ void ThemeRenderer::calcBackgroundOffset(DrawData type) {
}
void ThemeRenderer::restoreBackground(Common::Rect r, bool special) {
-/* const OverlayColor *src = (const OverlayColor*)_backBuffer->getBasePtr(r.left, r.top);
+ const OverlayColor *src = (const OverlayColor*)_backBuffer->getBasePtr(r.left, r.top);
OverlayColor *dst = (OverlayColor*)_screen->getBasePtr(r.left, r.top);
int h = r.height();
@@ -345,10 +361,10 @@ void ThemeRenderer::restoreBackground(Common::Rect r, bool special) {
memcpy(dst, src, w * sizeof(OverlayColor));
src += _backBuffer->w;
dst += _screen->w;
- }*/
+ }
- debugWidgetPosition("", r);
- printf(" BG_RESTORE ");
+// debugWidgetPosition("", r);
+// printf(" BG_RESTORE ");
}
void ThemeRenderer::drawButton(const Common::Rect &r, const Common::String &str, WidgetStateInfo state, uint16 hints) {
@@ -537,24 +553,11 @@ void ThemeRenderer::renderDirtyScreen() {
_dirtyScreen.clear();
}
-void ThemeRenderer::openDialog(bool top) {
- if (_dialogCount++ == 0)
- return;
+void ThemeRenderer::openDialog(bool doBuffer) {
+ if (doBuffer)
+ _buffering = true;
- _cachedDialog = _dialogCount - 1;
memcpy(_backBuffer->pixels, _screen->pixels, _screen->w * _screen->h * _screen->bytesPerPixel);
}
-bool ThemeRenderer::closeDialog() {
- assert(_dialogCount);
-
- _dialogCount--;
-
- if (_dialogCount != _cachedDialog)
- return false;
-
- memcpy(_screen->pixels, _backBuffer->pixels, _screen->w * _screen->h * _screen->bytesPerPixel);
- return true;
-}
-
} // end of namespace GUI.
diff --git a/gui/ThemeRenderer.h b/gui/ThemeRenderer.h
index 11728f8e6e..347cbafcc9 100644
--- a/gui/ThemeRenderer.h
+++ b/gui/ThemeRenderer.h
@@ -56,6 +56,7 @@ struct WidgetDrawData {
/** Sets whether the widget is cached beforehand. */
bool _cached;
+ bool _buffer;
/** Texture where the cached widget is stored. */
Graphics::Surface *_surfaceCache;
@@ -156,17 +157,12 @@ public:
void enable();
void disable();
- void closeAllDialogs() {
- _dialogCount = 0;
- _cachedDialog = 0;
- }
+ void closeAllDialogs() {}
-
- void updateScreen(); //{}
+ void updateScreen();
void resetDrawArea() {}
- void openDialog(bool top);// {}
- bool closeDialog();// {}
+ void openDialog(bool top);
/** Font management */
const Graphics::Font *getFont(FontStyle font) const { return _font; }
@@ -220,6 +216,10 @@ public:
bool loadTheme(Common::String themeName);
void setGraphicsMode(GraphicsMode mode);
+ void finishBuffering() {
+ _buffering = false;
+ }
+
protected:
template<typename PixelType> void screenInit(bool backBuffer);
@@ -310,8 +310,7 @@ protected:
Graphics::Surface *_screen;
Graphics::Surface *_backBuffer;
- uint32 _dialogCount;
- uint32 _cachedDialog;
+ bool _buffering;
int _bytesPerPixel;
GraphicsMode _graphicsMode;
diff --git a/gui/newgui.cpp b/gui/newgui.cpp
index f3734c6ee0..c4fafe7e22 100644
--- a/gui/newgui.cpp
+++ b/gui/newgui.cpp
@@ -192,37 +192,28 @@ void NewGui::redraw() {
switch (_redrawStatus) {
case kRedrawCloseDialog:
- printf("Dialog closed!\n");
- if (_theme->closeDialog())
- break;
-
case kRedrawFull:
_theme->clearAll();
_theme->closeAllDialogs();
for (i = 0; i < _dialogStack.size(); i++) {
- if ((i == _dialogStack.size() - 2) && !_dialogStack[i + 1]->dimsInactive())
- _theme->openDialog(true);
- else if ((i != (_dialogStack.size() - 1)) || !_dialogStack[i]->dimsInactive())
- _theme->openDialog(false);
- else
- _theme->openDialog(true);
-
+ _theme->openDialog(true);
_dialogStack[i]->drawDialog();
}
break;
- case kRedrawTopDialog:
- _dialogStack.top()->drawDialog();
- printf("Top dialog redraw!\n");
- break;
-
case kRedrawOpenDialog:
_theme->openDialog(true);
_dialogStack.top()->drawDialog();
+ _theme->finishBuffering();
printf("Dialog opened!\n");
break;
+ case kRedrawTopDialog:
+ _dialogStack.top()->drawDialog();
+ printf("Top dialog redraw!\n");
+ break;
+
default:
return;
}
diff --git a/gui/theme.h b/gui/theme.h
index 91f59d961c..a55f04b115 100644
--- a/gui/theme.h
+++ b/gui/theme.h
@@ -251,6 +251,7 @@ public:
* the dialog stack from scratch.
*/
virtual bool closeDialog() { return false; }
+ virtual void finishBuffering() {}
/**
* Clear the complete GUI screen.