Inline the autolock hack and use it for both surfaces

This commit is contained in:
YoshiRulz 2021-02-24 10:41:28 +10:00
parent cc7e440fba
commit 2859d6c45b
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
1 changed files with 16 additions and 15 deletions

View File

@ -83,12 +83,26 @@ namespace BizHawk.Client.Common
private DisplaySurface GetRelevantSurface(DisplaySurfaceID? surfaceID) private DisplaySurface GetRelevantSurface(DisplaySurfaceID? surfaceID)
{ {
switch (surfaceID ?? _usingSurfaceID) var nnID = surfaceID ?? _usingSurfaceID ?? throw new Exception();
void ThisIsTheLuaAutolockHack()
{
try
{
UnlockSurface(nnID);
LockSurface(nnID);
}
catch (InvalidOperationException ex)
{
LogCallback(ex.ToString());
}
}
switch (nnID)
{ {
case DisplaySurfaceID.EmuCore: case DisplaySurfaceID.EmuCore:
if (_GUISurface == null && EnableLuaAutolockHack) LockEmuSurfaceLua(); if (_GUISurface == null && EnableLuaAutolockHack) ThisIsTheLuaAutolockHack();
return _GUISurface; return _GUISurface;
case DisplaySurfaceID.Client: case DisplaySurfaceID.Client:
if (_clientSurface == null && EnableLuaAutolockHack) ThisIsTheLuaAutolockHack();
return _clientSurface; return _clientSurface;
default: default:
throw new Exception(); throw new Exception();
@ -144,19 +158,6 @@ namespace BizHawk.Client.Common
} }
} }
public void LockEmuSurfaceLua()
{
try
{
UnlockSurface(DisplaySurfaceID.EmuCore);
LockSurface(DisplaySurfaceID.EmuCore);
}
catch (InvalidOperationException ex)
{
LogCallback(ex.ToString());
}
}
public void UnlockEmuSurfaceLua() => UnlockSurface(DisplaySurfaceID.EmuCore); public void UnlockEmuSurfaceLua() => UnlockSurface(DisplaySurfaceID.EmuCore);
public void DrawNew(string name, bool clear) public void DrawNew(string name, bool clear)