1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 10:33:30 +08:00

Merge pull request #27562 from EVAST9919/osu-performance

Don't update SubTreeMasking in `OsuPlayfield`
This commit is contained in:
Dean Herbert 2024-03-12 18:15:14 +08:00 committed by GitHub
commit e431c1240e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 32 additions and 10 deletions

View File

@ -1,8 +1,6 @@
// 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.
#nullable disable
using System.Collections.Generic;
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Mods;
@ -25,7 +23,7 @@ namespace osu.Game.Rulesets.Osu.Edit
private partial class OsuEditorPlayfield : OsuPlayfield
{
protected override GameplayCursorContainer CreateCursor() => null;
protected override GameplayCursorContainer? CreateCursor() => null;
public OsuEditorPlayfield()
{

View File

@ -1,14 +1,14 @@
// 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.
#nullable disable
using System;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Primitives;
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Objects;
@ -35,12 +35,16 @@ namespace osu.Game.Rulesets.Osu.UI
private readonly JudgementPooler<DrawableOsuJudgement> judgementPooler;
// For osu! gameplay, everything is always on screen.
// Skipping masking calculations improves performance in intense beatmaps (ie. https://osu.ppy.sh/beatmapsets/150945#osu/372245)
public override bool UpdateSubTreeMasking(Drawable source, RectangleF maskingBounds) => false;
public SmokeContainer Smoke { get; }
public FollowPointRenderer FollowPoints { get; }
public static readonly Vector2 BASE_SIZE = new Vector2(512, 384);
protected override GameplayCursorContainer CreateCursor() => new OsuCursorContainer();
protected override GameplayCursorContainer? CreateCursor() => new OsuCursorContainer();
private readonly Container judgementAboveHitObjectLayer;
@ -81,6 +85,7 @@ namespace osu.Game.Rulesets.Osu.UI
public IHitPolicy HitPolicy
{
get => hitPolicy;
[MemberNotNull(nameof(hitPolicy))]
set
{
hitPolicy = value ?? throw new ArgumentNullException(nameof(value));
@ -116,12 +121,12 @@ namespace osu.Game.Rulesets.Osu.UI
judgementAboveHitObjectLayer.Add(judgement.ProxiedAboveHitObjectsContent);
}
[BackgroundDependencyLoader(true)]
private void load(OsuRulesetConfigManager config, IBeatmap beatmap)
[BackgroundDependencyLoader]
private void load(OsuRulesetConfigManager? config, IBeatmap? beatmap)
{
config?.BindWith(OsuRulesetSetting.PlayfieldBorderStyle, playfieldBorder.PlayfieldBorderStyle);
var osuBeatmap = (OsuBeatmap)beatmap;
var osuBeatmap = (OsuBeatmap?)beatmap;
RegisterPool<HitCircle, DrawableHitCircle>(20, 100);

View File

@ -18,6 +18,8 @@ namespace osu.Game.Tests.Visual.Gameplay
{
protected override bool AllowBackwardsSeeks => true;
private bool seek;
[Test]
public void TestAllSamplesStopDuringSeek()
{
@ -42,7 +44,7 @@ namespace osu.Game.Tests.Visual.Gameplay
if (!samples.Any(s => s.Playing))
return false;
Player.ChildrenOfType<GameplayClockContainer>().First().Seek(40000);
seek = true;
return true;
});
@ -55,10 +57,27 @@ namespace osu.Game.Tests.Visual.Gameplay
AddAssert("sample playback still disabled", () => sampleDisabler.SamplePlaybackDisabled.Value);
AddStep("stop seeking", () => seek = false);
AddUntilStep("seek finished, sample playback enabled", () => !sampleDisabler.SamplePlaybackDisabled.Value);
AddUntilStep("any sample is playing", () => Player.ChildrenOfType<PausableSkinnableSound>().Any(s => s.IsPlaying));
}
protected override void Update()
{
base.Update();
if (seek)
{
// Frame stable playback is too fast to catch up these days.
//
// We want to keep seeking while asserting various test conditions, so
// continue to seek until we unset the flag.
var gameplayClockContainer = Player.ChildrenOfType<GameplayClockContainer>().First();
gameplayClockContainer.Seek(gameplayClockContainer.CurrentTime > 30000 ? 0 : 60000);
}
}
private IEnumerable<PausableSkinnableSound> allSounds => Player.ChildrenOfType<PausableSkinnableSound>();
private IEnumerable<PausableSkinnableSound> allLoopingSounds => allSounds.Where(sound => sound.Looping);