1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 00:47:24 +08:00

Add local off-screen avatar optimisation.

This commit is contained in:
Dean Herbert 2017-03-15 19:07:26 +09:00
parent 1855f48997
commit d208614495
No known key found for this signature in database
GPG Key ID: 46D71BF4958ABB49

View File

@ -66,12 +66,30 @@ namespace osu.Game.Users
});
}
private double timeVisible;
private bool shouldUpdate => Sprite != null || timeVisible > 500;
protected override void Update()
{
base.Update();
//todo: should only be run when we are visible to the user.
updateSprite();
if (!shouldUpdate)
{
//Special optimisation to not start loading until we are within bounds of our closest ScrollContainer parent.
ScrollContainer scroll = null;
IContainer cursor = this;
while (scroll == null && (cursor = cursor.Parent) != null)
scroll = cursor as ScrollContainer;
if (scroll?.ScreenSpaceDrawQuad.Intersects(ScreenSpaceDrawQuad) ?? true)
timeVisible += Time.Elapsed;
else
timeVisible = 0;
}
if (shouldUpdate)
updateSprite();
}
public class OnlineSprite : Sprite