And so it begins (again); bumped version # for next release.

Now that there are no dirty updates, remove redundant calls to draw();
calling setDirty() is now sufficient to get the changes shown in the
next frame.  This is also slightly faster, since redrawing is done
only when necessary.


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@3156 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2015-03-21 20:00:00 +00:00
parent 651204df32
commit 36229b4ee1
22 changed files with 81 additions and 118 deletions

View File

@ -89,11 +89,11 @@ void CheatManager::addPerFrame(const string& name, const string& code, bool enab
{
// The actual cheat will always be in the main list; we look there first
shared_ptr<Cheat> cheat;
for(uInt32 i = 0; i < myCheatList.size(); i++)
for(auto& c: myCheatList)
{
if(myCheatList[i]->name() == name || myCheatList[i]->code() == code)
if(c->name() == name || c->code() == code)
{
cheat = myCheatList[i];
cheat = c;
break;
}
}

View File

@ -22,7 +22,7 @@
#include <cstdlib>
#define STELLA_VERSION "4.6"
#define STELLA_VERSION "4.7_pre"
#define STELLA_BUILD atoi("$Rev$" + 6)
#endif

View File

@ -46,7 +46,7 @@ ColorWidget::~ColorWidget()
void ColorWidget::setColor(int color)
{
_color = color;
setDirty(); draw();
setDirty();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -128,7 +128,7 @@ cerr << "_addrList.size() = " << _addrList.size()
// Send item selected signal for starting with cell 0
sendCommand(DataGridWidget::kSelectionChangedCmd, _selectedItem, _id);
setDirty(); draw();
setDirty();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -165,7 +165,7 @@ void DataGridWidget::setHiliteList(const BoolArray& hilitelist)
_hiliteList.clear();
_hiliteList = hilitelist;
setDirty(); draw();
setDirty();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -201,7 +201,7 @@ void DataGridWidget::setValue(int position, int value, bool changed)
sendCommand(DataGridWidget::kItemDataChangedCmd, position, _id);
setDirty(); draw();
setDirty();
}
}
@ -234,7 +234,7 @@ void DataGridWidget::handleMouseDown(int x, int y, int button, int clickCount)
_currentCol = _selectedItem - (_currentRow * _cols);
sendCommand(DataGridWidget::kSelectionChangedCmd, _selectedItem, _id);
setDirty(); draw();
setDirty();
}
}
@ -462,7 +462,7 @@ bool DataGridWidget::handleKeyDown(StellaKey key, StellaMod mod)
if(_selectedItem != oldItem)
sendCommand(DataGridWidget::kSelectionChangedCmd, _selectedItem, _id);
setDirty(); draw();
setDirty();
}
_currentKeyDown = key;

View File

