Merge pull request #430 from Tom94/mod-select-performance

Massively improves fill-rate of mod select screen
This commit is contained in:
Dean Herbert 2017-03-04 15:39:50 +09:00 committed by GitHub
commit 833b83ed62

View File

@ -9,6 +9,8 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites;
using OpenTK;
using osu.Framework.Graphics.Transforms;
using osu.Framework.Graphics.Primitives;
using System;
namespace osu.Game.Overlays
{
@ -86,9 +88,10 @@ namespace osu.Game.Overlays
AddInternal(wavesContainer = new Container<Wave>
{
RelativeSizeAxes = Axes.Both,
RelativeSizeAxes = Axes.X,
Origin = Anchor.TopCentre,
Anchor = Anchor.TopCentre,
Masking = true,
Children = new[]
{
firstWave = new Wave
@ -148,14 +151,23 @@ namespace osu.Game.Overlays
w.State = Visibility.Hidden;
}
protected override void UpdateAfterChildren()
{
base.UpdateAfterChildren();
// This is done as an optimization, such that invisible parts of the waves
// are masked away, and thus do not consume fill rate.
wavesContainer.Height = Math.Max(0, DrawHeight - (contentContainer.DrawHeight - contentContainer.Y));
}
private class Wave : Container, IStateful<Visibility>
{
public float FinalPosition;
public Wave()
{
RelativeSizeAxes = Axes.Both;
Size = new Vector2(1.5f);
RelativeSizeAxes = Axes.X;
Width = 1.5f;
Masking = true;
EdgeEffect = new EdgeEffect
{
@ -173,6 +185,15 @@ namespace osu.Game.Overlays
};
}
protected override void Update()
{
base.Update();
// We can not use RelativeSizeAxes for Height, because the height
// of our parent diminishes as the content moves up.
Height = Parent.Parent.DrawSize.Y * 1.5f;
}
private Visibility state;
public Visibility State
{
@ -184,7 +205,7 @@ namespace osu.Game.Overlays
switch (value)
{
case Visibility.Hidden:
MoveToY(DrawHeight / Height, DISAPPEAR_DURATION, easing_hide);
MoveToY(Parent.Parent.DrawSize.Y, DISAPPEAR_DURATION, easing_hide);
break;
case Visibility.Visible:
MoveToY(FinalPosition, APPEAR_DURATION, easing_show);