fix a surface GC churn bug in display manager

This commit is contained in:
zeromus 2012-04-21 17:21:09 +00:00
parent aecd849eb5
commit 1e3b38538d
1 changed files with 33 additions and 24 deletions

View File

@ -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,8 +663,7 @@ 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 //scale the source bitmap to the desired size of the render panel
@ -683,7 +690,9 @@ namespace BizHawk.MultiClient
//send the native resolution image to the render panel //send the native resolution image to the render panel
Global.RenderPanel.Render(nativeBmp); Global.RenderPanel.Render(nativeBmp);
}
//release the native resolution image
nativeDisplaySurfaceSet.ReleaseSurface(nativeBmp);
} }
Thread displayThread; Thread displayThread;