@ -86,19 +86,21 @@ void PromptWidget::drawWidget(bool hilite)
int start = _scrollLine - _linesPerPage + 1;
int y = _y + 2;
for (int line = 0; line < _linesPerPage; line++)
for (int line = 0; line < _linesPerPage; ++line)
{
int x = _x + 1;
for (int column = 0; column < _lineWidth; column++) {
for (int column = 0; column < _lineWidth; ++column) {
int c = buffer((start + line) * _lineWidth + column);
if(c & (1 << 17)) { // inverse video flag
if(c & (1 << 17)) // inverse video flag
{
fgcolor = _bgcolor;
bgcolor = (c & 0x1ffff) >> 8;
s.fillRect(x, y, _kConsoleCharWidth, _kConsoleCharHeight, bgcolor);
} else {
fgcolor = c >> 8;
}
else
fgcolor = c >> 8;
s.drawChar(_font, c & 0x7f, x, y, fgcolor);
x += _kConsoleCharWidth;
}
@ -144,7 +146,7 @@ bool PromptWidget::handleText(char text)
for(int i = _promptEndPos - 1; i >= _currentPos; i--)
buffer(i + 1) = buffer(i);
_promptEndPos++;
putchar(text);
putcharIntern(text);
scrollToCurrent();
}
return true;
@ -430,9 +432,7 @@ bool PromptWidget::handleKeyDown(StellaKey key, StellaMod mod)
// Take care of changes made above
if(dirty)
{
setDirty(); draw();
}
setDirty();
// There are times when we want the prompt and scrollbar to be marked
// as dirty *after* they've been drawn above. One such occurrence is
@ -478,7 +478,7 @@ void PromptWidget::handleCommand(CommandSender* sender, int cmd,
if (newPos != _scrollLine)
{
_scrollLine = newPos;
setDirty(); draw();
setDirty();
}
break;
}
@ -553,9 +553,7 @@ void PromptWidget::specialKeys(StellaKey key)
}
if(handled)
{
setDirty(); draw();
}
setDirty();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -709,7 +707,7 @@ void PromptWidget::historyScroll(int direction)
// Ensure once more the caret is visible (in case of very long history entries)
scrollToCurrent();
setDirty(); draw();
setDirty();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -774,13 +772,6 @@ int PromptWidget::vprintf(const char* format, va_list argptr)
return count;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PromptWidget::putchar(int c)
{
putcharIntern(c);
setDirty(); draw();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PromptWidget::putcharIntern(int c)
{
@ -809,14 +800,14 @@ void PromptWidget::putcharIntern(int c)
updateScrollBuffer();
}
}
setDirty();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PromptWidget::print(const string& str)
{
const char* c = str.c_str();
while(*c)
putcharIntern(*c++);
for(char c: str)
putcharIntern(c);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -38,8 +38,6 @@ class PromptWidget : public Widget, public CommandSender
public:
int printf(const char *format, ...);
int vprintf(const char *format, va_list argptr);
#undef putchar
void putchar(int c);
void print(const string& str);
void printPrompt();
bool saveBuffer(string& filename);

View File

@ -112,8 +112,6 @@ void RomListWidget::setList(const CartDebug::Disassembly& disasm,
myCheckList[i]->clearFlags(WIDGET_ENABLED);
recalc();
setDirty(); draw();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -190,6 +188,8 @@ void RomListWidget::recalc()
// Reset to normal data entry
abortEditMode();
setDirty();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -215,7 +215,7 @@ void RomListWidget::scrollToCurrent(int item)
myScrollBar->_currentPos = _currentPos;
myScrollBar->recalc();
setDirty(); draw();
setDirty();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -245,7 +245,7 @@ void RomListWidget::handleMouseDown(int x, int y, int button, int clickCount)
if (_editMode)
abortEditMode();
_selectedItem = newSelectedItem;
setDirty(); draw();
setDirty();
}
}
}
@ -409,7 +409,7 @@ void RomListWidget::handleCommand(CommandSender* sender, int cmd, int data, int
if (_currentPos != (int)data)
{
_currentPos = data;
setDirty(); draw();
setDirty();
}
break;

View File

@ -60,7 +60,7 @@ TiaOutputWidget::~TiaOutputWidget()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void TiaOutputWidget::loadConfig()
{
setDirty(); draw();
setDirty();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -68,7 +68,7 @@ TiaZoomWidget::~TiaZoomWidget()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void TiaZoomWidget::loadConfig()
{
setDirty(); draw();
setDirty();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -104,7 +104,7 @@ void TiaZoomWidget::recalc()
myXOff = BSPF_clamp(myXOff, 0, tw - myNumCols);
myYOff = BSPF_clamp(myYOff, 0, th - myNumRows);
setDirty(); draw();
setDirty();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -72,7 +72,7 @@ void ToggleBitWidget::setState(const BoolArray& state, const BoolArray& changed)
_changedList.clear();
_changedList = changed;
setDirty(); draw();
setDirty();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -54,7 +54,7 @@ void TogglePixelWidget::setState(const BoolArray& state)
_stateList.clear();
_stateList = state;
setDirty(); draw();
setDirty();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -61,7 +61,7 @@ void ToggleWidget::handleMouseDown(int x, int y, int button, int clickCount)
_selectedItem = newSelectedItem;
_currentRow = _selectedItem / _cols;
_currentCol = _selectedItem - (_currentRow * _cols);
setDirty(); draw();
setDirty();
}
}
@ -78,7 +78,7 @@ void ToggleWidget::handleMouseUp(int x, int y, int button, int clickCount)
_stateList[_selectedItem] = !_stateList[_selectedItem];
_changedList[_selectedItem] = !_changedList[_selectedItem];
sendCommand(ToggleWidget::kItemDataChangedCmd, _selectedItem, _id);
setDirty(); draw();
setDirty();
}
}
@ -195,7 +195,7 @@ bool ToggleWidget::handleKeyDown(StellaKey key, StellaMod mod)
sendCommand(ToggleWidget::kItemDataChangedCmd, _selectedItem, _id);
}
setDirty(); draw();
setDirty();
}
return handled;
@ -211,7 +211,7 @@ void ToggleWidget::handleCommand(CommandSender* sender, int cmd,
if (_selectedItem != (int)data)
{
_selectedItem = data;
setDirty(); draw();
setDirty();
}
break;
}

