Skip to content

Commit

Permalink
Merge pull request #6161 from EVAST9919/icon-fix
Browse files Browse the repository at this point in the history
Fix `SpriteIcon` flickering for one frame
  • Loading branch information
bdach authored Jan 29, 2024
2 parents a1585bf + d6a6cf5 commit a639ba6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
15 changes: 15 additions & 0 deletions osu.Framework.Tests/Visual/Sprites/TestSceneSpriteIcon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,21 @@ public partial class TestSceneSpriteIcon : FrameworkTestScene
{
private ScheduledDelegate? scheduledDelegate;

[Test]
public void TestPreloadIcon()
{
SpriteIcon? icon = null;

AddStep("create icon", () => icon = new SpriteIcon
{
Size = new Vector2(20),
Icon = FontAwesome.Solid.Anchor
});
AddStep("preload icon", () => LoadComponent(icon));
AddStep("change icon", () => icon!.Icon = FontAwesome.Solid.Ad);
AddStep("add icon", () => Add(icon));
}

[Test]
public void TestOneIconAtATime()
{
Expand Down
7 changes: 1 addition & 6 deletions osu.Framework/Graphics/Sprites/SpriteIcon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,6 @@ private void load(FontStore store, ShaderManager shaders)
{
this.store = store;
TextureShader = shaders.Load(VertexShaderDescriptor.TEXTURE_2, FragmentShaderDescriptor.TEXTURE);
}

protected override void LoadComplete()
{
base.LoadComplete();
updateTexture();
}

Expand Down Expand Up @@ -121,7 +116,7 @@ public IconUsage Icon
if (icon.Equals(value)) return;

icon = value;
if (IsLoaded)
if (LoadState > LoadState.NotLoaded)
updateTexture();
}
}
Expand Down

0 comments on commit a639ba6

Please sign in to comment.