1
0
mirror of https://github.com/ppy/osu.git synced 2026-05-24 16:20:37 +08:00

Adjust API of HighPerformanceSession + rename

This commit is contained in:
Dan Balasescu
2024-02-26 22:12:04 +09:00
Unverified
parent 09b420a083
commit 3e9425fdf2
3 changed files with 36 additions and 44 deletions
+2 -2
View File
@@ -792,7 +792,7 @@ namespace osu.Game
protected virtual UpdateManager CreateUpdateManager() => new UpdateManager();
protected virtual HighPerformanceSession CreateHighPerformanceSession() => new HighPerformanceSession();
protected virtual HighPerformanceSessionManager CreateHighPerformanceSessionManager() => new HighPerformanceSessionManager();
protected override Container CreateScalingContainer() => new ScalingContainer(ScalingMode.Everything);
@@ -1088,7 +1088,7 @@ namespace osu.Game
loadComponentSingleFile(new AccountCreationOverlay(), topMostOverlayContent.Add, true);
loadComponentSingleFile<IDialogOverlay>(new DialogOverlay(), topMostOverlayContent.Add, true);
loadComponentSingleFile(CreateHighPerformanceSession(), Add);
loadComponentSingleFile(CreateHighPerformanceSessionManager(), Add, true);
loadComponentSingleFile(new BackgroundDataStoreProcessor(), Add);
@@ -1,42 +0,0 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Game.Screens.Play;
namespace osu.Game.Performance
{
public partial class HighPerformanceSession : Component
{
private readonly IBindable<bool> localUserPlaying = new Bindable<bool>();
[BackgroundDependencyLoader]
private void load(ILocalUserPlayInfo localUserInfo)
{
localUserPlaying.BindTo(localUserInfo.IsPlaying);
}
protected override void LoadComplete()
{
base.LoadComplete();
localUserPlaying.BindValueChanged(playing =>
{
if (playing.NewValue)
EnableHighPerformanceSession();
else
DisableHighPerformanceSession();
}, true);
}
protected virtual void EnableHighPerformanceSession()
{
}
protected virtual void DisableHighPerformanceSession()
{
}
}
}
@@ -0,0 +1,34 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System;
using System.Runtime;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
namespace osu.Game.Performance
{
public partial class HighPerformanceSessionManager : Component
{
private GCLatencyMode originalGCMode;
public IDisposable BeginSession()
{
EnableHighPerformanceSession();
return new InvokeOnDisposal<HighPerformanceSessionManager>(this, static m => m.DisableHighPerformanceSession());
}
protected virtual void EnableHighPerformanceSession()
{
originalGCMode = GCSettings.LatencyMode;
GCSettings.LatencyMode = GCLatencyMode.LowLatency;
GC.Collect(0);
}
protected virtual void DisableHighPerformanceSession()
{
if (GCSettings.LatencyMode == GCLatencyMode.LowLatency)
GCSettings.LatencyMode = originalGCMode;
}
}
}