Rendering pipeline. WIP.

(I see working buttons)

svn-id: r32898
This commit is contained in:
Vicent Marti 2008-07-03 19:42:04 +00:00
parent 919d81f03b
commit 8240e5b96d
6 changed files with 61 additions and 20 deletions

View File

@ -63,7 +63,7 @@ public:
_pos = idx;
return _stream->readSByte();
return _stream->readByte();
}
void loadStream(SeekableReadStream *s) {
@ -331,6 +331,13 @@ protected:
return (*key == 0);
}
/**
* Overload if your parser needs to support parsing the same file
* several times, so you can clean up the internal state of the
* parser before each parse.
*/
virtual void cleanup() {}
int _pos; /** Current position on the XML buffer. */
XMLStream _text; /** Buffer with the text being parsed */
Common::String _fileName;

View File

@ -536,11 +536,11 @@ public:
*/
virtual void copyFrame(OSystem *sys, const 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());
sys->copyRectToOverlay((const PixelType*)_activeSurface->getBasePtr(r.left, r.top),
_activeSurface->w, r.top, r.left, r.width(), r.height());
#else
sys->copyRectToOverlay((const OverlayColor*)_activeSurface->pixels,
_activeSurface->pitch, r.top, r.left, r.width(), r.height());
sys->copyRectToOverlay((const OverlayColor*)_activeSurface->getBasePtr(r.left, r.top),
_activeSurface->w, r.top, r.left, r.width(), r.height());
#endif
}

View File

@ -58,7 +58,7 @@ bool ThemeRenderer::loadDefaultXML() {
"<layout_info>"
"</layout_info>";
if (!parser()->loadBuffer(defaultXML, false))
if (!parser()->loadBuffer((const byte*)defaultXML, strlen(defaultXML), false))
return false;
return parser()->parse();

View File

@ -47,6 +47,7 @@ const char *ThemeRenderer::kDrawDataStrings[] = {
"button_idle",
"button_hover",
"button_disabled",
"surface",
@ -70,7 +71,7 @@ const char *ThemeRenderer::kDrawDataStrings[] = {
ThemeRenderer::ThemeRenderer(Common::String themeName, GraphicsMode mode) :
_vectorRenderer(0), _system(0), _graphicsMode(kGfxDisabled),
_screen(0), _bytesPerPixel(0), _initOk(false), _themeOk(false) {
_screen(0), _bytesPerPixel(0), _initOk(false), _themeOk(false), _enabled(false) {
_system = g_system;
_parser = new ThemeParser(this);
@ -81,8 +82,7 @@ ThemeRenderer::ThemeRenderer(Common::String themeName, GraphicsMode mode) :
_graphicsMode = mode;
setGraphicsMode(_graphicsMode);
if (isThemeLoadingRequired())
loadTheme(themeName);
loadConfigFile("classic");
_initOk = true;
_themeName = themeName;
@ -99,9 +99,21 @@ bool ThemeRenderer::init() {
resetDrawArea();
}
if (isThemeLoadingRequired())
if (!_themeOk || isThemeLoadingRequired()) {
loadTheme(_themeName);
Theme::loadTheme(_defaultConfig);
Theme::loadTheme(_configFile, false, true);
}
if (_fontName.empty()) {
if (_screen->w >= 400 && _screen->h >= 300) {
_font = FontMan.getFontByUsage(Graphics::FontManager::kBigGUIFont);
} else {
_font = FontMan.getFontByUsage(Graphics::FontManager::kGUIFont);
}
}
return true;
}
@ -110,7 +122,6 @@ void ThemeRenderer::deinit() {
_system->hideOverlay();
freeRenderer();
freeScreen();
unloadTheme();
_initOk = false;
}
}
@ -119,9 +130,21 @@ void ThemeRenderer::clearAll() {
if (!_initOk)
return;
_vectorRenderer->clearSurface();
_vectorRenderer->copyWholeFrame(_system);
_system->updateScreen();
_system->clearOverlay();
_system->grabOverlay((OverlayColor*)_screen->pixels, _screen->w);
}
void ThemeRenderer::enable() {
init();
resetDrawArea();
_system->showOverlay();
clearAll();
_enabled = true;
}
void ThemeRenderer::disable() {
_system->hideOverlay();
_enabled = false;
}
template<typename PixelType>
@ -228,7 +251,7 @@ void ThemeRenderer::drawCached(DrawData type, const Common::Rect &r) {
void ThemeRenderer::drawDD(DrawData type, const Common::Rect &r) {
if (isWidgetCached(type, r)) {
drawCached(type, r);
} else {
} else if (_widgets[type] != 0) {
for (uint i = 0; i < _widgets[type]->_steps.size(); ++i)
_vectorRenderer->drawStep(r, *_widgets[type]->_steps[i]);
}
@ -242,6 +265,8 @@ void ThemeRenderer::drawButton(const Common::Rect &r, const Common::String &str,
drawDD(kDDButtonIdle, r);
else if (state == kStateHighlight)
drawDD(kDDButtonHover, r);
else if (state == kStateDisabled)
drawDD(kDDButtonDisabled, r);
// TODO: Add text drawing.
@ -290,6 +315,11 @@ void ThemeRenderer::drawScrollbar(const Common::Rect &r, int sliderY, int slider
return;
}
void ThemeRenderer::updateScreen() {
// renderDirtyScreen();
_vectorRenderer->copyWholeFrame(_system);
}
void ThemeRenderer::renderDirtyScreen() {
// TODO: This isn't really optimized. Check dirty squares for collisions
// and all that.
@ -299,7 +329,7 @@ void ThemeRenderer::renderDirtyScreen() {
for (uint i = 0; i < _dirtyScreen.size(); ++i)
_vectorRenderer->copyFrame(_system, _dirtyScreen[i]);
_system->updateScreen();
// _system->updateScreen();
_dirtyScreen.clear();
}

View File

@ -87,6 +87,7 @@ public:
kDDButtonIdle,
kDDButtonHover,
kDDButtonDisabled,
kDDSurface,
@ -124,13 +125,13 @@ public:
void clearAll();
void refresh() {}
void enable() {}
void disable() {}
void enable();
void disable();
void openDialog() {}
void closeAllDialogs() {}
void updateScreen() {}
void updateScreen(); //{}
void resetDrawArea() {}
void openDialog(bool top) {}
@ -210,6 +211,8 @@ protected:
delete _widgets[i];
_widgets[i] = 0;
}
_themeOk = false;
}
void screenChange() {}
@ -268,6 +271,7 @@ protected:
bool _initOk;
bool _themeOk;
bool _caching;
bool _enabled;
Common::String _themeName;
};

View File

@ -242,7 +242,7 @@ void NewGui::runLoop() {
while (!_dialogStack.empty() && activeDialog == getTopDialog()) {
if (_needRedraw) {
redraw();
_needRedraw = false;
// _needRedraw = false;
}
// Don't "tickle" the dialog until the theme has had a chance