mirror of
https://github.com/libretro/Mesen.git
synced 2024-12-16 05:48:05 +00:00
Debugger: Fixed performance for nametable viewer grids
This commit is contained in:
parent
9b5917cd31
commit
69ca41daae
@ -17,6 +17,7 @@ namespace Mesen.GUI.Debugger.Controls
|
||||
private byte[][] _nametablePixelData = new byte[4][];
|
||||
private byte[][] _tileData = new byte[4][];
|
||||
private byte[][] _attributeData = new byte[4][];
|
||||
private Bitmap _gridOverlay;
|
||||
|
||||
public ctrlNametableViewer()
|
||||
{
|
||||
@ -54,19 +55,29 @@ namespace Mesen.GUI.Debugger.Controls
|
||||
}
|
||||
}
|
||||
|
||||
if(chkShowTileGrid.Checked) {
|
||||
using(Pen pen = new Pen(Color.FromArgb(chkShowAttributeGrid.Checked ? 120 : 180, 240, 100, 120))) {
|
||||
if(chkShowAttributeGrid.Checked) {
|
||||
pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot;
|
||||
if(this._gridOverlay == null && (chkShowTileGrid.Checked || chkShowAttributeGrid.Checked)) {
|
||||
this._gridOverlay = new Bitmap(512, 480);
|
||||
|
||||
using(Graphics overlay = Graphics.FromImage(this._gridOverlay)) {
|
||||
if(chkShowTileGrid.Checked) {
|
||||
using(Pen pen = new Pen(Color.FromArgb(chkShowAttributeGrid.Checked ? 120 : 180, 240, 100, 120))) {
|
||||
if(chkShowAttributeGrid.Checked) {
|
||||
pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot;
|
||||
}
|
||||
DrawGrid(overlay, pen, 1);
|
||||
}
|
||||
}
|
||||
|
||||
if(chkShowAttributeGrid.Checked) {
|
||||
using(Pen pen = new Pen(Color.FromArgb(180, 80, 130, 250))) {
|
||||
DrawGrid(overlay, pen, 2);
|
||||
}
|
||||
}
|
||||
DrawGrid(g, pen, 1);
|
||||
}
|
||||
}
|
||||
|
||||
if(chkShowAttributeGrid.Checked) {
|
||||
using(Pen pen = new Pen(Color.FromArgb(180, 80, 130, 250))) {
|
||||
DrawGrid(g, pen, 2);
|
||||
}
|
||||
if(this._gridOverlay != null) {
|
||||
g.DrawImage(this._gridOverlay, 0, 0);
|
||||
}
|
||||
|
||||
if(chkShowPpuScrollOverlay.Checked) {
|
||||
@ -167,6 +178,7 @@ namespace Mesen.GUI.Debugger.Controls
|
||||
{
|
||||
ConfigManager.Config.DebugInfo.ShowTileGrid = chkShowTileGrid.Checked;
|
||||
ConfigManager.ApplyChanges();
|
||||
this._gridOverlay = null;
|
||||
this.RefreshViewer();
|
||||
}
|
||||
|
||||
@ -174,6 +186,7 @@ namespace Mesen.GUI.Debugger.Controls
|
||||
{
|
||||
ConfigManager.Config.DebugInfo.ShowAttributeGrid = chkShowAttributeGrid.Checked;
|
||||
ConfigManager.ApplyChanges();
|
||||
this._gridOverlay = null;
|
||||
this.RefreshViewer();
|
||||
}
|
||||
}
|
||||
|
@ -16,9 +16,11 @@ namespace Mesen.GUI.Debugger
|
||||
{
|
||||
public partial class frmPpuViewer : BaseForm
|
||||
{
|
||||
private DateTime _lastUpdate = DateTime.MinValue;
|
||||
private InteropEmu.NotificationListener _notifListener;
|
||||
private int _autoRefreshCounter = 0;
|
||||
private TabPage _selectedTab;
|
||||
private bool _refreshing = false;
|
||||
|
||||
public frmPpuViewer()
|
||||
{
|
||||
@ -59,10 +61,12 @@ namespace Mesen.GUI.Debugger
|
||||
this.GetData();
|
||||
this.BeginInvoke((MethodInvoker)(() => this.RefreshViewers()));
|
||||
} else if(e.NotificationType == InteropEmu.ConsoleNotificationType.PpuViewerDisplayFrame) {
|
||||
if(_autoRefreshCounter % 4 == 0) {
|
||||
if(!_refreshing && (DateTime.Now - _lastUpdate).Milliseconds > 66) {
|
||||
//Update at 15 fps most
|
||||
this.GetData();
|
||||
this.BeginInvoke((MethodInvoker)(() => this.RefreshViewers()));
|
||||
_lastUpdate = DateTime.Now;
|
||||
}
|
||||
this.BeginInvoke((MethodInvoker)(() => this.AutoRefresh()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -81,6 +85,7 @@ namespace Mesen.GUI.Debugger
|
||||
|
||||
private void RefreshViewers()
|
||||
{
|
||||
_refreshing = true;
|
||||
if(_selectedTab == this.tpgNametableViewer) {
|
||||
this.ctrlNametableViewer.RefreshViewer();
|
||||
} else if(_selectedTab == this.tpgChrViewer) {
|
||||
@ -90,16 +95,9 @@ namespace Mesen.GUI.Debugger
|
||||
} else if(_selectedTab == this.tpgPaletteViewer) {
|
||||
this.ctrlPaletteViewer.RefreshViewer();
|
||||
}
|
||||
_refreshing = false;
|
||||
}
|
||||
|
||||
private void AutoRefresh()
|
||||
{
|
||||
if(_autoRefreshCounter % 4 == 0 && this.mnuAutoRefresh.Checked) {
|
||||
this.RefreshViewers();
|
||||
}
|
||||
_autoRefreshCounter++;
|
||||
}
|
||||
|
||||
private void mnuRefresh_Click(object sender, EventArgs e)
|
||||
{
|
||||
this.RefreshViewers();
|
||||
|
Loading…
Reference in New Issue
Block a user