Fix "double rendering" in Lua/ApiHawk gui stuff

This commit is contained in:
CasualPokePlayer 2024-06-01 14:01:01 -07:00
parent dcfe55360a
commit 1a9176e12f
7 changed files with 27 additions and 4 deletions

View File

@ -29,6 +29,12 @@ namespace BizHawk.Bizware.Graphics
/// </summary>
void Clear();
/// <summary>
/// Discards any pending draw calls.
/// Similar to Clear(), except this won't insert a command to clear the target texture
/// </summary>
void Discard();
CompositingMode CompositingMode { set; }
void DrawBezier(Color color, Point pt1, Point pt2, Point pt3, Point pt4);

View File

@ -302,6 +302,9 @@ namespace BizHawk.Bizware.Graphics
_hasClearPending = true;
}
public void Discard()
=> ResetDrawList();
protected bool EnableBlending { get; private set; }
private bool _pendingBlendEnable;

View File

@ -90,7 +90,7 @@ namespace BizHawk.Client.Common
public void DoFrameAdvance()
{
_mainForm.FrameAdvance();
_mainForm.FrameAdvance(discardApiHawkSurfaces: false); // we're rendering, so we don't want to discard
_mainForm.StepRunLoop_Throttle();
_mainForm.Render();
}

View File

@ -933,5 +933,13 @@ namespace BizHawk.Client.Common
renderer.Clear();
}
}
public void DiscardApiHawkSurfaces()
{
foreach (var renderer in _apiHawkIDTo2DRenderer.Values)
{
renderer.Discard();
}
}
}
}

View File

@ -52,7 +52,7 @@ namespace BizHawk.Client.Common
bool FlushSaveRAM(bool autosave = false);
/// <remarks>only referenced from <c>EmuClientApi</c></remarks>
void FrameAdvance();
void FrameAdvance(bool discardApiHawkSurfaces = true);
void FrameBufferResized();

View File

@ -56,7 +56,7 @@ namespace BizHawk.Client.EmuHawk
bool EnsureCoreIsAccurate();
/// <remarks>only referenced from <see cref="TAStudio"/></remarks>
void FrameAdvance();
void FrameAdvance(bool discardApiHawkSurfaces = true);
/// <remarks>only referenced from <see cref="LuaConsole"/></remarks>
void FrameBufferResized();

View File

@ -2477,6 +2477,7 @@ namespace BizHawk.Client.EmuHawk
{
if (Config.DispSpeedupFeatures == 0)
{
DisplayManager.DiscardApiHawkSurfaces();
return;
}
@ -3069,16 +3070,21 @@ namespace BizHawk.Client.EmuHawk
_throttle.Step(Config, Sound, allowSleep: true, forceFrameSkip: -1);
}
public void FrameAdvance()
public void FrameAdvance(bool discardApiHawkSurfaces)
{
PressFrameAdvance = true;
StepRunLoop_Core(true);
if (discardApiHawkSurfaces)
{
DisplayManager.DiscardApiHawkSurfaces();
}
}
public void SeekFrameAdvance()
{
PressFrameAdvance = true;
StepRunLoop_Core(true);
DisplayManager.DiscardApiHawkSurfaces();
PressFrameAdvance = false;
}