From 76729aa56b56796ac9573a48f117b8d92090d85b Mon Sep 17 00:00:00 2001 From: Morilli <35152647+Morilli@users.noreply.github.com> Date: Fri, 25 Mar 2022 14:19:07 +0100 Subject: [PATCH] Prevent churn by not allocating a new video buffer every frame in NullVideo --- .../Base Implementations/NullVideo.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/BizHawk.Emulation.Common/Base Implementations/NullVideo.cs b/src/BizHawk.Emulation.Common/Base Implementations/NullVideo.cs index 309fa086cd..4b04dbdb9b 100644 --- a/src/BizHawk.Emulation.Common/Base Implementations/NullVideo.cs +++ b/src/BizHawk.Emulation.Common/Base Implementations/NullVideo.cs @@ -1,4 +1,6 @@ -namespace BizHawk.Emulation.Common +using System; + +namespace BizHawk.Emulation.Common { /// /// A default IVideoProvider that simply returns @@ -7,7 +9,11 @@ /// 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]; } }