View File

@ -233,8 +233,8 @@ void Dialog::buildCurrentFocusList(int tabID)
}
// Add appropriate items from tablist (if present)
for(uInt32 id = 0; id < _myTabList.size(); ++id)
_myTabList[id].appendFocusList(_focusList);
for(auto& tabfocus: _myTabList)
tabfocus.appendFocusList(_focusList);
// Add remaining items from main focus list
Vec::append(_focusList, _myFocus.list);

View File

@ -42,8 +42,6 @@ void EditTextWidget::setText(const string& str, bool changed)
EditableWidget::setText(str, changed);
_backupString = str;
_changed = changed;
setDirty(); draw();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -65,9 +63,7 @@ void EditTextWidget::handleMouseDown(int x, int y, int button, int clickCount)
}
if (setCaretPos(i))
{
setDirty(); draw();
}
setDirty();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -55,9 +55,9 @@ void EditableWidget::setText(const string& str, bool)
{
// Filter input string
_editString = "";
for(int i = 0; i < str.size(); ++i)
if(_filter(tolower(str[i])))
_editString.push_back(str[i]);
for(char c: str)
if(_filter(tolower(c)))
_editString.push_back(c);
_caretPos = (int)_editString.size();
@ -68,8 +68,7 @@ void EditableWidget::setText(const string& str, bool)
if(_editable)
startEditMode();
// Make sure the new string is seen onscreen
setDirty(); draw();
setDirty();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void EditableWidget::setEditable(bool editable)
@ -102,7 +101,7 @@ bool EditableWidget::handleText(char text)
{
_caretPos++;
sendCommand(EditableWidget::kChangedCmd, 0, _id);
setDirty(); draw();
setDirty();
return true;
}
return false;
@ -179,9 +178,7 @@ bool EditableWidget::handleKeyDown(StellaKey key, StellaMod mod)
}
if (dirty)
{
setDirty(); draw();
}
setDirty();
return handled;
}

View File

