diff --git a/src/BizHawk.Bizware.BizwareGL/IGraphicsControl.cs b/src/BizHawk.Bizware.BizwareGL/IGraphicsControl.cs
index d9a90dbba6..83763c37fb 100644
--- a/src/BizHawk.Bizware.BizwareGL/IGraphicsControl.cs
+++ b/src/BizHawk.Bizware.BizwareGL/IGraphicsControl.cs
@@ -1,9 +1,14 @@
using System;
+using System.Drawing;
namespace BizHawk.Bizware.BizwareGL
{
public interface IGraphicsControl : IDisposable
{
+ Rectangle ClientRectangle { get; }
+
+ Graphics CreateGraphics();
+
///
/// Sets whether presentation operations on this control will vsync
///
diff --git a/src/BizHawk.Client.EmuHawk/GraphicsImplementations/IGL_GdiPlus.cs b/src/BizHawk.Client.EmuHawk/GraphicsImplementations/IGL_GdiPlus.cs
index 8b2159e2fb..cc52aa485b 100644
--- a/src/BizHawk.Client.EmuHawk/GraphicsImplementations/IGL_GdiPlus.cs
+++ b/src/BizHawk.Client.EmuHawk/GraphicsImplementations/IGL_GdiPlus.cs
@@ -15,11 +15,6 @@ namespace BizHawk.Client.EmuHawk
// rendering state
private RenderTarget _currRenderTarget;
- public IGL_GdiPlus()
- {
- MyBufferedGraphicsContext = new BufferedGraphicsContext();
- }
-
void IDisposable.Dispose()
{
}
@@ -267,7 +262,7 @@ namespace BizHawk.Client.EmuHawk
var ret = new GLControlWrapper_GdiPlus(this);
// create a render target for this control
- var rtw = new RenderTargetWrapper(this) { Control = ret };
+ var rtw = new RenderTargetWrapper(() => MyBufferedGraphicsContext, ret);
ret.RenderTargetWrapper = rtw;
return ret;
@@ -287,7 +282,7 @@ namespace BizHawk.Client.EmuHawk
};
var tex = new Texture2d(this, tw, w, h);
- var rtw = new RenderTargetWrapper(this);
+ var rtw = new RenderTargetWrapper(() => MyBufferedGraphicsContext);
var rt = new RenderTarget(this, rtw, tex);
rtw.Target = rt;
return rt;
@@ -342,7 +337,7 @@ namespace BizHawk.Client.EmuHawk
public GLControlWrapper_GdiPlus CurrentControl;
public RenderTargetWrapper CurrentRenderTargetWrapper;
- public BufferedGraphicsContext MyBufferedGraphicsContext;
+ public readonly BufferedGraphicsContext MyBufferedGraphicsContext = new();
} //class IGL_GdiPlus
diff --git a/src/BizHawk.Client.EmuHawk/GraphicsImplementations/RenderTargetWrapper.cs b/src/BizHawk.Client.EmuHawk/GraphicsImplementations/RenderTargetWrapper.cs
index 13b0881948..0494b1ff24 100644
--- a/src/BizHawk.Client.EmuHawk/GraphicsImplementations/RenderTargetWrapper.cs
+++ b/src/BizHawk.Client.EmuHawk/GraphicsImplementations/RenderTargetWrapper.cs
@@ -1,3 +1,4 @@
+using System;
using System.Drawing;
using BizHawk.Bizware.BizwareGL;
@@ -6,21 +7,24 @@ namespace BizHawk.Client.EmuHawk
{
public class RenderTargetWrapper
{
- public RenderTargetWrapper(IGL_GdiPlus gdi)
+ public RenderTargetWrapper(
+ Func getBufferedGraphicsContext,
+ IGraphicsControl control = null)
{
- Gdi = gdi;
+ _getBufferedGraphicsContext = getBufferedGraphicsContext;
+ Control = control;
}
public void Dispose()
{
}
- private readonly IGL_GdiPlus Gdi;
+ private readonly Func _getBufferedGraphicsContext;
///
/// the control associated with this render target (if any)
///
- public GLControlWrapper_GdiPlus Control;
+ private readonly IGraphicsControl Control;
///
/// the offscreen render target, if that's what this is representing
@@ -47,7 +51,7 @@ namespace BizHawk.Client.EmuHawk
}
MyBufferedGraphics?.Dispose();
- MyBufferedGraphics = Gdi.MyBufferedGraphicsContext.Allocate(refGraphics, r);
+ MyBufferedGraphics = _getBufferedGraphicsContext().Allocate(refGraphics, r);
// MyBufferedGraphics.Graphics.PixelOffsetMode = PixelOffsetMode.HighSpeed;
//not sure about this stuff...