|
|
|
|
| #pragma once
|
|
|
| #include "CommonUserWidget.h"
|
| #include "Widgets/SLeafWidget.h"
|
|
|
| #include "LyraPerfStatWidgetBase.generated.h"
|
|
|
| enum class ELyraDisplayablePerformanceStat : uint8;
|
|
|
| class ULyraPerformanceStatSubsystem;
|
| class UObject;
|
| struct FFrame;
|
| class FSampledStatCache;
|
|
|
| class SLyraLatencyGraph : public SLeafWidget
|
| {
|
| public:
|
|
|
| SLATE_BEGIN_ARGS(SLyraLatencyGraph)
|
| : _DesiredSize(150, 50),
|
| _MaxLatencyToGraph(33.0),
|
| _LineColor(255, 255, 255, 255),
|
| _BackgroundColor(0, 0, 0, 128)
|
| {
|
| _Clipping = EWidgetClipping::ClipToBounds;
|
| }
|
|
|
| SLATE_ARGUMENT(FVector2D, DesiredSize)
|
| SLATE_ARGUMENT(double, MaxLatencyToGraph)
|
| SLATE_ARGUMENT(FColor, LineColor)
|
| SLATE_ARGUMENT(FColor, BackgroundColor)
|
| SLATE_END_ARGS()
|
|
|
|
|
| void Construct(const FArguments& InArgs);
|
|
|
|
|
| virtual int32 OnPaint(const FPaintArgs& Args,
|
| const FGeometry& AllottedGeometry,
|
| const FSlateRect& MyClippingRect,
|
| FSlateWindowElementList& OutDrawElements,
|
| int32 LayerId,
|
| const FWidgetStyle& InWidgetStyle,
|
| bool bParentEnabled) const override;
|
|
|
| virtual bool ComputeVolatility() const override { return true; }
|
|
|
| virtual FVector2D ComputeDesiredSize(float LayoutScaleMultiplier) const override;
|
|
|
| inline void SetLineColor(const FColor& InColor)
|
| {
|
| LineColor = InColor;
|
| }
|
|
|
| inline void SetMaxYValue(const double InValue)
|
| {
|
| MaxYAxisOfGraph = InValue;
|
| }
|
|
|
| inline void SetBackgroundColor(const FColor& InColor)
|
| {
|
| BackgroundColor = InColor;
|
| }
|
|
|
| inline void UpdateGraphData(const FSampledStatCache* StatData, const float InScaleFactor)
|
| {
|
| GraphData = StatData;
|
| ScaleFactor = InScaleFactor;
|
| }
|
|
|
| private:
|
|
|
| void DrawTotalLatency(const FGeometry& AllottedGeometry, FSlateWindowElementList& OutDrawElements, int32 LayerId) const;
|
|
|
| |
| |
|
|
| FVector2D DesiredSize = { 150.0, 50.0 };
|
|
|
| |
| |
|
|
| double MaxYAxisOfGraph = 33.0;
|
|
|
| float ScaleFactor = 1.0f;
|
|
|
| |
| |
|
|
| FColor LineColor = FColor(255, 255, 255, 255);
|
|
|
| |
| |
|
|
| FColor BackgroundColor = FColor(0, 0, 0, 128);
|
|
|
| |
| |
|
|
| const FSampledStatCache* GraphData = nullptr;
|
| };
|
|
|
| |
| |
| |
| |
|
|
| UCLASS(meta = (DisableNativeTick))
|
| class ULyraPerfStatGraph : public UUserWidget
|
| {
|
| GENERATED_BODY()
|
|
|
| public:
|
| ULyraPerfStatGraph(const FObjectInitializer& ObjectInitializer);
|
|
|
| void SetLineColor(const FColor& InColor);
|
|
|
| void SetMaxYValue(const float InValue);
|
|
|
| void SetBackgroundColor(const FColor& InValue);
|
|
|
| void UpdateGraphData(const FSampledStatCache* StatData, const float ScaleFactor);
|
|
|
| protected:
|
|
|
| virtual TSharedRef<SWidget> RebuildWidget() override;
|
| virtual void ReleaseSlateResources(bool bReleaseChildren) override;
|
|
|
|
|
|
|
|
|
| TSharedPtr<SLyraLatencyGraph> SlateLatencyGraph;
|
| };
|
|
|
| |
| |
| |
| |
|
|
| UCLASS(Abstract)
|
| class ULyraPerfStatWidgetBase : public UCommonUserWidget
|
| {
|
| public:
|
| GENERATED_BODY()
|
|
|
| public:
|
|
|
| UFUNCTION(BlueprintPure)
|
| ELyraDisplayablePerformanceStat GetStatToDisplay() const
|
| {
|
| return StatToDisplay;
|
| }
|
|
|
|
|
| UFUNCTION(BlueprintPure)
|
| double FetchStatValue();
|
|
|
| UFUNCTION(BlueprintCallable)
|
| void UpdateGraphData(const float ScaleFactor = 1.0f);
|
|
|
| protected:
|
|
|
| virtual void NativeConstruct() override;
|
|
|
| ULyraPerformanceStatSubsystem* GetStatSubsystem();
|
|
|
| |
| |
|
|
| UPROPERTY(BlueprintReadWrite, meta=(BindWidget, OptionalWidget=true))
|
| TObjectPtr<ULyraPerfStatGraph> PerfStatGraph;
|
|
|
|
|
| UPROPERTY(Transient)
|
| TObjectPtr<ULyraPerformanceStatSubsystem> CachedStatSubsystem;
|
|
|
| UPROPERTY(EditAnywhere, Category = Display)
|
| FColor GraphLineColor = FColor(255, 255, 255, 255);
|
|
|
| UPROPERTY(EditAnywhere, Category = Display)
|
| FColor GraphBackgroundColor = FColor(0, 0, 0, 128);
|
|
|
| |
| |
|
|
| UPROPERTY(EditAnywhere, Category = Display)
|
| double GraphMaxYValue = 33.0;
|
|
|
|
|
| UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=Display)
|
| ELyraDisplayablePerformanceStat StatToDisplay;
|
| };
|
|
|