@ -63,19 +63,18 @@ class GuiObject : public CommandReceiver
: myOSystem(osystem),
myParent(parent),
myDialog(dialog),
_x(x),
_y(y),
_w(w),
_h(h),
_x(x), _y(y), _w(w), _h(h),
_dirty(false),
_firstWidget(0) {}
_firstWidget(0) { }
virtual ~GuiObject() {}
virtual ~GuiObject() { }
OSystem& instance() const { return myOSystem; }
DialogContainer& parent() const { return myParent; }
Dialog& dialog() const { return myDialog; }
void setDirty() { _dirty = true; }
virtual int getAbsX() const { return _x; }
virtual int getAbsY() const { return _y; }
virtual int getChildX() const { return getAbsX(); }
@ -86,10 +85,7 @@ class GuiObject : public CommandReceiver
virtual void setWidth(int w) { _w = w; }
virtual void setHeight(int h) { _h = h; }
virtual void setDirty() { _dirty = true; }
virtual bool isVisible() const = 0;
virtual void draw() = 0;
/** Add given widget to the focus list */
virtual void addFocusWidget(Widget* w) = 0;
@ -98,10 +94,11 @@ class GuiObject : public CommandReceiver
WidgetArray& getFocusList() { return _focusList; }
/** Redraw the focus list */
virtual void redrawFocus() {}
virtual void redrawFocus() { }
protected:
virtual void releaseFocus() = 0;
virtual void draw() = 0;
private:
OSystem& myOSystem;
@ -109,8 +106,7 @@ class GuiObject : public CommandReceiver
Dialog& myDialog;
protected:
int _x, _y;
int _w, _h;
int _x, _y, _w, _h;
bool _dirty;
Widget* _firstWidget;

View File

