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:
adelikat 2013-08-23 02:40:14 +00:00
parent 39ee86fa92
commit 36489ca95a
5 changed files with 2757 additions and 2709 deletions

View File

@ -391,16 +391,20 @@ namespace BizHawk.MultiClient
public void AddMessage(string message) public void AddMessage(string message)
{ {
Global.DisplayManager.NeedsToPaint = true;
messages.Add(new UIMessage { Message = message, ExpireAt = DateTime.Now + TimeSpan.FromSeconds(2) }); 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) 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 }); GUITextList.Add(new UIDisplay { Message = message, X = x, Y = y, BackGround = BackGround, ForeColor = ForeColor, Alert = alert, Anchor = anchor });
} }
public void ClearGUIText() public void ClearGUIText()
{ {
Global.DisplayManager.NeedsToPaint = true;
GUITextList.Clear(); GUITextList.Clear();
} }
@ -476,6 +480,8 @@ namespace BizHawk.MultiClient
public string MakeInputDisplay() public string MakeInputDisplay()
{ {
var blah = DateTime.Now.Ticks;
return blah.ToString();
StringBuilder s; StringBuilder s;
if (!Global.MovieSession.Movie.IsActive || Global.MovieSession.Movie.IsFinished) if (!Global.MovieSession.Movie.IsActive || Global.MovieSession.Movie.IsFinished)
{ {
@ -645,6 +651,7 @@ namespace BizHawk.MultiClient
readonly SwappableDisplaySurfaceSet sourceSurfaceSet = new SwappableDisplaySurfaceSet(); readonly SwappableDisplaySurfaceSet sourceSurfaceSet = new SwappableDisplaySurfaceSet();
public bool NeedsToPaint { get; set; }
DisplaySurface luaEmuSurface = null; DisplaySurface luaEmuSurface = null;
public void PreFrameUpdateLuaSource() public void PreFrameUpdateLuaSource()
@ -712,6 +719,8 @@ namespace BizHawk.MultiClient
if (filteredSurface != null) if (filteredSurface != null)
filteredSurface.Dispose(); filteredSurface.Dispose();
filteredSurface = null; filteredSurface = null;
NeedsToPaint = false;
} }
public bool Disposed { get; private set; } public bool Disposed { get; private set; }

View File

@ -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) 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); 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) 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()) using (var g = GetGraphics())
{ {
try try
@ -943,6 +945,7 @@ namespace BizHawk.MultiClient
public void gui_drawPixel(object X, object Y, object color = null) public void gui_drawPixel(object X, object Y, object color = null)
{ {
Global.DisplayManager.NeedsToPaint = true;
using (var g = GetGraphics()) using (var g = GetGraphics())
{ {
float x = LuaInt(X) + 0.1F; 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) public void gui_drawLine(object x1, object y1, object x2, object y2, object color = null)
{ {
Global.DisplayManager.NeedsToPaint = true;
using (var g = GetGraphics()) using (var g = GetGraphics())
{ {
try 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) 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()) using (var g = GetGraphics())
{ {
try try
@ -995,6 +1000,7 @@ namespace BizHawk.MultiClient
public void gui_drawPolygon(LuaTable points, object line, object background = null) public void gui_drawPolygon(LuaTable points, object line, object background = null)
{ {
Global.DisplayManager.NeedsToPaint = true;
//this is a test //this is a test
using (var g = GetGraphics()) using (var g = GetGraphics())
{ {
@ -1038,6 +1044,7 @@ namespace BizHawk.MultiClient
public void gui_drawBezier(LuaTable points, object color) public void gui_drawBezier(LuaTable points, object color)
{ {
Global.DisplayManager.NeedsToPaint = true;
using (var g = GetGraphics()) using (var g = GetGraphics())
{ {
try try
@ -1064,6 +1071,7 @@ namespace BizHawk.MultiClient
public void gui_drawPie(object X, object Y, object width, object height, object startangle, object sweepangle, public void gui_drawPie(object X, object Y, object width, object height, object startangle, object sweepangle,
object line, object background = null) object line, object background = null)
{ {
Global.DisplayManager.NeedsToPaint = true;
using (var g = GetGraphics()) using (var g = GetGraphics())
{ {
try try
@ -1085,6 +1093,7 @@ namespace BizHawk.MultiClient
public void gui_drawIcon(object Path, object x, object y, object width = null, object height = null) public void gui_drawIcon(object Path, object x, object y, object width = null, object height = null)
{ {
Global.DisplayManager.NeedsToPaint = true;
using (var g = GetGraphics()) using (var g = GetGraphics())
{ {
try try
@ -1110,6 +1119,7 @@ namespace BizHawk.MultiClient
public void gui_drawImage(object Path, object x, object y, object width = null, object height = null) public void gui_drawImage(object Path, object x, object y, object width = null, object height = null)
{ {
Global.DisplayManager.NeedsToPaint = true;
using (var g = GetGraphics()) using (var g = GetGraphics())
{ {
try try
@ -1132,6 +1142,7 @@ namespace BizHawk.MultiClient
public void gui_clearGraphics() public void gui_clearGraphics()
{ {
Global.DisplayManager.NeedsToPaint = true;
luaSurface.Clear(); luaSurface.Clear();
} }
@ -1146,6 +1157,7 @@ namespace BizHawk.MultiClient
public void emu_yield() public void emu_yield()
{ {
Global.DisplayManager.NeedsToPaint = true;
currThread.Yield(0); currThread.Yield(0);
} }

File diff suppressed because it is too large Load Diff

View File

@ -482,21 +482,25 @@ namespace BizHawk.MultiClient
private void displayFPSToolStripMenuItem_Click(object sender, EventArgs e) private void displayFPSToolStripMenuItem_Click(object sender, EventArgs e)
{ {
Global.DisplayManager.NeedsToPaint = true;
ToggleFPS(); ToggleFPS();
} }
private void displayFrameCounterToolStripMenuItem_Click(object sender, EventArgs e) private void displayFrameCounterToolStripMenuItem_Click(object sender, EventArgs e)
{ {
Global.DisplayManager.NeedsToPaint = true;
ToggleFrameCounter(); ToggleFrameCounter();
} }
private void displayInputToolStripMenuItem_Click(object sender, EventArgs e) private void displayInputToolStripMenuItem_Click(object sender, EventArgs e)
{ {
Global.DisplayManager.NeedsToPaint = true;
ToggleInputDisplay(); ToggleInputDisplay();
} }
private void displayLagCounterToolStripMenuItem_Click(object sender, EventArgs e) private void displayLagCounterToolStripMenuItem_Click(object sender, EventArgs e)
{ {
Global.DisplayManager.NeedsToPaint = true;
ToggleLagCounter(); ToggleLagCounter();
} }
@ -705,6 +709,7 @@ namespace BizHawk.MultiClient
private void displayRerecordCountToolStripMenuItem_Click(object sender, EventArgs e) private void displayRerecordCountToolStripMenuItem_Click(object sender, EventArgs e)
{ {
Global.DisplayManager.NeedsToPaint = true;
Global.Config.DisplayRerecordCount ^= true; Global.Config.DisplayRerecordCount ^= true;
} }
@ -1127,6 +1132,7 @@ namespace BizHawk.MultiClient
private void displaySubtitlesToolStripMenuItem_Click(object sender, EventArgs e) private void displaySubtitlesToolStripMenuItem_Click(object sender, EventArgs e)
{ {
Global.DisplayManager.NeedsToPaint = true;
Global.Config.DisplaySubtitles ^= true; Global.Config.DisplaySubtitles ^= true;
} }
@ -1325,6 +1331,7 @@ namespace BizHawk.MultiClient
private void menuStrip1_MenuDeactivate(object sender, EventArgs e) private void menuStrip1_MenuDeactivate(object sender, EventArgs e)
{ {
Global.DisplayManager.NeedsToPaint = true;
if (!wasPaused) if (!wasPaused)
{ {
UnpauseEmulator(); UnpauseEmulator();

View File

@ -622,7 +622,7 @@ namespace BizHawk.MultiClient
//if(!IsNullEmulator()) //if(!IsNullEmulator())
StepRunLoop_Throttle(); StepRunLoop_Throttle();
Render(); if (Global.DisplayManager.NeedsToPaint) { Render(); }
CheckMessages(); CheckMessages();
if (exit) if (exit)
@ -2201,6 +2201,7 @@ namespace BizHawk.MultiClient
//======================================= //=======================================
MemoryPulse.Pulse(); MemoryPulse.Pulse();
Global.Emulator.FrameAdvance(!throttle.skipnextframe || CurrAviWriter != null, !coreskipaudio); Global.Emulator.FrameAdvance(!throttle.skipnextframe || CurrAviWriter != null, !coreskipaudio);
Global.DisplayManager.NeedsToPaint = true;
MemoryPulse.Pulse(); MemoryPulse.Pulse();
//======================================= //=======================================
@ -2483,6 +2484,7 @@ namespace BizHawk.MultiClient
public void LoadStateFile(string path, string name, bool fromLua = false) public void LoadStateFile(string path, string name, bool fromLua = false)
{ {
Global.DisplayManager.NeedsToPaint = true;
// try to detect binary first // try to detect binary first
BinaryStateLoader bw = BinaryStateLoader.LoadAndDetect(path); BinaryStateLoader bw = BinaryStateLoader.LoadAndDetect(path);
if (bw != null) if (bw != null)
@ -4141,5 +4143,20 @@ namespace BizHawk.MultiClient
{ {
new FirmwaresConfig().Show(); 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;
}
} }
} }