From 9d63ec42d2f98370057731b3dc1f3f65197bf2d4 Mon Sep 17 00:00:00 2001 From: thrust26 Date: Sat, 28 Nov 2020 16:12:54 +0100 Subject: [PATCH] minimized redraws in debugger --- src/debugger/gui/DataGridWidget.cxx | 51 ++++++++++++++++++-------- src/debugger/gui/DataGridWidget.hxx | 2 +- src/debugger/gui/DebuggerDialog.cxx | 12 ------ src/debugger/gui/RomListWidget.cxx | 3 +- src/debugger/gui/TiaInfoWidget.cxx | 6 ++- src/debugger/gui/ToggleBitWidget.cxx | 6 ++- src/debugger/gui/TogglePixelWidget.cxx | 19 ++++++++-- src/debugger/gui/TogglePixelWidget.hxx | 2 +- src/gui/ColorWidget.cxx | 17 ++++++++- src/gui/ColorWidget.hxx | 2 +- src/gui/EditTextWidget.cxx | 6 ++- src/gui/EditableWidget.cxx | 8 ++-- src/gui/PopUpWidget.cxx | 11 +++++- src/gui/ScrollBarWidget.cxx | 6 ++- src/gui/TabWidget.cxx | 5 ++- src/gui/Widget.cxx | 20 +++++----- 16 files changed, 117 insertions(+), 59 deletions(-) diff --git a/src/debugger/gui/DataGridWidget.cxx b/src/debugger/gui/DataGridWidget.cxx index 20489912c..9fa82bcdc 100644 --- a/src/debugger/gui/DataGridWidget.cxx +++ b/src/debugger/gui/DataGridWidget.cxx @@ -107,15 +107,21 @@ DataGridWidget::DataGridWidget(GuiObject* boss, const GUI::Font& font, void DataGridWidget::setList(const IntArray& alist, const IntArray& vlist, const BoolArray& changed) { -/* -cerr << "alist.size() = " << alist.size() - << ", vlist.size() = " << vlist.size() - << ", changed.size() = " << changed.size() - << ", _rows*_cols = " << _rows * _cols << endl << endl; -*/ + /* + cerr << "alist.size() = " << alist.size() + << ", vlist.size() = " << vlist.size() + << ", changed.size() = " << changed.size() + << ", _rows*_cols = " << _rows * _cols << endl << endl; + */ int size = int(vlist.size()); // assume the alist is the same size assert(size == _rows * _cols); + bool dirty = _editMode + || !std::equal(_valueList.begin(), _valueList.end(), + vlist.begin(), vlist.end()) + || !std::equal(_changedList.begin(), _changedList.end(), + changed.begin(), changed.end()); + _addrList.clear(); _valueList.clear(); _valueStringList.clear(); @@ -130,19 +136,22 @@ cerr << "alist.size() = " << alist.size() for(int i = 0; i < size; ++i) _valueStringList.push_back(Common::Base::toString(_valueList[i], _base)); -/* -cerr << "_addrList.size() = " << _addrList.size() - << ", _valueList.size() = " << _valueList.size() - << ", _changedList.size() = " << _changedList.size() - << ", _valueStringList.size() = " << _valueStringList.size() - << ", _rows*_cols = " << _rows * _cols << endl << endl; -*/ + /* + cerr << "_addrList.size() = " << _addrList.size() + << ", _valueList.size() = " << _valueList.size() + << ", _changedList.size() = " << _changedList.size() + << ", _valueStringList.size() = " << _valueStringList.size() + << ", _rows*_cols = " << _rows * _cols << endl << endl; + */ enableEditMode(false); - // Send item selected signal for starting with cell 0 - sendCommand(DataGridWidget::kSelectionChangedCmd, _selectedItem, _id); + if(dirty) + { + // Send item selected signal for starting with cell 0 + sendCommand(DataGridWidget::kSelectionChangedCmd, _selectedItem, _id); - setDirty(); + setDirty(); + } } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -708,6 +717,16 @@ int DataGridWidget::getWidth() const return _w + (_scrollBar ? ScrollBarWidget::scrollBarWidth(_font) : 0); } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void DataGridWidget::setCrossed(bool enable) +{ + if(_crossGrid != enable) + { + _crossGrid = enable; + setDirty(); + } +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void DataGridWidget::startEditMode() { diff --git a/src/debugger/gui/DataGridWidget.hxx b/src/debugger/gui/DataGridWidget.hxx index 848993311..ed1b6be02 100644 --- a/src/debugger/gui/DataGridWidget.hxx +++ b/src/debugger/gui/DataGridWidget.hxx @@ -82,7 +82,7 @@ class DataGridWidget : public EditableWidget void setOpsWidget(DataGridOpsWidget* w) { _opsWidget = w; } - void setCrossed(bool enable) { _crossGrid = enable; } + void setCrossed(bool enable); string getToolTip(const Common::Point& pos) const override; bool changedToolTip(const Common::Point& oldPos, const Common::Point& newPos) const override; diff --git a/src/debugger/gui/DebuggerDialog.cxx b/src/debugger/gui/DebuggerDialog.cxx index b8a28f579..f2ac5c230 100644 --- a/src/debugger/gui/DebuggerDialog.cxx +++ b/src/debugger/gui/DebuggerDialog.cxx @@ -272,84 +272,72 @@ void DebuggerDialog::handleCommand(CommandSender* sender, int cmd, void DebuggerDialog::doStep() { instance().debugger().parser().run("step"); - setDirty(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void DebuggerDialog::doTrace() { instance().debugger().parser().run("trace"); - setDirty(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void DebuggerDialog::doAdvance() { instance().debugger().parser().run("frame #1"); - setDirty(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void DebuggerDialog::doScanlineAdvance() { instance().debugger().parser().run("scanline #1"); - setDirty(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void DebuggerDialog::doRewind() { instance().debugger().parser().run("rewind"); - setDirty(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void DebuggerDialog::doUnwind() { instance().debugger().parser().run("unwind"); - setDirty(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void DebuggerDialog::doRewind10() { instance().debugger().parser().run("rewind #10"); - setDirty(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void DebuggerDialog::doUnwind10() { instance().debugger().parser().run("unwind #10"); - setDirty(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void DebuggerDialog::doRewindAll() { instance().debugger().parser().run("rewind #1000"); - setDirty(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void DebuggerDialog::doUnwindAll() { instance().debugger().parser().run("unwind #1000"); - setDirty(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void DebuggerDialog::doExitDebugger() { instance().debugger().parser().run("run"); - setDirty(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void DebuggerDialog::doExitRom() { instance().debugger().parser().run("exitrom"); - setDirty(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/debugger/gui/RomListWidget.cxx b/src/debugger/gui/RomListWidget.cxx index c226398a6..9f8b9d589 100644 --- a/src/debugger/gui/RomListWidget.cxx +++ b/src/debugger/gui/RomListWidget.cxx @@ -553,7 +553,8 @@ void RomListWidget::drawWidget(bool hilite) checkBreakPoint(dlist[pos].address, instance().debugger().cartDebug().getBank(dlist[pos].address))); myCheckList[i]->setDirty(); - // draw immediately, because chain order is not deterministic + // All checkboxes have to be redrawn because RomListWidget clears its whole area + // Also draw immediately, because chain order is not deterministic myCheckList[i]->draw(); // Draw highlighted item in a frame diff --git a/src/debugger/gui/TiaInfoWidget.cxx b/src/debugger/gui/TiaInfoWidget.cxx index 2690f8b4f..fe2ce6d9b 100644 --- a/src/debugger/gui/TiaInfoWidget.cxx +++ b/src/debugger/gui/TiaInfoWidget.cxx @@ -81,7 +81,6 @@ TiaInfoWidget::TiaInfoWidget(GuiObject* boss, const GUI::Font& lfont, ypos += lineHeight + VGAP; new StaticTextWidget(boss, lfont, xpos, ypos + 1, "Total"); myTotalCycles = new EditTextWidget(boss, nfont, xpos + lwidth8, ypos - 1, twidth, lineHeight); - myTotalCycles->setToolTip("Total CPU cycles executed for this session (E notation)."); myTotalCycles->setEditable(false, true); // Left: Delta Cycles @@ -170,7 +169,10 @@ void TiaInfoWidget::loadConfig() uInt64 total = tia.cyclesLo() + (uInt64(tia.cyclesHi()) << 32); uInt64 totalOld = oldTia.info[2] + (uInt64(oldTia.info[3]) << 32); myTotalCycles->setText(Common::Base::toString(uInt32(total) / 1000000, Common::Base::Fmt::_10_6) + "e6", - total != totalOld); + total / 1000000 != totalOld / 1000000); + myTotalCycles->setToolTip("Total CPU cycles (E notation) executed for this session (" + + std::to_string(total) + ")."); + uInt64 delta = total - totalOld; myDeltaCycles->setText(Common::Base::toString(uInt32(delta), Common::Base::Fmt::_10_8)); // no coloring diff --git a/src/debugger/gui/ToggleBitWidget.cxx b/src/debugger/gui/ToggleBitWidget.cxx index 994d73aa9..629e58c57 100644 --- a/src/debugger/gui/ToggleBitWidget.cxx +++ b/src/debugger/gui/ToggleBitWidget.cxx @@ -70,12 +70,14 @@ void ToggleBitWidget::setList(const StringList& off, const StringList& on) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void ToggleBitWidget::setState(const BoolArray& state, const BoolArray& changed) { + if(!std::equal(_changedList.begin(), _changedList.end(), + changed.begin(), changed.end())) + setDirty(); + _stateList.clear(); _stateList = state; _changedList.clear(); _changedList = changed; - - setDirty(); } diff --git a/src/debugger/gui/TogglePixelWidget.cxx b/src/debugger/gui/TogglePixelWidget.cxx index 1cdb80bae..c26600130 100644 --- a/src/debugger/gui/TogglePixelWidget.cxx +++ b/src/debugger/gui/TogglePixelWidget.cxx @@ -51,15 +51,18 @@ void TogglePixelWidget::setState(const BoolArray& state) for(int col = 0; col < _cols; col++) { int pos = row * _cols + col; + bool changed = _stateList[pos] != state[pos]; - _changedList[pos] = _stateList[pos] != state[pos]; + if(_changedList[pos] != changed) + { + _changedList[pos] = changed; + setDirty(); + } } } _stateList.clear(); _stateList = state; - - setDirty(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -113,6 +116,16 @@ int TogglePixelWidget::getIntState() return value; } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void TogglePixelWidget::setCrossed(bool enable) +{ + if(_crossBits != enable) + { + _crossBits = enable; + setDirty(); + } +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void TogglePixelWidget::drawWidget(bool hilite) { diff --git a/src/debugger/gui/TogglePixelWidget.hxx b/src/debugger/gui/TogglePixelWidget.hxx index fe63cd964..503404c6f 100644 --- a/src/debugger/gui/TogglePixelWidget.hxx +++ b/src/debugger/gui/TogglePixelWidget.hxx @@ -39,7 +39,7 @@ class TogglePixelWidget : public ToggleWidget void setIntState(int value, bool swap = false); int getIntState(); - void setCrossed(bool enable) { _crossBits = enable; } + void setCrossed(bool enable); private: ColorId _pixelColor{kNone}, _backgroundColor{kDlgColor}; diff --git a/src/gui/ColorWidget.cxx b/src/gui/ColorWidget.cxx index 5f31df35d..94ef4bbf4 100644 --- a/src/gui/ColorWidget.cxx +++ b/src/gui/ColorWidget.cxx @@ -37,8 +37,21 @@ ColorWidget::ColorWidget(GuiObject* boss, const GUI::Font& font, // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void ColorWidget::setColor(ColorId color) { - _color = color; - setDirty(); + if(_color != color) + { + _color = color; + setDirty(); + } +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void ColorWidget::setCrossed(bool enable) +{ + if(_crossGrid != enable) + { + _crossGrid = enable; + setDirty(); + } } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/gui/ColorWidget.hxx b/src/gui/ColorWidget.hxx index 4d39871fa..0ec099a95 100644 --- a/src/gui/ColorWidget.hxx +++ b/src/gui/ColorWidget.hxx @@ -42,7 +42,7 @@ class ColorWidget : public Widget, public CommandSender void setColor(ColorId color); ColorId getColor() const { return _color; } - void setCrossed(bool enable) { _crossGrid = enable; } + void setCrossed(bool enable); protected: void drawWidget(bool hilite) override; diff --git a/src/gui/EditTextWidget.cxx b/src/gui/EditTextWidget.cxx index 6a0f32877..dde104002 100644 --- a/src/gui/EditTextWidget.cxx +++ b/src/gui/EditTextWidget.cxx @@ -46,7 +46,11 @@ void EditTextWidget::setText(const string& str, bool changed) { EditableWidget::setText(str, changed); _backupString = str; - _changed = changed; + if(_changed != changed) + { + _changed = changed; + setDirty(); + } } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/gui/EditableWidget.cxx b/src/gui/EditableWidget.cxx index e015dd899..eaadbaeeb 100644 --- a/src/gui/EditableWidget.cxx +++ b/src/gui/EditableWidget.cxx @@ -43,14 +43,18 @@ EditableWidget::EditableWidget(GuiObject* boss, const GUI::Font& font, } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void EditableWidget::setText(const string& str, bool) +void EditableWidget::setText(const string& str, bool changed) { + const string oldEditString = _editString; // Filter input string _editString = ""; for(char c: str) if(_filter(tolower(c))) _editString.push_back(c); + if(oldEditString != _editString) + setDirty(); + myUndoHandler->reset(); myUndoHandler->doo(_editString); @@ -60,8 +64,6 @@ void EditableWidget::setText(const string& str, bool) _editScrollOffset = (_font.getStringWidth(_editString) - (getEditRect().w())); if (_editScrollOffset < 0) _editScrollOffset = 0; - - setDirty(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/gui/PopUpWidget.cxx b/src/gui/PopUpWidget.cxx index eb35ed9c3..b4dd27b84 100644 --- a/src/gui/PopUpWidget.cxx +++ b/src/gui/PopUpWidget.cxx @@ -78,7 +78,11 @@ void PopUpWidget::setSelected(const Variant& tag, const Variant& def) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void PopUpWidget::setSelectedIndex(int idx, bool changed) { - _changed = changed; + if(_changed != changed) + { + _changed = changed; + setDirty(); + } myMenu->setSelectedIndex(idx); setText(myMenu->getSelectedName()); } @@ -86,6 +90,11 @@ void PopUpWidget::setSelectedIndex(int idx, bool changed) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void PopUpWidget::setSelectedMax(bool changed) { + if(_changed != changed) + { + _changed = changed; + setDirty(); + } _changed = changed; myMenu->setSelectedMax(); setText(myMenu->getSelectedName()); diff --git a/src/gui/ScrollBarWidget.cxx b/src/gui/ScrollBarWidget.cxx index 4bacbeece..c9d68cb82 100644 --- a/src/gui/ScrollBarWidget.cxx +++ b/src/gui/ScrollBarWidget.cxx @@ -251,6 +251,9 @@ void ScrollBarWidget::handleMouseLeft() void ScrollBarWidget::recalc() { //cerr << "ScrollBarWidget::recalc()\n"; + int oldSliderHeight = _sliderHeight, + oldSliderPos = _sliderPos; + if(_numEntries > _entriesPerPage) { _sliderHeight = (_h - 2 * _upDownBoxHeight) * _entriesPerPage / _numEntries; @@ -268,7 +271,8 @@ void ScrollBarWidget::recalc() _sliderPos = _upDownBoxHeight; } - setDirty(); + if(oldSliderHeight != _sliderHeight || oldSliderPos != _sliderPos) + setDirty(); // only set dirty when something changed } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/gui/TabWidget.cxx b/src/gui/TabWidget.cxx index 3c7d48258..89967d041 100644 --- a/src/gui/TabWidget.cxx +++ b/src/gui/TabWidget.cxx @@ -110,6 +110,9 @@ void TabWidget::setActiveTab(int tabID, bool show) _tabs[_activeTab].firstWidget = _firstWidget; } + if(_activeTab != tabID) + setDirty(); + _activeTab = tabID; _firstWidget = _tabs[tabID].firstWidget; @@ -138,8 +141,6 @@ void TabWidget::updateActiveTab() if(_tabs[_activeTab].parentWidget) _tabs[_activeTab].parentWidget->loadConfig(); - setDirty(); - // Redraw focused areas _boss->redrawFocus(); // TJ: Does nothing! } diff --git a/src/gui/Widget.cxx b/src/gui/Widget.cxx index 61b9296cb..38c46bdbe 100644 --- a/src/gui/Widget.cxx +++ b/src/gui/Widget.cxx @@ -425,20 +425,19 @@ StaticTextWidget::StaticTextWidget(GuiObject* boss, const GUI::Font& font, // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void StaticTextWidget::setValue(int value) { - _label = std::to_string(value); - - setDirty(); + setLabel(std::to_string(value)); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void StaticTextWidget::setLabel(const string& label) { - _label = label; - - setDirty(); + if(_label != label) + { + _label = label; + setDirty(); + } } - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void StaticTextWidget::handleMouseEntered() { @@ -710,12 +709,13 @@ void CheckboxWidget::setFill(FillType type) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void CheckboxWidget::setState(bool state, bool changed) { - if(_state != state) + if(_state != state || _changed != changed) { - _state = state; setDirty(); + + _state = state; + _changed = changed; } - _changed = changed; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -