From fa4c72887f07dd18d61959447e1bb91a2d2725a2 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 3 Jun 2025 01:14:18 +0900 Subject: [PATCH] Bring back missing logic to avoid stutters when scrolling Again, I don't know why the new implementation didn't just draw from the old which was known to work. This mostly matches what was there in v1. --- .../Screens/SelectV2/PanelSetBackground.cs | 36 +++++++++++++------ 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/osu.Game/Screens/SelectV2/PanelSetBackground.cs b/osu.Game/Screens/SelectV2/PanelSetBackground.cs index 743d0d489a..ae7c7d3138 100644 --- a/osu.Game/Screens/SelectV2/PanelSetBackground.cs +++ b/osu.Game/Screens/SelectV2/PanelSetBackground.cs @@ -5,6 +5,7 @@ using System; using System.Threading; using osu.Framework.Allocation; using osu.Framework.Extensions.Color4Extensions; +using osu.Framework.Extensions.PolygonExtensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Containers; @@ -51,7 +52,9 @@ namespace osu.Game.Screens.SelectV2 } public PanelSetBackground() - // : base(cachedFrameBuffer: true) + // TODO: for performance reasons we probably want this to be true + // for it to work we will need to move transforms accordingly. + : base(cachedFrameBuffer: false) { RelativeSizeAxes = Axes.Both; } @@ -105,7 +108,7 @@ namespace osu.Game.Screens.SelectV2 private void loadContentIfRequired() { // A load is already in progress if the cancellation token is non-null. - if (loadCancellation != null) + if (loadCancellation != null || working == null) return; if (beatmapCarousel != null) @@ -131,24 +134,37 @@ namespace osu.Game.Screens.SelectV2 loadCancellation = new CancellationTokenSource(); - var texture = working?.GetPanelBackground(); - - if (texture == null) - return; - - LoadComponentAsync(new Sprite + LoadComponentAsync(new PanelBeatmapBackground(working) { Depth = float.MaxValue, RelativeSizeAxes = Axes.Both, Anchor = Anchor.Centre, Origin = Anchor.Centre, FillMode = FillMode.Fill, - Texture = texture, }, s => { AddInternal(sprite = s); - sprite.FadeInFromZero(200, Easing.OutQuint); + bool spriteOnScreen = beatmapCarousel?.ScreenSpaceDrawQuad.Intersects(sprite.ScreenSpaceDrawQuad) != false; + sprite.FadeInFromZero(spriteOnScreen ? 400 : 0, Easing.OutQuint); }, loadCancellation.Token); } + + public partial class PanelBeatmapBackground : Sprite + { + private readonly IWorkingBeatmap working; + + public PanelBeatmapBackground(IWorkingBeatmap working) + { + ArgumentNullException.ThrowIfNull(working); + + this.working = working; + } + + [BackgroundDependencyLoader] + private void load() + { + Texture = working.GetPanelBackground(); + } + } } }