diff options
author | Vicent Marti | 2008-06-29 12:08:53 +0000 |
---|---|---|
committer | Vicent Marti | 2008-06-29 12:08:53 +0000 |
commit | f1173f52a24de56fd7ad91e5806917db8c11ee63 (patch) | |
tree | 9ebc022d02428390e3f8dd3dbc0f35182abd816f | |
parent | 0e4cd6fc8ea9d72f4d07dbfeabcabf50d6d1c2bd (diff) | |
download | scummvm-rg350-f1173f52a24de56fd7ad91e5806917db8c11ee63.tar.gz scummvm-rg350-f1173f52a24de56fd7ad91e5806917db8c11ee63.tar.bz2 scummvm-rg350-f1173f52a24de56fd7ad91e5806917db8c11ee63.zip |
Changes to rendering pipeline. WIP.
svn-id: r32837
-rw-r--r-- | graphics/VectorRenderer.h | 15 | ||||
-rw-r--r-- | gui/InterfaceManager.cpp | 52 | ||||
-rw-r--r-- | gui/InterfaceManager.h | 36 |
3 files changed, 52 insertions, 51 deletions
diff --git a/graphics/VectorRenderer.h b/graphics/VectorRenderer.h index d989781d5c..9b2e6cd383 100644 --- a/graphics/VectorRenderer.h +++ b/graphics/VectorRenderer.h @@ -406,7 +406,7 @@ public: * * @param sys Pointer to the global System class */ - virtual void copyFrame(OSystem *sys) = 0; + virtual void copyFrame(OSystem *sys, Common::Rect &r) = 0; /** * Blits a given graphics surface on top of the current drawing surface. @@ -533,15 +533,14 @@ public: /** * @see VectorRenderer::copyFrame() */ - virtual void copyFrame(OSystem *sys) { -#ifdef OVERLAY_MULTIPLE_DEPTHS - sys->copyRectToOverlay((const PixelType*)_activeSurface->getBasePtr(0, 0), - _activeSurface->w, 0, 0, _activeSurface->w, _activeSurface->w); + virtual void copyFrame(OSystem *sys, Common::Rect &r) { +#ifdef OVERLAY_MULTIPLE_DEPTHS // TODO: change OSystem to support templated copyRectToOverlay + sys->copyRectToOverlay((const PixelType*)_activeSurface->pixels, + _activeSurface->pitch, r.top, r.left, r.width(), r.height()); #else - sys->copyRectToOverlay((const OverlayColor*)_activeSurface->getBasePtr(0, 0), - _activeSurface->w, 0, 0, _activeSurface->w, _activeSurface->w); + sys->copyRectToOverlay((const OverlayColor*)_activeSurface->pixels, + _activeSurface->pitch, r.top, r.left, r.width(), r.height()); #endif - sys->updateScreen(); } /** diff --git a/gui/InterfaceManager.cpp b/gui/InterfaceManager.cpp index f7a197f2fb..d4a0a167ff 100644 --- a/gui/InterfaceManager.cpp +++ b/gui/InterfaceManager.cpp @@ -81,9 +81,6 @@ InterfaceManager::InterfaceManager() : _graphicsMode = kGfxAntialias16bit; // default GFX mode // TODO: load this from a config file - -// setGraphicsMode(kGfxStandard16bit); -// printf("Singleton init!"); } template<typename PixelType> @@ -96,6 +93,15 @@ void InterfaceManager::screenInit() { } void InterfaceManager::setGraphicsMode(Graphics_Mode mode) { + + // FIXME: reload theme everytime we change resolution... + // what if we change the renderer too? + // ...We may need to reload it to re-cache the widget + // surfaces + if (_system->getOverlayWidth() != _screen->w || + _system->getOverlayHeight() != _screen->h) + _needThemeLoad = true; + switch (mode) { case kGfxStandard16bit: case kGfxAntialias16bit: @@ -132,6 +138,8 @@ bool InterfaceManager::addDrawData(DrawData data_id, bool cached) { } bool InterfaceManager::loadTheme(Common::String themeName) { + unloadTheme(); + if (!loadThemeXML(themeName)) { warning("Could not parse custom theme '%s'.\nFalling back to default theme", themeName.c_str()); @@ -150,6 +158,7 @@ bool InterfaceManager::loadTheme(Common::String themeName) { } } + _needThemeLoad = false; _themeOk = true; return true; } @@ -260,38 +269,52 @@ void InterfaceManager::drawScrollbar(const Common::Rect &r, int sliderY, int sli return; } +void InterfaceManager::redrawDialogStack() { + _vectorRenderer->clearSurface(); + + for (int i = 0; i < _dialogStack.size(); ++i) + _dialogStack[i]->draw(); +} + int InterfaceManager::runGUI() { + init(); + if (!ready()) return 0; Common::EventManager *eventMan = _system->getEventManager(); Dialog *activeDialog = getTopDialog(); + Dialog *lastDialog = 0; if (!activeDialog) return 0; bool didSaveState = false; - bool running = true; + bool stackChange = true; int button; uint32 time; - while (!_dialogStack.empty() && activeDialog == getTopDialog()) { // draw!! + _system->showOverlay(); - drawDD(kDDMainDialogBackground, Common::Rect()); - drawDD(kDDButtonIdle, Common::Rect(32, 32, 128, 128)); + while (activeDialog) { // draw!! + stackChange = (activeDialog != lastDialog); + lastDialog = activeDialog; - _vectorRenderer->copyFrame(_system); + if (stackChange || needRedraw()) + redrawDialogStack(); + + if (!_dirtyScreen.empty()) { + for (uint i = 0; i < _dirtyScreen.size(); ++i) + _vectorRenderer->copyFrame(_system, _dirtyScreen[i]); + _system->updateScreen(); + _dirtyScreen.clear(); + } Common::Event event; - _system->delayMillis(100); while (eventMan->pollEvent(event)) { - - if (activeDialog != getTopDialog() && - event.type != Common::EVENT_QUIT && - event.type != Common::EVENT_SCREEN_CHANGED) - continue; + activeDialog->handleTickle(); Common::Point mouse(event.mouse.x - activeDialog->_x, event.mouse.y - activeDialog->_y); @@ -352,6 +375,7 @@ int InterfaceManager::runGUI() { } } + activeDialog = getTopDialog(); _system->delayMillis(10); } diff --git a/gui/InterfaceManager.h b/gui/InterfaceManager.h index 779f9aab57..07fa0ea24e 100644 --- a/gui/InterfaceManager.h +++ b/gui/InterfaceManager.h @@ -220,33 +220,6 @@ public: return _initOk && _themeOk; } - void refresh() { - init(); - if (_enabled) { - _system->showOverlay(); -// CursorMan.replaceCursorPalette(_cursorPal, 0, MAX_CURS_COLORS); -// CursorMan.replaceCursor(_cursor, _cursorWidth, _cursorHeight, _cursorHotspotX, _cursorHotspotY, 255, _cursorTargetScale); - } - } - - void enable() { - init(); - _system->showOverlay(); - _enabled = true; - } - - void disable() { - _system->hideOverlay(); - _enabled = false; - } - - void deinit() { - if (_initOk) { - _system->hideOverlay(); - _initOk = false; - } - } - bool loadTheme() { ConfMan.registerDefault("gui_theme", "default"); Common::String style(ConfMan.get("gui_theme")); @@ -300,6 +273,11 @@ protected: return (_themeOk == false || _needThemeLoad == true); } + bool needRedraw() { + return true; + } + + void redrawDialogStack(); bool isWidgetCached(DrawData type, const Common::Rect &r); void drawCached(DrawData type, const Common::Rect &r); @@ -307,7 +285,7 @@ protected: inline void drawDD(DrawData type, const Common::Rect &r); void addDirtyRect(const Common::Rect &r) { - _dirtyScreen.extend(r); + _dirtyScreen.push_back(r); } OSystem *_system; @@ -325,7 +303,7 @@ protected: WidgetDrawData *_widgets[kDrawDataMAX]; Common::FixedStack<Dialog *, kMaxDialogDepth> _dialogStack; - Common::Rect _dirtyScreen; + Common::Array<Common::Rect> _dirtyScreen; bool _initOk; bool _themeOk; |