From 0b5cc8fb10c88fb12650762a8b4fef78f406bde8 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 15 Jan 2024 14:01:03 +0900 Subject: [PATCH] Fix gameplay counter textures not being cached ahead of time Part of https://github.com/ppy/osu/issues/26535. --- osu.Game/Screens/Play/HUD/ArgonCounterTextComponent.cs | 6 ++++++ osu.Game/Skinning/LegacySpriteText.cs | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/osu.Game/Screens/Play/HUD/ArgonCounterTextComponent.cs b/osu.Game/Screens/Play/HUD/ArgonCounterTextComponent.cs index a11f2f01cd..f16669f865 100644 --- a/osu.Game/Screens/Play/HUD/ArgonCounterTextComponent.cs +++ b/osu.Game/Screens/Play/HUD/ArgonCounterTextComponent.cs @@ -137,6 +137,12 @@ private void load(TextureStore textures) Spacing = new Vector2(-2f, 0f); Font = new FontUsage(font_name, 1); glyphStore = new GlyphStore(font_name, textures, getLookup); + + // cache common lookups ahead of time. + foreach (char c in new[] { '.', '%', 'x' }) + glyphStore.Get(font_name, c); + for (int i = 0; i < 10; i++) + glyphStore.Get(font_name, (char)('0' + i)); } protected override TextBuilder CreateTextBuilder(ITexturedGlyphLookupStore store) => base.CreateTextBuilder(glyphStore); diff --git a/osu.Game/Skinning/LegacySpriteText.cs b/osu.Game/Skinning/LegacySpriteText.cs index 581e7534e4..fdd8716d5a 100644 --- a/osu.Game/Skinning/LegacySpriteText.cs +++ b/osu.Game/Skinning/LegacySpriteText.cs @@ -50,6 +50,12 @@ private void load(ISkinSource skin) Spacing = new Vector2(-skin.GetFontOverlap(font), 0); glyphStore = new LegacyGlyphStore(fontPrefix, skin, MaxSizePerGlyph); + + // cache common lookups ahead of time. + foreach (char c in FixedWidthExcludeCharacters) + glyphStore.Get(fontPrefix, c); + for (int i = 0; i < 10; i++) + glyphStore.Get(fontPrefix, (char)('0' + i)); } protected override TextBuilder CreateTextBuilder(ITexturedGlyphLookupStore store) => base.CreateTextBuilder(glyphStore);