Remove use of the dynamic type from BizwareGL

This commit is contained in:
YoshiRulz 2021-09-15 06:00:05 +10:00
parent 2d81c820b4
commit fc0ebf372f
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
3 changed files with 9 additions and 10 deletions

View File

@ -9,7 +9,6 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Cyotek.Drawing.BitmapFont" Version="2.0.2" />
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" /><!-- for (extra?) dynamic type support -->
<PackageReference Include="System.Drawing.Common" Version="5.0.2" />
<ProjectReference Include="$(ProjectDir)../BizHawk.Common/BizHawk.Common.csproj" />
</ItemGroup>

View File

@ -9,10 +9,10 @@ namespace BizHawk.Bizware.BizwareGL
{
public class GDIPlusGuiRenderer : IGuiRenderer
{
public GDIPlusGuiRenderer(IGL gl)
{
Owner = gl;
}
private readonly IGL_GdiPlus Gdi;
public GDIPlusGuiRenderer(IGL_GdiPlus gl)
=> Gdi = gl;
private readonly Vector4[] CornerColors = { new(1.0f, 1.0f, 1.0f, 1.0f), new(1.0f, 1.0f, 1.0f, 1.0f), new(1.0f, 1.0f, 1.0f, 1.0f), new(1.0f, 1.0f, 1.0f, 1.0f) };
@ -151,7 +151,7 @@ namespace BizHawk.Bizware.BizwareGL
public void DrawSubrect(Texture2d tex, float x, float y, float w, float h, float u0, float v0, float u1, float v1)
{
var tw = tex.Opaque as GDIPTextureWrapper;
var g = ((dynamic) Gdi).GetCurrentGraphics() as sd.Graphics;
var g = Gdi.GetCurrentGraphics();
PrepDraw(g, tex);
SetupMatrix(g);
@ -239,7 +239,7 @@ namespace BizHawk.Bizware.BizwareGL
private void DrawInternal(Texture2d tex, float x, float y, float w, float h, float u0, float v0, float u1, float v1)
{
var g = ((dynamic) Gdi).GetCurrentGraphics() as sd.Graphics;
var g = Gdi.GetCurrentGraphics();
PrepDraw(g, tex);
SetupMatrix(g);
@ -268,7 +268,7 @@ namespace BizHawk.Bizware.BizwareGL
}
public bool IsActive { get; private set; }
public IGL Owner { get; }
public IGL Gdi => Owner;
public IGL Owner => Gdi;
}
}

View File

@ -11,7 +11,7 @@ namespace BizHawk.Client.EmuHawk
{
public static IGuiRenderer CreateRenderer(this IGL gl) => gl switch
{
IGL_GdiPlus => new GDIPlusGuiRenderer(gl),
IGL_GdiPlus gdipImpl => new GDIPlusGuiRenderer(gdipImpl),
IGL_SlimDX9 => new GuiRenderer(gl),
IGL_TK => new GuiRenderer(gl),
_ => throw new NotSupportedException()