Skip to content

Commit

Permalink
Merge branch 'master' into refactor-dropdown-test-scene
Browse files Browse the repository at this point in the history
  • Loading branch information
bdach authored Nov 27, 2023
2 parents d253e06 + 450ef26 commit 9b569cc
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 25 deletions.
2 changes: 1 addition & 1 deletion osu.Framework.Benchmarks/BenchmarkTextBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ private void initialiseBuilder(bool withDifferentBaselines)

private class TestStore : ITexturedGlyphLookupStore
{
public ITexturedCharacterGlyph Get(string fontName, char character) => new TexturedCharacterGlyph(
public ITexturedCharacterGlyph Get(string? fontName, char character) => new TexturedCharacterGlyph(
new CharacterGlyph(character, character, character, character, character, null),
new DummyRenderer().CreateTexture(1, 1));

Expand Down
28 changes: 14 additions & 14 deletions osu.Framework/Graphics/UserInterface/CircularProgress.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public bool RoundedCaps
}
}

private class CircularProgressDrawNode : SpriteDrawNode
protected class CircularProgressDrawNode : SpriteDrawNode
{
public new CircularProgress Source => (CircularProgress)base.Source;

Expand All @@ -98,28 +98,28 @@ public CircularProgressDrawNode(CircularProgress source)
{
}

private float innerRadius;
private float progress;
private float texelSize;
private bool roundedCaps;
protected float InnerRadius { get; private set; }
protected float Progress { get; private set; }
protected float TexelSize { get; private set; }
protected bool RoundedCaps { get; private set; }

public override void ApplyState()
{
base.ApplyState();

innerRadius = Source.innerRadius;
progress = Math.Abs((float)Source.current.Value);
roundedCaps = Source.roundedCaps;
InnerRadius = Source.innerRadius;
Progress = Math.Abs((float)Source.current.Value);
RoundedCaps = Source.roundedCaps;

// smoothstep looks too sharp with 1px, let's give it a bit more
texelSize = 1.5f / ScreenSpaceDrawQuad.Size.X;
TexelSize = 1.5f / ScreenSpaceDrawQuad.Size.X;
}

private IUniformBuffer<CircularProgressParameters> parametersBuffer;

protected override void Blit(IRenderer renderer)
{
if (innerRadius == 0 || (!roundedCaps && progress == 0))
if (InnerRadius == 0 || (!RoundedCaps && Progress == 0))
return;

base.Blit(renderer);
Expand All @@ -132,10 +132,10 @@ protected override void BindUniformResources(IShader shader, IRenderer renderer)
parametersBuffer ??= renderer.CreateUniformBuffer<CircularProgressParameters>();
parametersBuffer.Data = new CircularProgressParameters
{
InnerRadius = innerRadius,
Progress = progress,
TexelSize = texelSize,
RoundedCaps = roundedCaps,
InnerRadius = InnerRadius,
Progress = Progress,
TexelSize = TexelSize,
RoundedCaps = RoundedCaps,
};

shader.BindUniformBlock("m_CircularProgressParameters", parametersBuffer);
Expand Down
21 changes: 13 additions & 8 deletions osu.Framework/IO/Stores/FontStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Threading.Tasks;
using JetBrains.Annotations;
using osu.Framework.Extensions.ObjectExtensions;
using osu.Framework.Graphics.Rendering;
using osu.Framework.Graphics.Textures;
Expand All @@ -20,7 +19,7 @@ public class FontStore : TextureStore, ITexturedGlyphLookupStore
{
private readonly List<IGlyphStore> glyphStores = new List<IGlyphStore>();

private readonly List<FontStore> nestedFontStores = new List<FontStore>();
private readonly List<ITexturedGlyphLookupStore> nestedFontStores = new List<ITexturedGlyphLookupStore>();

private Storage cacheStorage;

Expand Down Expand Up @@ -77,12 +76,18 @@ public override void AddTextureSource(IResourceStore<TextureUpload> store)

public override void AddStore(ITextureStore store)
{
if (store is FontStore fs)
switch (store)
{
// if null, share the main store's atlas.
fs.Atlas ??= Atlas;
fs.cacheStorage ??= cacheStorage;
nestedFontStores.Add(fs);
case FontStore fs:
// if null, share the main store's atlas.
fs.Atlas ??= Atlas;
fs.cacheStorage ??= cacheStorage;
nestedFontStores.Add(fs);
break;

case ITexturedGlyphLookupStore gs:
nestedFontStores.Add(gs);
break;
}

base.AddStore(store);
Expand Down Expand Up @@ -132,7 +137,7 @@ public override void RemoveStore(ITextureStore store)
base.RemoveStore(store);
}

public ITexturedCharacterGlyph Get([CanBeNull] string fontName, char character)
public ITexturedCharacterGlyph Get(string fontName, char character)
{
var key = (fontName, character);

Expand Down
2 changes: 1 addition & 1 deletion osu.Framework/IO/Stores/GlyphStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public GlyphStore(ResourceStore<byte[]> store, string assetName = null, IResourc
AssetName = assetName;
TextureLoader = textureLoader;

FontName = assetName?.Split('/').Last();
FontName = assetName?.Split('/').Last() ?? string.Empty;
}

private Task fontLoadTask;
Expand Down
2 changes: 1 addition & 1 deletion osu.Framework/Text/ITexturedGlyphLookupStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public interface ITexturedGlyphLookupStore
/// <param name="fontName">The name of the font.</param>
/// <param name="character">The character to retrieve.</param>
/// <returns>The character glyph.</returns>
ITexturedCharacterGlyph? Get(string fontName, char character);
ITexturedCharacterGlyph? Get(string? fontName, char character);

/// <summary>
/// Retrieves a glyph from the store asynchronously.
Expand Down

0 comments on commit 9b569cc

Please sign in to comment.