1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-13 20:47:26 +08:00
osu-lazer/osu.Game/Graphics/Sprites/LogoAnimation.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

89 lines
2.6 KiB
C#
Raw Normal View History

2020-06-24 20:11:38 +08:00
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
2022-06-17 15:37:17 +08:00
#nullable disable
2023-02-25 00:21:37 +08:00
using System.Runtime.InteropServices;
2020-06-24 20:11:38 +08:00
using osu.Framework.Allocation;
using osu.Framework.Graphics;
2022-07-29 21:33:34 +08:00
using osu.Framework.Graphics.Rendering;
2020-06-24 20:11:38 +08:00
using osu.Framework.Graphics.Shaders;
2023-02-25 00:21:37 +08:00
using osu.Framework.Graphics.Shaders.Types;
2020-06-24 20:11:38 +08:00
using osu.Framework.Graphics.Sprites;
namespace osu.Game.Graphics.Sprites
{
2020-07-23 04:10:59 +08:00
public partial class LogoAnimation : Sprite
2020-06-24 20:11:38 +08:00
{
[BackgroundDependencyLoader]
2022-01-15 08:06:39 +08:00
private void load(ShaderManager shaders)
2020-06-24 20:11:38 +08:00
{
TextureShader = shaders.Load(@"LogoAnimation", @"LogoAnimation");
2020-06-24 20:11:38 +08:00
}
private float animationProgress;
public float AnimationProgress
{
get => animationProgress;
set
{
if (animationProgress == value) return;
animationProgress = value;
Invalidate(Invalidation.DrawInfo);
}
}
public override bool IsPresent => true;
2020-07-23 04:10:59 +08:00
protected override DrawNode CreateDrawNode() => new LogoAnimationDrawNode(this);
2020-06-24 20:11:38 +08:00
2020-07-23 04:10:59 +08:00
private class LogoAnimationDrawNode : SpriteDrawNode
2020-06-24 20:11:38 +08:00
{
2020-07-23 04:10:59 +08:00
private LogoAnimation source => (LogoAnimation)Source;
2020-06-24 20:11:38 +08:00
private float progress;
2020-07-23 04:10:59 +08:00
public LogoAnimationDrawNode(LogoAnimation source)
2020-06-24 20:11:38 +08:00
: base(source)
{
}
public override void ApplyState()
{
base.ApplyState();
2020-06-25 06:59:12 +08:00
progress = source.animationProgress;
2020-06-24 20:11:38 +08:00
}
2023-02-25 00:21:37 +08:00
private IUniformBuffer<AnimationData> animationDataBuffer;
2022-07-29 21:33:34 +08:00
protected override void Blit(IRenderer renderer)
2020-06-24 20:11:38 +08:00
{
2023-02-25 00:21:37 +08:00
animationDataBuffer ??= renderer.CreateUniformBuffer<AnimationData>();
animationDataBuffer.Data = animationDataBuffer.Data with { Progress = progress };
TextureShader.BindUniformBlock("m_AnimationData", animationDataBuffer);
2020-06-24 20:11:38 +08:00
2022-07-29 21:33:34 +08:00
base.Blit(renderer);
2020-06-24 20:11:38 +08:00
}
protected override bool CanDrawOpaqueInterior => false;
2023-02-25 00:21:37 +08:00
protected override void Dispose(bool isDisposing)
{
base.Dispose(isDisposing);
animationDataBuffer?.Dispose();
}
[StructLayout(LayoutKind.Sequential, Pack = 1)]
private record struct AnimationData
{
public UniformFloat Progress;
private readonly UniformPadding12 pad1;
}
2020-06-24 20:11:38 +08:00
}
}
}