mirror of https://github.com/stella-emu/stella.git
split Dialog drawing and rendering and skip drawing render when possible
This commit is contained in:
parent
a6922fb989
commit
d77612f572
|
@ -128,7 +128,6 @@ void Dialog::close()
|
|||
_visible = false;
|
||||
|
||||
parent().removeDialog();
|
||||
setDirty();
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -219,26 +218,30 @@ void Dialog::positionAt(uInt32 pos)
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool Dialog::render()
|
||||
void Dialog::redraw()
|
||||
{
|
||||
if(!isVisible() || !needsRedraw())
|
||||
return false;
|
||||
return;// false;
|
||||
|
||||
// Draw this dialog
|
||||
center();
|
||||
drawDialog();
|
||||
render();
|
||||
|
||||
// return true;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void Dialog::render()
|
||||
{
|
||||
// Update dialog surface; also render any extra surfaces
|
||||
// Extra surfaces must be rendered afterwards, so they are drawn on top
|
||||
if(_surface->render())
|
||||
{
|
||||
mySurfaceStack.applyAll([](shared_ptr<FBSurface>& surface){
|
||||
mySurfaceStack.applyAll([](shared_ptr<FBSurface>& surface) {
|
||||
surface->render();
|
||||
});
|
||||
}
|
||||
//_dirty = false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
|
|
@ -67,7 +67,8 @@ class Dialog : public GuiObject
|
|||
void setDirty() override;
|
||||
bool isDirty() override; // TODO: remove
|
||||
bool isChainDirty() const override;
|
||||
bool render();
|
||||
void redraw();
|
||||
void render();
|
||||
|
||||
void addFocusWidget(Widget* w) override;
|
||||
void addToFocusList(WidgetArray& list) override;
|
||||
|
|
|
@ -89,11 +89,11 @@ void DialogContainer::updateTime(uInt64 time)
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool DialogContainer::draw(bool full)
|
||||
void DialogContainer::draw(bool full)
|
||||
{
|
||||
cerr << "draw " << full << " " << typeid(*this).name() << endl;
|
||||
if(myDialogStack.empty())
|
||||
return false;
|
||||
return;
|
||||
|
||||
// Make the top dialog dirty if a full redraw is requested
|
||||
if(full)
|
||||
|
@ -102,10 +102,8 @@ bool DialogContainer::draw(bool full)
|
|||
// Render all dirty dialogs
|
||||
myDialogStack.applyAll([&](Dialog*& d) {
|
||||
if(d->needsRedraw())
|
||||
full |= d->render();
|
||||
d->redraw();
|
||||
});
|
||||
|
||||
return full;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -133,7 +131,7 @@ int DialogContainer::addDialog(Dialog* d)
|
|||
"Unable to show dialog box; FIX THE CODE");
|
||||
else
|
||||
{
|
||||
// fade out current top dialog
|
||||
// "darken" current top dialog
|
||||
if(!myDialogStack.empty())
|
||||
myDialogStack.top()->setDirty();
|
||||
d->setDirty();
|
||||
|
@ -148,14 +146,16 @@ void DialogContainer::removeDialog()
|
|||
if(!myDialogStack.empty())
|
||||
{
|
||||
myDialogStack.pop();
|
||||
// necessary as long as all dialogs share the same surface
|
||||
|
||||
if(!myDialogStack.empty())
|
||||
{
|
||||
//myDialogStack.top()->setDirty();
|
||||
// this "undarkens" the top dialog
|
||||
myDialogStack.top()->setDirty();
|
||||
|
||||
// Mark all dialogs for redraw
|
||||
// Rerender all dialogs (TODO: top dialog is rendered twice)
|
||||
myDialogStack.applyAll([&](Dialog*& d){
|
||||
d->setDirty();
|
||||
//d->setDirty();
|
||||
d->render();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -121,10 +121,8 @@ class DialogContainer
|
|||
|
||||
/**
|
||||
Draw the stack of menus (full indicates to redraw all items).
|
||||
|
||||
@return Answers whether any drawing actually occurred.
|
||||
*/
|
||||
bool draw(bool full = false);
|
||||
void draw(bool full = false);
|
||||
|
||||
/**
|
||||
Answers whether a full redraw is required.
|
||||
|
|
|
@ -74,7 +74,6 @@ bool EditableWidget::isDirty()
|
|||
_caretEnabled = !_caretEnabled;
|
||||
_dirty = true;
|
||||
}
|
||||
cerr << ".";
|
||||
}
|
||||
|
||||
return _dirty;
|
||||
|
|
|
@ -277,7 +277,7 @@ void PopUpWidget::drawWidget(bool hilite)
|
|||
|
||||
// Fill the background
|
||||
ColorId bgCol = isEditable() ? kWidColor : kDlgColor;
|
||||
s.fillRect(x + 1, _y + 1, w - (_arrowWidth * 2 - 0), _h - 2,
|
||||
s.fillRect(x + 1, _y + 1, w - (_arrowWidth * 2 - 1), _h - 2,
|
||||
onTop ? _changed ? kDbgChangedColor : bgCol : kDlgColor);
|
||||
s.fillRect(x + w - (_arrowWidth * 2 - 2), _y + 1, (_arrowWidth * 2 - 3), _h - 2,
|
||||
onTop ? isEnabled() && hilite ? kBtnColorHi : bgCol : kBGColorLo);
|
||||
|
|
Loading…
Reference in New Issue