mirror of
https://github.com/ppy/osu.git
synced 2025-03-19 01:17:19 +08:00
Merge pull request #14329 from peppy/fix-new-lounge-performance
Cache buffered background to fix multiplayer lounge performance
This commit is contained in:
commit
bc8e9d9ea8
@ -10,12 +10,12 @@ namespace osu.Game.Screens.OnlinePlay.Components
|
||||
{
|
||||
public class OnlinePlayBackgroundSprite : OnlinePlayComposite
|
||||
{
|
||||
private readonly BeatmapSetCoverType beatmapSetCoverType;
|
||||
protected readonly BeatmapSetCoverType BeatmapSetCoverType;
|
||||
private UpdateableBeatmapBackgroundSprite sprite;
|
||||
|
||||
public OnlinePlayBackgroundSprite(BeatmapSetCoverType beatmapSetCoverType = BeatmapSetCoverType.Cover)
|
||||
{
|
||||
this.beatmapSetCoverType = beatmapSetCoverType;
|
||||
BeatmapSetCoverType = beatmapSetCoverType;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
@ -33,6 +33,6 @@ namespace osu.Game.Screens.OnlinePlay.Components
|
||||
sprite.Beatmap.Value = Playlist.FirstOrDefault()?.Beatmap.Value;
|
||||
}
|
||||
|
||||
protected virtual UpdateableBeatmapBackgroundSprite CreateBackgroundSprite() => new UpdateableBeatmapBackgroundSprite(beatmapSetCoverType) { RelativeSizeAxes = Axes.Both };
|
||||
protected virtual UpdateableBeatmapBackgroundSprite CreateBackgroundSprite() => new UpdateableBeatmapBackgroundSprite(BeatmapSetCoverType) { RelativeSizeAxes = Axes.Both };
|
||||
}
|
||||
}
|
||||
|
@ -158,21 +158,14 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
||||
Children = new Drawable[]
|
||||
{
|
||||
// This resolves internal 1px gaps due to applying the (parenting) corner radius and masking across multiple filling background sprites.
|
||||
new BufferedContainer
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = colours.Background5,
|
||||
},
|
||||
new OnlinePlayBackgroundSprite
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both
|
||||
},
|
||||
}
|
||||
Colour = colours.Background5,
|
||||
},
|
||||
new OnlinePlayBackgroundSprite
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both
|
||||
},
|
||||
new Container
|
||||
{
|
||||
@ -187,37 +180,29 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
||||
CornerRadius = corner_radius,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
// This resolves internal 1px gaps due to applying the (parenting) corner radius and masking across multiple filling background sprites.
|
||||
new BufferedContainer
|
||||
new GridContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Children = new Drawable[]
|
||||
ColumnDimensions = new[]
|
||||
{
|
||||
new GridContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
ColumnDimensions = new[]
|
||||
{
|
||||
new Dimension(GridSizeMode.Relative, 0.2f)
|
||||
},
|
||||
Content = new[]
|
||||
{
|
||||
new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = colours.Background5,
|
||||
},
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = ColourInfo.GradientHorizontal(colours.Background5, colours.Background5.Opacity(0.3f))
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
new Dimension(GridSizeMode.Relative, 0.2f)
|
||||
},
|
||||
Content = new[]
|
||||
{
|
||||
new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = colours.Background5,
|
||||
},
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = ColourInfo.GradientHorizontal(colours.Background5, colours.Background5.Opacity(0.3f))
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
new Container
|
||||
{
|
||||
|
@ -11,6 +11,7 @@ using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Logging;
|
||||
using osu.Framework.Screens;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Beatmaps.Drawables;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Input;
|
||||
@ -104,14 +105,9 @@ namespace osu.Game.Screens.OnlinePlay
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new BufferedContainer
|
||||
new BeatmapBackgroundSprite
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
BlurSigma = new Vector2(10),
|
||||
Child = new BeatmapBackgroundSprite
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both
|
||||
}
|
||||
RelativeSizeAxes = Axes.Both
|
||||
},
|
||||
new Box
|
||||
{
|
||||
@ -306,11 +302,46 @@ namespace osu.Game.Screens.OnlinePlay
|
||||
|
||||
private class BeatmapBackgroundSprite : OnlinePlayBackgroundSprite
|
||||
{
|
||||
protected override UpdateableBeatmapBackgroundSprite CreateBackgroundSprite() => new BackgroundSprite { RelativeSizeAxes = Axes.Both };
|
||||
protected override UpdateableBeatmapBackgroundSprite CreateBackgroundSprite() => new BlurredBackgroundSprite(BeatmapSetCoverType) { RelativeSizeAxes = Axes.Both };
|
||||
|
||||
private class BackgroundSprite : UpdateableBeatmapBackgroundSprite
|
||||
public class BlurredBackgroundSprite : UpdateableBeatmapBackgroundSprite
|
||||
{
|
||||
public BlurredBackgroundSprite(BeatmapSetCoverType type)
|
||||
: base(type)
|
||||
{
|
||||
}
|
||||
|
||||
protected override double LoadDelay => 200;
|
||||
|
||||
protected override Drawable CreateDrawable(BeatmapInfo model) =>
|
||||
new BufferedLoader(base.CreateDrawable(model));
|
||||
}
|
||||
|
||||
// This class is an unfortunate requirement due to `LongRunningLoad` requiring direct async loading.
|
||||
// It means that if the web request fetching the beatmap background takes too long, it will suddenly appear.
|
||||
internal class BufferedLoader : BufferedContainer
|
||||
{
|
||||
private readonly Drawable drawable;
|
||||
|
||||
public BufferedLoader(Drawable drawable)
|
||||
{
|
||||
this.drawable = drawable;
|
||||
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
BlurSigma = new Vector2(10);
|
||||
FrameBufferScale = new Vector2(0.5f);
|
||||
CacheDrawnFrameBuffer = true;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
LoadComponentAsync(drawable, d =>
|
||||
{
|
||||
Add(d);
|
||||
ForceRedraw();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user