mirror of https://github.com/PCSX2/pcsx2.git
Optimize register list drawing
This commit is contained in:
parent
fc98fc9781
commit
a3dea9b243
|
@ -64,7 +64,7 @@ CtrlRegisterList::CtrlRegisterList(wxWindow* parent, DebugInterface* _cpu)
|
||||||
maxLen = std::max<int>(maxLen,strlen(cpu->getRegisterName(i,k)));
|
maxLen = std::max<int>(maxLen,strlen(cpu->getRegisterName(i,k)));
|
||||||
}
|
}
|
||||||
|
|
||||||
int x = 17+(maxLen+3)*charWidth;
|
int x = 17+(maxLen+2)*charWidth;
|
||||||
startPositions.push_back(x);
|
startPositions.push_back(x);
|
||||||
currentRows.push_back(0);
|
currentRows.push_back(0);
|
||||||
}
|
}
|
||||||
|
@ -193,48 +193,51 @@ void CtrlRegisterList::OnDraw(wxDC& dc)
|
||||||
#endif
|
#endif
|
||||||
dc.SetFont(font);
|
dc.SetFont(font);
|
||||||
|
|
||||||
// clear background
|
|
||||||
wxColor white = wxColor(0xFFFFFFFF);
|
|
||||||
|
|
||||||
dc.SetBrush(wxBrush(white));
|
|
||||||
dc.SetPen(wxPen(white));
|
|
||||||
|
|
||||||
wxSize size = GetClientSize();
|
|
||||||
dc.DrawRectangle(0,0,size.x,size.y);
|
|
||||||
|
|
||||||
refreshChangedRegs();
|
refreshChangedRegs();
|
||||||
|
|
||||||
wxColor colorChanged = wxColor(0xFF0000FF);
|
wxColor colorChanged = wxColor(0xFF0000FF);
|
||||||
wxColor colorUnchanged = wxColor(0xFF004000);
|
wxColor colorUnchanged = wxColor(0xFF004000);
|
||||||
wxColor colorNormal = wxColor(0xFF600000);
|
wxColor colorNormal = wxColor(0xFF600000);
|
||||||
|
|
||||||
|
int startRow;
|
||||||
|
GetViewStart(nullptr,&startRow);
|
||||||
|
int endRow = startRow + ceil(float(GetClientSize().y) / rowHeight);
|
||||||
|
|
||||||
// draw categories
|
// draw categories
|
||||||
int piece = size.x/cpu->getRegisterCategoryCount();
|
int width = GetClientSize().x;
|
||||||
for (int i = 0; i < cpu->getRegisterCategoryCount(); i++)
|
if (startRow == 0)
|
||||||
{
|
{
|
||||||
const char* name = cpu->getRegisterCategoryName(i);
|
int piece = width /cpu->getRegisterCategoryCount();
|
||||||
|
for (int i = 0; i < cpu->getRegisterCategoryCount(); i++)
|
||||||
int x = i*piece;
|
|
||||||
|
|
||||||
if (i == category)
|
|
||||||
{
|
{
|
||||||
dc.SetBrush(wxBrush(wxColor(0xFF70FF70)));
|
const char* name = cpu->getRegisterCategoryName(i);
|
||||||
dc.SetPen(wxPen(wxColor(0xFF000000)));
|
|
||||||
} else {
|
|
||||||
dc.SetBrush(wxBrush(wxColor(0xFFFFEFE8)));
|
|
||||||
dc.SetPen(wxPen(wxColor(0xFF000000)));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (i == cpu->getRegisterCategoryCount()-1)
|
int x = i*piece;
|
||||||
piece += size.x-piece*cpu->getRegisterCategoryCount()-1;
|
|
||||||
|
if (i == category)
|
||||||
|
{
|
||||||
|
dc.SetBrush(wxBrush(wxColor(0xFF70FF70)));
|
||||||
|
dc.SetPen(wxPen(wxColor(0xFF000000)));
|
||||||
|
} else {
|
||||||
|
dc.SetBrush(wxBrush(wxColor(0xFFFFEFE8)));
|
||||||
|
dc.SetPen(wxPen(wxColor(0xFF000000)));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i == cpu->getRegisterCategoryCount()-1)
|
||||||
|
piece += width-piece*cpu->getRegisterCategoryCount()-1;
|
||||||
|
|
||||||
dc.DrawRectangle(x,0,piece+1,rowHeight);
|
dc.DrawRectangle(x,0,piece+1,rowHeight);
|
||||||
|
|
||||||
// center text
|
// center text
|
||||||
x += (piece-strlen(name)*charWidth)/2;
|
x += (piece-strlen(name)*charWidth)/2;
|
||||||
dc.DrawText(wxString(name,wxConvUTF8),x,2);
|
dc.DrawText(wxString(name,wxConvUTF8),x,2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// skip the tab row
|
||||||
|
startRow = std::max<int>(0,startRow-1);
|
||||||
|
endRow = std::min<int>(cpu->getRegisterCount(category)-1,endRow-1);
|
||||||
|
|
||||||
int nameStart = 17;
|
int nameStart = 17;
|
||||||
int valueStart = startPositions[category];
|
int valueStart = startPositions[category];
|
||||||
|
|
||||||
|
@ -242,23 +245,22 @@ void CtrlRegisterList::OnDraw(wxDC& dc)
|
||||||
int registerBits = cpu->getRegisterSize(category);
|
int registerBits = cpu->getRegisterSize(category);
|
||||||
DebugInterface::RegisterType type = cpu->getRegisterType(category);
|
DebugInterface::RegisterType type = cpu->getRegisterType(category);
|
||||||
|
|
||||||
for (int i = 0; i < cpu->getRegisterCount(category); i++)
|
for (int i = startRow; i <= endRow; i++)
|
||||||
{
|
{
|
||||||
int x = valueStart;
|
int x = valueStart;
|
||||||
int y = rowHeight*(i+1);
|
int y = rowHeight*(i+1);
|
||||||
|
|
||||||
|
wxColor backgroundColor;
|
||||||
if (currentRows[category] == i)
|
if (currentRows[category] == i)
|
||||||
{
|
backgroundColor = wxColor(0xFFFFCFC8);
|
||||||
dc.SetBrush(wxBrush(wxColor(0xFFFFCFC8)));
|
else if (i % 2)
|
||||||
dc.SetPen(wxPen(wxColor(0xFFFFEFE8)));
|
backgroundColor = wxColor(237, 242, 255, 255);
|
||||||
dc.DrawRectangle(0,y,size.x,rowHeight);
|
else
|
||||||
} else if (i % 2)
|
backgroundColor = wxColor(0xFFFFFFFF);
|
||||||
{
|
|
||||||
wxColor color = wxColor(237,242,255,255);
|
dc.SetBrush(backgroundColor);
|
||||||
dc.SetBrush(wxBrush(color));
|
dc.SetPen(backgroundColor);
|
||||||
dc.SetPen(wxPen(color));
|
dc.DrawRectangle(0, y, width, rowHeight);
|
||||||
dc.DrawRectangle(0, y, size.x, rowHeight);
|
|
||||||
}
|
|
||||||
|
|
||||||
const char* name = cpu->getRegisterName(category,i);
|
const char* name = cpu->getRegisterName(category,i);
|
||||||
dc.SetTextForeground(colorNormal);
|
dc.SetTextForeground(colorNormal);
|
||||||
|
@ -275,7 +277,7 @@ void CtrlRegisterList::OnDraw(wxDC& dc)
|
||||||
case 128:
|
case 128:
|
||||||
{
|
{
|
||||||
int startIndex = std::min<int>(3,maxBits/32-1);
|
int startIndex = std::min<int>(3,maxBits/32-1);
|
||||||
int actualX = size.x-4-(startIndex+1)*(8*charWidth+2);
|
int actualX = width-4-(startIndex+1)*(8*charWidth+2);
|
||||||
x = std::max<int>(actualX,x);
|
x = std::max<int>(actualX,x);
|
||||||
|
|
||||||
if (startIndex != 3)
|
if (startIndex != 3)
|
||||||
|
@ -377,10 +379,10 @@ void CtrlRegisterList::changeValue(RegisterChangeMode mode)
|
||||||
oldValue._u64[0] = newValue;
|
oldValue._u64[0] = newValue;
|
||||||
break;
|
break;
|
||||||
case UPPER64:
|
case UPPER64:
|
||||||
oldValue._u64[1] = newValue;
|
oldValue._u64[1] = newValue;
|
||||||
break;
|
break;
|
||||||
case CHANGE32:
|
case CHANGE32:
|
||||||
oldValue._u32[0] = newValue;
|
oldValue._u32[0] = newValue;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue