Files
UnrealEngineUWP/Engine/Source/ThirdParty/Oculus/Common/AsyncLoadingSplash.cpp
Nick Whiting d64cd6df6d Copying //UE4/Dev-VR to //UE4/Main (Source: //UE4/Dev-VR @ 2940090)
#lockdown nick.penwarden

==========================
MAJOR FEATURES + CHANGES
==========================

Change 2897367 on 2016/03/07 by Chad.Taylor@Chad.Taylor_Z3299_Tango

	PS4Tracker Submit call now assigning the appropriate memory type read mode

Change 2920696 on 2016/03/23 by Nick.Whiting@nick.whiting_T7326_DevVRStream

	Fixed analytics event for VRPIE to have a description

	#jira UE-28562

Change 2925395 on 2016/03/28 by Chad.Taylor@Chad.Taylor_Z3299_Tango

	Aspect ratio and buffer clearing fixed up to properly handle non-standard viewport configurations.

	#jira UE-28816

Change 2932703 on 2016/04/04 by Nick.Whiting@nick.whiting_T7326_DevVRStream

	Merging CL 2922134, fix for culling because of stale view matrices

Change 2932761 on 2016/04/04 by Nick.Whiting@nick.whiting_T7326_DevVRStream

	Oculus 1.3 Engine support, merged from 4.11 stream

Change 2932762 on 2016/04/04 by Nick.Whiting@nick.whiting_T7326_DevVRStream

	Removing redundant libraries for Oculus LibOVRMobile

Change 2932765 on 2016/04/04 by Nick.Whiting@nick.whiting_T7326_DevVRStream

	Merging updated license files for Oculus libraries

Change 2938342 on 2016/04/08 by Ryan.Vance@ryan.vance_devvr

	Fixing bloom offset in stereo.

Change 2938427 on 2016/04/08 by Ryan.Vance@ryan.vance_devvr

	Adding PSVR support for changing the screen percentage dynamically. Previously it could only be changed with ini settings and a relaunch.
	Reworked mutex use in reprojection thread. Some things weren't locked that should have been and removed a redundant mutex.

Change 2938736 on 2016/04/08 by Ryan.Vance@ryan.vance_devvr

	#jira UE-26722
	Updating ISR related code for debug view to fix tesselation.

Change 2939709 on 2016/04/11 by Chad.Taylor@Chad.Taylor_Z3299_Tango

	Explicit order prioritization for ISceneViewExtensions for proper sampling order

Change 2939717 on 2016/04/11 by Chad.Taylor@Chad.Taylor_Z3299_Tango

	Initial stereo layer implementation sans editor wireframe visualization

Change 2939816 on 2016/04/11 by Chad.Taylor@Chad.Taylor_Z3299_Tango

	Stereo layer compionent visualizer

[CL 2940449 by Nick Whiting in Main branch]
2016-04-11 23:01:18 -04:00

167 lines
3.9 KiB
C++

// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.
#include "Engine.h"
#include "AsyncLoadingSplash.h"
DEFINE_LOG_CATEGORY_STATIC(LogLoadingSplash, Log, All);
FAsyncLoadingSplash::FAsyncLoadingSplash() :
bAutoShow(true)
, bInitialized(false)
{
}
FAsyncLoadingSplash::~FAsyncLoadingSplash()
{
// Make sure RenTicker is freed in Shutdown
check(!RenTicker.IsValid())
}
void FAsyncLoadingSplash::AddReferencedObjects(FReferenceCollector& Collector)
{
FScopeLock ScopeLock(&SplashScreensLock);
for (int32 i = 0; i < SplashScreenDescs.Num(); ++i)
{
if (SplashScreenDescs[i].LoadingTexture)
{
Collector.AddReferencedObject(SplashScreenDescs[i].LoadingTexture);
}
}
}
void FAsyncLoadingSplash::Startup()
{
if (!bInitialized)
{
RenTicker = MakeShareable(new FTicker(this));
ENQUEUE_UNIQUE_RENDER_COMMAND_ONEPARAMETER(RegisterAsyncTick,
FTickableObjectRenderThread*, RenTicker, RenTicker.Get(),
{
RenTicker->Register();
});
// Add a delegate to start playing movies when we start loading a map
FCoreUObjectDelegates::PreLoadMap.AddSP(this, &FAsyncLoadingSplash::OnPreLoadMap);
FCoreUObjectDelegates::PostLoadMap.AddSP(this, &FAsyncLoadingSplash::OnPostLoadMap);
bInitialized = true;
}
}
void FAsyncLoadingSplash::Shutdown()
{
if (bInitialized)
{
{
FScopeLock ScopeLock(&SplashScreensLock);
for (int32 i = 0; i < SplashScreenDescs.Num(); ++i)
{
UnloadTexture(SplashScreenDescs[i]);
}
}
ENQUEUE_UNIQUE_RENDER_COMMAND_ONEPARAMETER(UnregisterAsyncTick,
TSharedPtr<FTicker>&, RenTicker, RenTicker,
{
RenTicker->Unregister();
RenTicker = nullptr;
});
FlushRenderingCommands();
FCoreUObjectDelegates::PreLoadMap.RemoveAll(this);
FCoreUObjectDelegates::PostLoadMap.RemoveAll(this);
bInitialized = false;
LoadingCompleted = false;
LoadingStarted = false;
}
}
void FAsyncLoadingSplash::LoadTexture(FSplashDesc& InSplashDesc)
{
check(IsInGameThread());
UnloadTexture(InSplashDesc);
UE_LOG(LogLoadingSplash, Log, TEXT("Loading texture for splash %s..."), *InSplashDesc.TexturePath);
InSplashDesc.LoadingTexture = LoadObject<UTexture2D>(NULL, *InSplashDesc.TexturePath, NULL, LOAD_None, NULL);
if (InSplashDesc.LoadingTexture != nullptr)
{
UE_LOG(LogLoadingSplash, Log, TEXT("...Success. "));
}
}
void FAsyncLoadingSplash::UnloadTexture(FSplashDesc& InSplashDesc)
{
check(IsInGameThread());
if (InSplashDesc.LoadingTexture && InSplashDesc.LoadingTexture->IsValidLowLevel())
{
InSplashDesc.LoadingTexture = nullptr;
}
}
void FAsyncLoadingSplash::OnLoadingBegins()
{
if (bAutoShow)
{
UE_LOG(LogLoadingSplash, Log, TEXT("Loading begins"));
LoadingStarted = true;
LoadingCompleted = false;
Show(ShowAtLoading);
}
}
void FAsyncLoadingSplash::OnLoadingEnds()
{
if (bAutoShow)
{
UE_LOG(LogLoadingSplash, Log, TEXT("Loading ends"));
LoadingStarted = false;
LoadingCompleted = true;
Hide(ShowAtLoading);
}
}
bool FAsyncLoadingSplash::AddSplash(const FSplashDesc& Desc)
{
check(IsInGameThread());
FScopeLock ScopeLock(&SplashScreensLock);
if (SplashScreenDescs.Num() < SPLASH_MAX_NUM)
{
#if !UE_BUILD_SHIPPING
// check if we already have very same layer; if yes, print out a warning
for (int32 i = 0; i < SplashScreenDescs.Num(); ++i)
{
if (SplashScreenDescs[i] == Desc)
{
UE_LOG(LogHMD, Warning, TEXT(""))
}
}
#endif // #if !UE_BUILD_SHIPPING
SplashScreenDescs.Add(Desc);
return true;
}
return false;
}
void FAsyncLoadingSplash::ClearSplashes()
{
check(IsInGameThread());
FScopeLock ScopeLock(&SplashScreensLock);
for (int32 i = 0; i < SplashScreenDescs.Num(); ++i)
{
UnloadTexture(SplashScreenDescs[i]);
}
SplashScreenDescs.SetNum(0);
}
bool FAsyncLoadingSplash::GetSplash(unsigned index, FSplashDesc& OutDesc)
{
check(IsInGameThread());
FScopeLock ScopeLock(&SplashScreensLock);
if (index < unsigned(SplashScreenDescs.Num()))
{
OutDesc = SplashScreenDescs[int32(index)];
return true;
}
return false;
}