57 lines
1.6 KiB
C++
57 lines
1.6 KiB
C++
#pragma once
|
|
#include "PixelShaderViewer.h"
|
|
#include "PluginHost/Sampler.h"
|
|
|
|
class FSamplePatternInstance;
|
|
|
|
class IWaveformHandle
|
|
{
|
|
public:
|
|
virtual TArray<float> GetWaveform(int32 SizeX) const = 0;
|
|
};
|
|
|
|
|
|
class ARONA_API SWaveformViewer : public SLeafWidget
|
|
{
|
|
public:
|
|
SLATE_BEGIN_ARGS(SWaveformViewer)
|
|
{
|
|
}
|
|
SLATE_END_ARGS()
|
|
|
|
/** Constructs this widget with InArgs */
|
|
void Construct(const FArguments& InArgs);
|
|
|
|
virtual void Tick(const FGeometry& AllottedGeometry, const double InCurrentTime, const float InDeltaTime) override;
|
|
virtual int32 OnPaint(const FPaintArgs& Args, const FGeometry& AllottedGeometry, const FSlateRect& MyCullingRect, FSlateWindowElementList& OutDrawElements, int32 LayerId, const FWidgetStyle& InWidgetStyle, bool bParentEnabled) const override;
|
|
virtual FVector2D ComputeDesiredSize(float LayoutScaleMultiplier) const override { return RenderTarget->GetSize(); }
|
|
|
|
void OnResize(const FIntPoint& InSize) const;
|
|
void SetWaveformHandle(TSharedPtr<IWaveformHandle> InHandle) { WaveformHandle = InHandle; }
|
|
private:
|
|
TSharedPtr<FSlateRenderTarget> RenderTarget;
|
|
TSharedPtr<FSlateComputeShader> ComputeShader;
|
|
TSharedPtr<FSlateShaderParam> Params;
|
|
TSharedPtr<IComputeShaderSlateElement> ComputeElement;
|
|
FSampler Sampler;
|
|
mutable bool bNeedCompute = false;
|
|
float UpdateInterval = 0.1f;
|
|
float UpdateTimer = 0.0f;
|
|
|
|
struct UpdateTask
|
|
{
|
|
TArray<float> Array;
|
|
FIntPoint Size;
|
|
float LineUV;
|
|
};
|
|
mutable TQueue<UpdateTask, EQueueMode::Mpsc> UpdateQueue;
|
|
|
|
struct FCSParam
|
|
{
|
|
FLinearColor WaveColor;
|
|
FLinearColor BgColor;
|
|
float LineUV;
|
|
} mutable Param;
|
|
TSharedPtr<IWaveformHandle> WaveformHandle;
|
|
};
|