@ -70,7 +70,7 @@ void ListWidget::setSelected(int item)
{
if(item < 0 || item >= (int)_list.size())
{
setDirty(); draw(); // Simply redraw and exit
setDirty(); // Simply redraw and exit
return;
}
@ -208,7 +208,7 @@ void ListWidget::handleMouseDown(int x, int y, int button, int clickCount)
abortEditMode();
_selectedItem = newSelectedItem;
sendCommand(ListWidget::kSelectionChangedCmd, _selectedItem, _id);
setDirty(); draw();
setDirty();
}
// TODO: Determine where inside the string the user clicked and place the
@ -420,7 +420,7 @@ void ListWidget::handleCommand(CommandSender* sender, int cmd, int data, int id)
if (_currentPos != (int)data)
{
_currentPos = data;
setDirty(); draw();
setDirty();
// Let boss know the list has scrolled
sendCommand(ListWidget::kScrolledCmd, _currentPos, _id);
@ -453,7 +453,7 @@ void ListWidget::scrollToCurrent(int item)
_scrollBar->_currentPos = _currentPos;
_scrollBar->recalc();
setDirty(); draw();
setDirty();
if(oldScrollPos != _currentPos)
sendCommand(ListWidget::kScrolledCmd, _currentPos, _id);

View File

@ -48,10 +48,7 @@ void RomInfoWidget::loadConfig()
// by saving a different image or through a change in video renderer,
// so we reload the properties
if(myHaveProperties)
{
parseProperties();
setDirty(); draw();
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -62,10 +59,7 @@ void RomInfoWidget::setProperties(const Properties& props)
// Decide whether the information should be shown immediately
if(instance().eventHandler().state() == EventHandler::S_LAUNCHER)
{
parseProperties();
setDirty(); draw();
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -77,9 +71,7 @@ void RomInfoWidget::clearProperties()
// Decide whether the information should be shown immediately
if(instance().eventHandler().state() == EventHandler::S_LAUNCHER)
{
setDirty(); draw();
}
setDirty();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -132,6 +124,8 @@ void RomInfoWidget::parseProperties()
myRomInfo.push_back("Note: " + myProperties.get(Cartridge_Note));
myRomInfo.push_back("Controllers: " + myProperties.get(Controller_Left) +
" (left), " + myProperties.get(Controller_Right) + " (right)");
setDirty();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -181,9 +181,7 @@ void ScrollBarWidget::handleMouseMoved(int x, int y, int button)
_part = kSliderPart;
if (old_part != _part)
{
setDirty(); draw();
}
setDirty();
}
}
@ -204,8 +202,7 @@ void ScrollBarWidget::checkBounds(int old_pos)
if (old_pos != _currentPos)
{
recalc(); // This takes care of the required refresh
setDirty(); draw();
recalc();
sendCommand(kSetPositionCmd, _currentPos, _id);
}
}
@ -214,7 +211,6 @@ void ScrollBarWidget::checkBounds(int old_pos)
void ScrollBarWidget::handleMouseEntered(int button)
{
setFlags(WIDGET_HILITED);
setDirty(); draw();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -222,7 +218,6 @@ void ScrollBarWidget::handleMouseLeft(int button)
{
_part = kNoPart;
clearFlags(WIDGET_HILITED);
setDirty(); draw();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -246,7 +241,7 @@ void ScrollBarWidget::recalc()
_sliderPos = UP_DOWN_BOX_HEIGHT;
}
setDirty(); draw();
setDirty();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -126,7 +126,7 @@ void TabWidget::updateActiveTab()
if(_tabs[_activeTab].parentWidget)
_tabs[_activeTab].parentWidget->loadConfig();
setDirty(); draw();
setDirty();
// Redraw focused areas
_boss->redrawFocus();

View File

@ -152,12 +152,8 @@ void Widget::lostFocus()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Widget::setEnabled(bool e)
{
if(e)
setFlags(WIDGET_ENABLED);
else
clearFlags(WIDGET_ENABLED);
setDirty(); draw();
if(e) setFlags(WIDGET_ENABLED);
else clearFlags(WIDGET_ENABLED);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -227,7 +223,7 @@ Widget* Widget::setFocusForChain(GuiObject* boss, WidgetArray& arr,
tmp->lostFocus();
s.frameRect(x, y, w, h, kDlgColor);
tmp->setDirty(); tmp->draw();
tmp->setDirty();
s.setDirty();
}
}
@ -270,7 +266,7 @@ Widget* Widget::setFocusForChain(GuiObject* boss, WidgetArray& arr,
tmp->receivedFocus();
s.frameRect(x, y, w, h, kWidFrameColor, kDashLine);
tmp->setDirty(); tmp->draw();
tmp->setDirty();
s.setDirty();
return tmp;
@ -310,7 +306,7 @@ void StaticTextWidget::setValue(int value)
BSPF_snprintf(buf, 255, "%d", value);
_label = buf;
setDirty(); draw();
setDirty();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -318,7 +314,7 @@ void StaticTextWidget::setLabel(const string& label)
{
_label = label;
setDirty(); draw();
setDirty();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -350,14 +346,14 @@ ButtonWidget::ButtonWidget(GuiObject* boss, const GUI::Font& font,
void ButtonWidget::handleMouseEntered(int button)
{
setFlags(WIDGET_HILITED);
setDirty(); draw();
setDirty();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void ButtonWidget::handleMouseLeft(int button)
{
clearFlags(WIDGET_HILITED);
setDirty(); draw();
setDirty();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -513,7 +509,7 @@ void CheckboxWidget::setState(bool state)
if(_state != state)
{
_state = state;
setDirty(); draw();
setDirty();
}
}
@ -572,7 +568,7 @@ void SliderWidget::setValue(int value)
if(value != _value)
{
_value = value;
setDirty(); draw();
setDirty();
sendCommand(_cmd, _value, _id);
}
}

View File

@ -87,11 +87,11 @@ class Widget : public GuiObject
void lostFocus();
void addFocusWidget(Widget* w) { _focusList.push_back(w); }
/** Set/clear WIDGET_ENABLED flag and immediately redraw */
/** Set/clear WIDGET_ENABLED flag */
void setEnabled(bool e);
void setFlags(int flags) { _flags |= flags; }
void clearFlags(int flags) { _flags &= ~flags; }
void setFlags(int flags) { _flags |= flags; setDirty(); }
void clearFlags(int flags) { _flags &= ~flags; setDirty(); }
int getFlags() const { return _flags; }
bool isEnabled() const { return _flags & WIDGET_ENABLED; }