Skip to content

Commit

Permalink
should only create shard data once because drawable node will create …
Browse files Browse the repository at this point in the history
…three times.
  • Loading branch information
andy840119 committed Oct 11, 2021
1 parent ebecbc6 commit a57139d
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 6 deletions.
6 changes: 4 additions & 2 deletions osu.Framework.Font.Tests/Visual/Shaders/ShaderTestScene.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ protected class TestShaderContainer : Container, IMultiShaderBufferedDrawable

private readonly List<IShader> shaders = new();

// todo: should have a better way to let user able to customize formats?
private readonly MultiShaderBufferedDrawNodeSharedData sharedData = new();

public IReadOnlyList<IShader> Shaders
{
get => shaders;
Expand All @@ -95,9 +98,8 @@ private void load(ShaderManager shaders)
RoundedTextureShader = shaders.Load(VertexShaderDescriptor.TEXTURE_2, FragmentShaderDescriptor.TEXTURE_ROUNDED);
}

// todo: should have a better way to let user able to customize formats?
protected override DrawNode CreateDrawNode()
=> new TestShaderContainerShaderEffectDrawNode(this, new MultiShaderBufferedDrawNodeSharedData());
=> new TestShaderContainerShaderEffectDrawNode(this, sharedData);

/// <summary>
/// <see cref="BufferedDrawNode"/> to apply <see cref="IShader"/>.
Expand Down
3 changes: 3 additions & 0 deletions osu.Framework.Font/Graphics/Sprites/KaraokeSpriteText.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ public class KaraokeSpriteText : KaraokeSpriteText<LyricSpriteText>
private readonly MaskingContainer<T> backLyricTextContainer;
private readonly T backLyricText;

// todo: should have a better way to let user able to customize formats?
private readonly MultiShaderBufferedDrawNodeSharedData sharedData = new MultiShaderBufferedDrawNodeSharedData();

public IShader TextureShader { get; private set; }
public IShader RoundedTextureShader { get; private set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@ protected override Quad ComputeScreenSpaceDrawQuad()
return ToScreenSpace(newRectangle);
}

// todo: should have a better way to let user able to customize formats?
protected override DrawNode CreateDrawNode()
=> new KaraokeSpriteTextShaderEffectDrawNode(this, new MultiShaderBufferedDrawNodeSharedData());
=> new KaraokeSpriteTextShaderEffectDrawNode(this, sharedData);

/// <summary>
/// <see cref="BufferedDrawNode"/> to apply <see cref="IShader"/>.
Expand Down
3 changes: 3 additions & 0 deletions osu.Framework.Font/Graphics/Sprites/LyricSpriteText.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ public partial class LyricSpriteText : Drawable, IMultiShaderBufferedDrawable, I
private const float default_text_size = 48;
private static readonly char[] default_never_fixed_width_characters = { '.', ',', ':', ' ' };

// todo: should have a better way to let user able to customize formats?
private readonly MultiShaderBufferedDrawNodeSharedData sharedData = new MultiShaderBufferedDrawNodeSharedData();

[Resolved]
private FontStore store { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@ protected override Quad ComputeScreenSpaceDrawQuad()
return ToScreenSpace(newRectangle);
}

// todo: should have a better way to let user able to customize formats?
protected override DrawNode CreateDrawNode()
=> new LyricSpriteTextShaderEffectDrawNode(this, new MultiShaderBufferedDrawNodeSharedData());
=> new LyricSpriteTextShaderEffectDrawNode(this, sharedData);

/// <summary>
/// <see cref="BufferedDrawNode"/> to apply <see cref="IShader"/>.
Expand Down

0 comments on commit a57139d

Please sign in to comment.