mirror of
https://github.com/ppy/osu.git
synced 2025-02-21 10:42:54 +08:00
Add local off-screen avatar optimisation.
This commit is contained in:
parent
1855f48997
commit
d208614495
@ -66,12 +66,30 @@ namespace osu.Game.Users
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private double timeVisible;
|
||||||
|
|
||||||
|
private bool shouldUpdate => Sprite != null || timeVisible > 500;
|
||||||
|
|
||||||
protected override void Update()
|
protected override void Update()
|
||||||
{
|
{
|
||||||
base.Update();
|
base.Update();
|
||||||
|
|
||||||
//todo: should only be run when we are visible to the user.
|
if (!shouldUpdate)
|
||||||
updateSprite();
|
{
|
||||||
|
//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
|
public class OnlineSprite : Sprite
|
||||||
|
Loading…
Reference in New Issue
Block a user