Prevent churn by not allocating a new video buffer every frame in NullVideo

This commit is contained in:
Morilli 2022-03-25 14:19:07 +01:00
parent da2a20e55b
commit 76729aa56b
1 changed files with 10 additions and 2 deletions

View File

@ -1,4 +1,6 @@
namespace BizHawk.Emulation.Common
using System;
namespace BizHawk.Emulation.Common
{
/// <summary>
/// A default IVideoProvider that simply returns
@ -7,7 +9,11 @@
/// <seealso cref="IVideoProvider" />
public class NullVideo : IVideoProvider
{
public int[] GetVideoBuffer() => new int[BufferWidth * BufferHeight];
public int[] GetVideoBuffer()
{
Array.Clear(VideoBuffer, 0, VideoBuffer.Length);
return VideoBuffer;
}
public static NullVideo Instance { get; } = new NullVideo();
@ -30,5 +36,7 @@
public int VsyncNumerator => DefaultVsyncNum;
public int VsyncDenominator => DefaultVsyncDen;
private static readonly int[] VideoBuffer = new int[DefaultWidth * DefaultHeight];
}
}