#pragma once #include "PixelShaderViewer.h" #include "PluginHost/Sampler.h" class FSamplePatternInstance; class IWaveformHandle { public: virtual TArray 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 InHandle) { WaveformHandle = InHandle; } private: TSharedPtr RenderTarget; TSharedPtr ComputeShader; TSharedPtr Params; TSharedPtr ComputeElement; FSampler Sampler; mutable bool bNeedCompute = false; float UpdateInterval = 0.1f; float UpdateTimer = 0.0f; struct UpdateTask { TArray Array; FIntPoint Size; float LineUV; }; mutable TQueue UpdateQueue; struct FCSParam { FLinearColor WaveColor; FLinearColor BgColor; float LineUV; } mutable Param; TSharedPtr WaveformHandle; };