mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 15:07:44 +08:00
Add local off-screen avatar optimisation.
This commit is contained in:
parent
1855f48997
commit
d208614495
@ -66,11 +66,29 @@ 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.
|
||||
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();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user