Files
UnrealEngineUWP/Engine/Source/Programs/CrashReportClient/Private/MainLoopTiming.cpp
Ryan Durand 9ef3748747 Updating copyrights for Engine Programs.
#rnx
#rb none
#jira none

#ROBOMERGE-OWNER: ryan.durand
#ROBOMERGE-AUTHOR: ryan.durand
#ROBOMERGE-SOURCE: CL 10869242 in //Fortnite/Release-12.00/... via CL 10869536
#ROBOMERGE-BOT: FORTNITE (Main -> Dev-EngineMerge) (v613-10869866)

[CL 10870955 by Ryan Durand in Main branch]
2019-12-26 23:01:54 -05:00

48 lines
1.3 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#include "MainLoopTiming.h"
#include "HAL/PlatformProcess.h"
#include "Math/UnrealMathUtility.h"
#include "Containers/Ticker.h"
#include "CrashReportClientApp.h"
#include "Async/TaskGraphInterfaces.h"
#if !CRASH_REPORT_UNATTENDED_ONLY
#include "Framework/Application/SlateApplication.h"
#endif
FMainLoopTiming::FMainLoopTiming(float InIdealTickRate, EMainLoopOptions::Type Options)
: IdealFrameTime(1.f / InIdealTickRate)
, bTickSlate(Options & EMainLoopOptions::UsingSlate)
{
}
void FMainLoopTiming::Tick()
{
static double ActualDeltaTime = IdealFrameTime;
static double LastTime = FPlatformTime::Seconds();
// Tick app logic
FTaskGraphInterface::Get().ProcessThreadUntilIdle(ENamedThreads::GameThread);
FTicker::GetCoreTicker().Tick(ActualDeltaTime);
#if !CRASH_REPORT_UNATTENDED_ONLY
// Tick SlateApplication
if (bTickSlate)
{
FSlateApplication::Get().PumpMessages();
FSlateApplication::Get().Tick();
}
#endif // !CRASH_REPORT_UNATTENDED_ONLY
// Sleep Throttling
// Copied from Community Portal - should be shared
FPlatformProcess::Sleep(FMath::Max<float>(0, IdealFrameTime - (FPlatformTime::Seconds() - LastTime)));
// Calculate deltas
const double AppTime = FPlatformTime::Seconds();
ActualDeltaTime = AppTime - LastTime;
LastTime = AppTime;
}