fix a surface GC churn bug in display manager
This commit is contained in:
parent
aecd849eb5
commit
1e3b38538d
|
@ -556,6 +556,11 @@ namespace BizHawk.MultiClient
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void ReleaseSurface(DisplaySurface surface)
|
||||||
|
{
|
||||||
|
lock (this) ReleasedSurfaces.Enqueue(surface);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// returns the current buffer, making the most recent pending buffer (if there is such) as the new current first.
|
/// returns the current buffer, making the most recent pending buffer (if there is such) as the new current first.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -629,6 +634,9 @@ namespace BizHawk.MultiClient
|
||||||
suspendReplyEvent.WaitOne();
|
suspendReplyEvent.WaitOne();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
SwappableDisplaySurfaceSet nativeDisplaySurfaceSet = new SwappableDisplaySurfaceSet();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// internal display worker proc; runs through the multiply layered display pipeline
|
/// internal display worker proc; runs through the multiply layered display pipeline
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -655,35 +663,36 @@ namespace BizHawk.MultiClient
|
||||||
|
|
||||||
int w = currNativeWidth;
|
int w = currNativeWidth;
|
||||||
int h = currNativeHeight;
|
int h = currNativeHeight;
|
||||||
using (var nativeBmp = new DisplaySurface(w,h))
|
var nativeBmp = nativeDisplaySurfaceSet.AllocateSurface(w, h, true);
|
||||||
|
using (var g = Graphics.FromImage(nativeBmp.PeekBitmap()))
|
||||||
{
|
{
|
||||||
using (var g = Graphics.FromImage(nativeBmp.PeekBitmap()))
|
//scale the source bitmap to the desired size of the render panel
|
||||||
{
|
g.PixelOffsetMode = PixelOffsetMode.HighSpeed;
|
||||||
//scale the source bitmap to the desired size of the render panel
|
g.InterpolationMode = InterpolationMode.NearestNeighbor;
|
||||||
g.PixelOffsetMode = PixelOffsetMode.HighSpeed;
|
g.CompositingMode = CompositingMode.SourceCopy;
|
||||||
g.InterpolationMode = InterpolationMode.NearestNeighbor;
|
g.CompositingQuality = CompositingQuality.HighSpeed;
|
||||||
g.CompositingMode = CompositingMode.SourceCopy;
|
g.DrawImage(currentSourceSurface.PeekBitmap(), 0, 0, w, h);
|
||||||
g.CompositingQuality = CompositingQuality.HighSpeed;
|
g.Clip = new Region(new Rectangle(0, 0, nativeBmp.Width, nativeBmp.Height));
|
||||||
g.DrawImage(currentSourceSurface.PeekBitmap(), 0, 0, w, h);
|
|
||||||
g.Clip = new Region(new Rectangle(0, 0, nativeBmp.Width, nativeBmp.Height));
|
|
||||||
|
|
||||||
//switch to fancier composition for OSD overlays and such
|
//switch to fancier composition for OSD overlays and such
|
||||||
g.CompositingMode = CompositingMode.SourceOver;
|
g.CompositingMode = CompositingMode.SourceOver;
|
||||||
|
|
||||||
//apply a lua layer
|
//apply a lua layer
|
||||||
var luaSurface = luaNativeSurfaceSet.GetCurrent();
|
var luaSurface = luaNativeSurfaceSet.GetCurrent();
|
||||||
if (luaSurface != null) g.DrawImageUnscaled(luaSurface.PeekBitmap(), 0, 0);
|
if (luaSurface != null) g.DrawImageUnscaled(luaSurface.PeekBitmap(), 0, 0);
|
||||||
//although we may want to change this if we want to fade out messages or have some other fancy alpha faded gui stuff
|
//although we may want to change this if we want to fade out messages or have some other fancy alpha faded gui stuff
|
||||||
|
|
||||||
//draw the OSD at native resolution
|
//draw the OSD at native resolution
|
||||||
Global.OSD.DrawScreenInfo(g);
|
Global.OSD.DrawScreenInfo(g);
|
||||||
Global.OSD.DrawMessages(g);
|
Global.OSD.DrawMessages(g);
|
||||||
g.Clip.Dispose();
|
g.Clip.Dispose();
|
||||||
}
|
|
||||||
|
|
||||||
//send the native resolution image to the render panel
|
|
||||||
Global.RenderPanel.Render(nativeBmp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//send the native resolution image to the render panel
|
||||||
|
Global.RenderPanel.Render(nativeBmp);
|
||||||
|
|
||||||
|
//release the native resolution image
|
||||||
|
nativeDisplaySurfaceSet.ReleaseSurface(nativeBmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
Thread displayThread;
|
Thread displayThread;
|
||||||
|
|
Loading…
Reference in New Issue