Decouple IGL_GdiPlus from GLControlWrapper_GdiPlus

This commit is contained in:
YoshiRulz 2021-06-15 10:01:57 +10:00
parent 673982003a
commit 5bdeea6c20
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
6 changed files with 27 additions and 7 deletions

View File

@ -7,6 +7,8 @@ namespace BizHawk.Bizware.BizwareGL
{ {
Rectangle ClientRectangle { get; } Rectangle ClientRectangle { get; }
RenderTargetWrapper RenderTargetWrapper { get; set; }
Graphics CreateGraphics(); Graphics CreateGraphics();
/// <summary> /// <summary>

View File

@ -8,6 +8,12 @@ namespace BizHawk.Bizware.DirectX
{ {
public sealed class GLControlWrapperSlimDX9 : Control, IGraphicsControl public sealed class GLControlWrapperSlimDX9 : Control, IGraphicsControl
{ {
public RenderTargetWrapper RenderTargetWrapper
{
get => throw new NotImplementedException();
set => throw new NotImplementedException();
}
public GLControlWrapperSlimDX9(IGL_SlimDX9 sdx) public GLControlWrapperSlimDX9(IGL_SlimDX9 sdx)
{ {
_sdx = sdx; _sdx = sdx;

View File

@ -1,3 +1,4 @@
using System;
using System.Windows.Forms; using System.Windows.Forms;
using BizHawk.Bizware.BizwareGL; using BizHawk.Bizware.BizwareGL;
@ -9,6 +10,12 @@ namespace BizHawk.Bizware.OpenTK3
{ {
internal class GLControlWrapper : GLControl, IGraphicsControl internal class GLControlWrapper : GLControl, IGraphicsControl
{ {
public RenderTargetWrapper RenderTargetWrapper
{
get => throw new NotImplementedException();
set => throw new NotImplementedException();
}
// Note: In order to work around bugs in OpenTK which sometimes do things to a context without making that context active first... // Note: In order to work around bugs in OpenTK which sometimes do things to a context without making that context active first...
// we are going to push and pop the context before doing stuff // we are going to push and pop the context before doing stuff
public GLControlWrapper(IGL_TK owner) public GLControlWrapper(IGL_TK owner)

View File

@ -23,7 +23,7 @@ namespace BizHawk.Client.EmuHawk
/// <summary> /// <summary>
/// the render target for rendering to this control /// the render target for rendering to this control
/// </summary> /// </summary>
public RenderTargetWrapper RenderTargetWrapper; public RenderTargetWrapper RenderTargetWrapper { get; set; }
public void SetVsync(bool state) public void SetVsync(bool state)
{ {

View File

@ -15,6 +15,11 @@ namespace BizHawk.Client.EmuHawk
// rendering state // rendering state
private RenderTarget _currRenderTarget; private RenderTarget _currRenderTarget;
private readonly Func<IGL_GdiPlus, IGraphicsControl> _createGLControlWrapper;
public IGL_GdiPlus(Func<IGL_GdiPlus, IGraphicsControl> createGLControlWrapper)
=> _createGLControlWrapper = createGLControlWrapper;
void IDisposable.Dispose() void IDisposable.Dispose()
{ {
} }
@ -232,17 +237,17 @@ namespace BizHawk.Client.EmuHawk
SetViewport(size.Width, size.Height); SetViewport(size.Width, size.Height);
} }
public void BeginControl(GLControlWrapper_GdiPlus control) public void BeginControl(IGraphicsControl control)
{ {
CurrentControl = control; CurrentControl = control;
} }
public void EndControl(GLControlWrapper_GdiPlus control) public void EndControl(IGraphicsControl control)
{ {
CurrentControl = null; CurrentControl = null;
} }
public void SwapControl(GLControlWrapper_GdiPlus control) public void SwapControl(IGraphicsControl control)
{ {
} }
@ -259,7 +264,7 @@ namespace BizHawk.Client.EmuHawk
public IGraphicsControl Internal_CreateGraphicsControl() public IGraphicsControl Internal_CreateGraphicsControl()
{ {
var ret = new GLControlWrapper_GdiPlus(this); var ret = _createGLControlWrapper(this);
// create a render target for this control // create a render target for this control
var rtw = new RenderTargetWrapper(() => MyBufferedGraphicsContext, ret); var rtw = new RenderTargetWrapper(() => MyBufferedGraphicsContext, ret);
@ -334,7 +339,7 @@ namespace BizHawk.Client.EmuHawk
return rtw.MyBufferedGraphics.Graphics; return rtw.MyBufferedGraphics.Graphics;
} }
public GLControlWrapper_GdiPlus CurrentControl; public IGraphicsControl CurrentControl;
public RenderTargetWrapper CurrentRenderTargetWrapper; public RenderTargetWrapper CurrentRenderTargetWrapper;
public readonly BufferedGraphicsContext MyBufferedGraphicsContext = new(); public readonly BufferedGraphicsContext MyBufferedGraphicsContext = new();

View File

@ -186,7 +186,7 @@ namespace BizHawk.Client.EmuHawk
return CheckRenderer(glOpenTK); return CheckRenderer(glOpenTK);
default: default:
case EDispMethod.GdiPlus: case EDispMethod.GdiPlus:
return new IGL_GdiPlus(); return new IGL_GdiPlus(self => new GLControlWrapper_GdiPlus(self));
} }
} }