[Scummvm-cvs-logs] SF.net SVN: scummvm: [32837] scummvm/branches/gsoc2008-gui
Tanoku at users.sourceforge.net
Tanoku at users.sourceforge.net
Sun Jun 29 14:08:54 CEST 2008
Revision: 32837
http://scummvm.svn.sourceforge.net/scummvm/?rev=32837&view=rev
Author: Tanoku
Date: 2008-06-29 05:08:53 -0700 (Sun, 29 Jun 2008)
Log Message:
-----------
Changes to rendering pipeline. WIP.
Modified Paths:
--------------
scummvm/branches/gsoc2008-gui/graphics/VectorRenderer.h
scummvm/branches/gsoc2008-gui/gui/InterfaceManager.cpp
scummvm/branches/gsoc2008-gui/gui/InterfaceManager.h
Modified: scummvm/branches/gsoc2008-gui/graphics/VectorRenderer.h
===================================================================
--- scummvm/branches/gsoc2008-gui/graphics/VectorRenderer.h 2008-06-29 11:51:47 UTC (rev 32836)
+++ scummvm/branches/gsoc2008-gui/graphics/VectorRenderer.h 2008-06-29 12:08:53 UTC (rev 32837)
@@ -406,7 +406,7 @@
*
* @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 @@
/**
* @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();
}
/**
Modified: scummvm/branches/gsoc2008-gui/gui/InterfaceManager.cpp
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/InterfaceManager.cpp 2008-06-29 11:51:47 UTC (rev 32836)
+++ scummvm/branches/gsoc2008-gui/gui/InterfaceManager.cpp 2008-06-29 12:08:53 UTC (rev 32837)
@@ -81,9 +81,6 @@
_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::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::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 @@
}
}
+ _needThemeLoad = false;
_themeOk = true;
return true;
}
@@ -260,39 +269,53 @@
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)) {
+ activeDialog->handleTickle();
- if (activeDialog != getTopDialog() &&
- event.type != Common::EVENT_QUIT &&
- event.type != Common::EVENT_SCREEN_CHANGED)
- continue;
-
Common::Point mouse(event.mouse.x - activeDialog->_x, event.mouse.y - activeDialog->_y);
switch (event.type) {
@@ -352,6 +375,7 @@
}
}
+ activeDialog = getTopDialog();
_system->delayMillis(10);
}
Modified: scummvm/branches/gsoc2008-gui/gui/InterfaceManager.h
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/InterfaceManager.h 2008-06-29 11:51:47 UTC (rev 32836)
+++ scummvm/branches/gsoc2008-gui/gui/InterfaceManager.h 2008-06-29 12:08:53 UTC (rev 32837)
@@ -220,33 +220,6 @@
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,14 +273,19 @@
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);
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 @@
WidgetDrawData *_widgets[kDrawDataMAX];
Common::FixedStack<Dialog *, kMaxDialogDepth> _dialogStack;
- Common::Rect _dirtyScreen;
+ Common::Array<Common::Rect> _dirtyScreen;
bool _initOk;
bool _themeOk;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list