Only paint the screen when needed, which is once per frame, or when the OSD is invoked. Also when lua draws things. I think I invoked it in all the logical places but probably missed some things. The lua logic needs to be refactored anyway to have a paint method, and an onpaint event
This commit is contained in:
parent
39ee86fa92
commit
36489ca95a
|
@ -391,16 +391,20 @@ namespace BizHawk.MultiClient
|
|||
|
||||
public void AddMessage(string message)
|
||||
{
|
||||
Global.DisplayManager.NeedsToPaint = true;
|
||||
messages.Add(new UIMessage { Message = message, ExpireAt = DateTime.Now + TimeSpan.FromSeconds(2) });
|
||||
}
|
||||
|
||||
public void AddGUIText(string message, int x, int y, bool alert, Color BackGround, Color ForeColor, int anchor)
|
||||
{
|
||||
Global.DisplayManager.NeedsToPaint = true;
|
||||
GUITextList.Add(new UIDisplay { Message = message, X = x, Y = y, BackGround = BackGround, ForeColor = ForeColor, Alert = alert, Anchor = anchor });
|
||||
}
|
||||
|
||||
public void ClearGUIText()
|
||||
{
|
||||
Global.DisplayManager.NeedsToPaint = true;
|
||||
|
||||
GUITextList.Clear();
|
||||
}
|
||||
|
||||
|
@ -476,6 +480,8 @@ namespace BizHawk.MultiClient
|
|||
|
||||
public string MakeInputDisplay()
|
||||
{
|
||||
var blah = DateTime.Now.Ticks;
|
||||
return blah.ToString();
|
||||
StringBuilder s;
|
||||
if (!Global.MovieSession.Movie.IsActive || Global.MovieSession.Movie.IsFinished)
|
||||
{
|
||||
|
@ -645,6 +651,7 @@ namespace BizHawk.MultiClient
|
|||
|
||||
readonly SwappableDisplaySurfaceSet sourceSurfaceSet = new SwappableDisplaySurfaceSet();
|
||||
|
||||
public bool NeedsToPaint { get; set; }
|
||||
|
||||
DisplaySurface luaEmuSurface = null;
|
||||
public void PreFrameUpdateLuaSource()
|
||||
|
@ -712,6 +719,8 @@ namespace BizHawk.MultiClient
|
|||
if (filteredSurface != null)
|
||||
filteredSurface.Dispose();
|
||||
filteredSurface = null;
|
||||
|
||||
NeedsToPaint = false;
|
||||
}
|
||||
|
||||
public bool Disposed { get; private set; }
|
||||
|
|
|
@ -886,11 +886,13 @@ namespace BizHawk.MultiClient
|
|||
|
||||
public void gui_drawString(object X, object Y, object message, object color = null, object fontsize = null, object fontfamily = null, object fontstyle = null)
|
||||
{
|
||||
Global.DisplayManager.NeedsToPaint = true;
|
||||
gui_drawText(X, Y, message, color, fontsize, fontfamily, fontstyle);
|
||||
}
|
||||
|
||||
public void gui_drawText(object X, object Y, object message, object color = null, object fontsize = null, object fontfamily = null, object fontstyle = null)
|
||||
{
|
||||
Global.DisplayManager.NeedsToPaint = true;
|
||||
using (var g = GetGraphics())
|
||||
{
|
||||
try
|
||||
|
@ -943,6 +945,7 @@ namespace BizHawk.MultiClient
|
|||
|
||||
public void gui_drawPixel(object X, object Y, object color = null)
|
||||
{
|
||||
Global.DisplayManager.NeedsToPaint = true;
|
||||
using (var g = GetGraphics())
|
||||
{
|
||||
float x = LuaInt(X) + 0.1F;
|
||||
|
@ -959,6 +962,7 @@ namespace BizHawk.MultiClient
|
|||
|
||||
public void gui_drawLine(object x1, object y1, object x2, object y2, object color = null)
|
||||
{
|
||||
Global.DisplayManager.NeedsToPaint = true;
|
||||
using (var g = GetGraphics())
|
||||
{
|
||||
try
|
||||
|
@ -974,6 +978,7 @@ namespace BizHawk.MultiClient
|
|||
|
||||
public void gui_drawEllipse(object X, object Y, object width, object height, object line, object background = null)
|
||||
{
|
||||
Global.DisplayManager.NeedsToPaint = true;
|
||||
using (var g = GetGraphics())
|
||||
{
|
||||
try
|
||||
|
@ -995,6 +1000,7 @@ namespace BizHawk.MultiClient
|
|||
|
||||
public void gui_drawPolygon(LuaTable points, object line, object background = null)
|
||||
{
|
||||
Global.DisplayManager.NeedsToPaint = true;
|
||||
//this is a test
|
||||
using (var g = GetGraphics())
|
||||
{
|
||||
|
@ -1038,6 +1044,7 @@ namespace BizHawk.MultiClient
|
|||
|
||||
public void gui_drawBezier(LuaTable points, object color)
|
||||
{
|
||||
Global.DisplayManager.NeedsToPaint = true;
|
||||
using (var g = GetGraphics())
|
||||
{
|
||||
try
|
||||
|
@ -1064,6 +1071,7 @@ namespace BizHawk.MultiClient
|
|||
public void gui_drawPie(object X, object Y, object width, object height, object startangle, object sweepangle,
|
||||
object line, object background = null)
|
||||
{
|
||||
Global.DisplayManager.NeedsToPaint = true;
|
||||
using (var g = GetGraphics())
|
||||
{
|
||||
try
|
||||
|
@ -1085,6 +1093,7 @@ namespace BizHawk.MultiClient
|
|||
|
||||
public void gui_drawIcon(object Path, object x, object y, object width = null, object height = null)
|
||||
{
|
||||
Global.DisplayManager.NeedsToPaint = true;
|
||||
using (var g = GetGraphics())
|
||||
{
|
||||
try
|
||||
|
@ -1110,6 +1119,7 @@ namespace BizHawk.MultiClient
|
|||
|
||||
public void gui_drawImage(object Path, object x, object y, object width = null, object height = null)
|
||||
{
|
||||
Global.DisplayManager.NeedsToPaint = true;
|
||||
using (var g = GetGraphics())
|
||||
{
|
||||
try
|
||||
|
@ -1132,6 +1142,7 @@ namespace BizHawk.MultiClient
|
|||
|
||||
public void gui_clearGraphics()
|
||||
{
|
||||
Global.DisplayManager.NeedsToPaint = true;
|
||||
luaSurface.Clear();
|
||||
}
|
||||
|
||||
|
@ -1146,6 +1157,7 @@ namespace BizHawk.MultiClient
|
|||
|
||||
public void emu_yield()
|
||||
{
|
||||
Global.DisplayManager.NeedsToPaint = true;
|
||||
currThread.Yield(0);
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -482,21 +482,25 @@ namespace BizHawk.MultiClient
|
|||
|
||||
private void displayFPSToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
Global.DisplayManager.NeedsToPaint = true;
|
||||
ToggleFPS();
|
||||
}
|
||||
|
||||
private void displayFrameCounterToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
Global.DisplayManager.NeedsToPaint = true;
|
||||
ToggleFrameCounter();
|
||||
}
|
||||
|
||||
private void displayInputToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
Global.DisplayManager.NeedsToPaint = true;
|
||||
ToggleInputDisplay();
|
||||
}
|
||||
|
||||
private void displayLagCounterToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
Global.DisplayManager.NeedsToPaint = true;
|
||||
ToggleLagCounter();
|
||||
}
|
||||
|
||||
|
@ -705,6 +709,7 @@ namespace BizHawk.MultiClient
|
|||
|
||||
private void displayRerecordCountToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
Global.DisplayManager.NeedsToPaint = true;
|
||||
Global.Config.DisplayRerecordCount ^= true;
|
||||
}
|
||||
|
||||
|
@ -1127,6 +1132,7 @@ namespace BizHawk.MultiClient
|
|||
|
||||
private void displaySubtitlesToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
Global.DisplayManager.NeedsToPaint = true;
|
||||
Global.Config.DisplaySubtitles ^= true;
|
||||
}
|
||||
|
||||
|
@ -1325,6 +1331,7 @@ namespace BizHawk.MultiClient
|
|||
|
||||
private void menuStrip1_MenuDeactivate(object sender, EventArgs e)
|
||||
{
|
||||
Global.DisplayManager.NeedsToPaint = true;
|
||||
if (!wasPaused)
|
||||
{
|
||||
UnpauseEmulator();
|
||||
|
|
|
@ -622,7 +622,7 @@ namespace BizHawk.MultiClient
|
|||
//if(!IsNullEmulator())
|
||||
StepRunLoop_Throttle();
|
||||
|
||||
Render();
|
||||
if (Global.DisplayManager.NeedsToPaint) { Render(); }
|
||||
|
||||
CheckMessages();
|
||||
if (exit)
|
||||
|
@ -2201,6 +2201,7 @@ namespace BizHawk.MultiClient
|
|||
//=======================================
|
||||
MemoryPulse.Pulse();
|
||||
Global.Emulator.FrameAdvance(!throttle.skipnextframe || CurrAviWriter != null, !coreskipaudio);
|
||||
Global.DisplayManager.NeedsToPaint = true;
|
||||
MemoryPulse.Pulse();
|
||||
//=======================================
|
||||
|
||||
|
@ -2483,6 +2484,7 @@ namespace BizHawk.MultiClient
|
|||
|
||||
public void LoadStateFile(string path, string name, bool fromLua = false)
|
||||
{
|
||||
Global.DisplayManager.NeedsToPaint = true;
|
||||
// try to detect binary first
|
||||
BinaryStateLoader bw = BinaryStateLoader.LoadAndDetect(path);
|
||||
if (bw != null)
|
||||
|
@ -4141,5 +4143,20 @@ namespace BizHawk.MultiClient
|
|||
{
|
||||
new FirmwaresConfig().Show();
|
||||
}
|
||||
|
||||
private void menuStrip1_Leave(object sender, EventArgs e)
|
||||
{
|
||||
Global.DisplayManager.NeedsToPaint = true;
|
||||
}
|
||||
|
||||
private void MainForm_Enter(object sender, EventArgs e)
|
||||
{
|
||||
Global.DisplayManager.NeedsToPaint = true;
|
||||
}
|
||||
|
||||
private void MainForm_Paint(object sender, PaintEventArgs e)
|
||||
{
|
||||
Global.DisplayManager.NeedsToPaint = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue