Files
UnrealEngineUWP/Engine/Source/Developer/Android/AndroidTargetPlatform/Private/AndroidTargetPlatform.h
Ben Marsh 4ba423868f Copying //UE4/Dev-Build to //UE4/Dev-Main (Source: //UE4/Dev-Build @ 3209340)
#lockdown Nick.Penwarden
#rb none

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

Change 3209340 on 2016/11/23 by Ben.Marsh

	Convert UE4 codebase to an "include what you use" model - where every header just includes the dependencies it needs, rather than every source file including large monolithic headers like Engine.h and UnrealEd.h.

	Measured full rebuild times around 2x faster using XGE on Windows, and improvements of 25% or more for incremental builds and full rebuilds on most other platforms.

	  * Every header now includes everything it needs to compile.
	        * There's a CoreMinimal.h header that gets you a set of ubiquitous types from Core (eg. FString, FName, TArray, FVector, etc...). Most headers now include this first.
	        * There's a CoreTypes.h header that sets up primitive UE4 types and build macros (int32, PLATFORM_WIN64, etc...). All headers in Core include this first, as does CoreMinimal.h.
	  * Every .cpp file includes its matching .h file first.
	        * This helps validate that each header is including everything it needs to compile.
	  * No engine code includes a monolithic header such as Engine.h or UnrealEd.h any more.
	        * You will get a warning if you try to include one of these from the engine. They still exist for compatibility with game projects and do not produce warnings when included there.
	        * There have only been minor changes to our internal games down to accommodate these changes. The intent is for this to be as seamless as possible.
	  * No engine code explicitly includes a precompiled header any more.
	        * We still use PCHs, but they're force-included on the compiler command line by UnrealBuildTool instead. This lets us tune what they contain without breaking any existing include dependencies.
	        * PCHs are generated by a tool to get a statistical amount of coverage for the source files using it, and I've seeded the new shared PCHs to contain any header included by > 15% of source files.

	Tool used to generate this transform is at Engine\Source\Programs\IncludeTool.

[CL 3209342 by Ben Marsh in Main branch]
2016-11-23 15:48:37 -05:00

264 lines
8.2 KiB
C++

// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.
/*=============================================================================
AndroidTargetPlatform.h: Declares the FAndroidTargetPlatform class.
=============================================================================*/
#pragma once
#include "CoreTypes.h"
#include "Containers/UnrealString.h"
#include "UObject/NameTypes.h"
#include "Delegates/IDelegateInstance.h"
#include "Containers/Map.h"
#include "Delegates/Delegate.h"
#include "Containers/Ticker.h"
#include "Misc/ScopeLock.h"
#if WITH_ENGINE
#include "Internationalization/Text.h"
#include "StaticMeshResources.h"
#endif // WITH_ENGINE
class FTargetDeviceId;
class IAndroidDeviceDetection;
class ITargetPlatform;
class UTextureLODSettings;
enum class ETargetPlatformFeatures;
template<typename TPlatformProperties> class TTargetPlatformBase;
template< typename InElementType, typename KeyFuncs , typename Allocator > class TSet;
template<typename KeyType,typename ValueType,typename SetAllocator ,typename KeyFuncs > class TMap;
template<typename KeyType,typename ValueType,typename SetAllocator ,typename KeyFuncs > class TMultiMap;
template<typename TPlatformProperties> class TTargetPlatformBase;
/**
* Defines supported texture format names.
*/
namespace AndroidTexFormat
{
// Compressed Texture Formats
static FName NamePVRTC2(TEXT("PVRTC2"));
static FName NamePVRTC4(TEXT("PVRTC4"));
static FName NameAutoPVRTC(TEXT("AutoPVRTC"));
static FName NameDXT1(TEXT("DXT1"));
static FName NameDXT5(TEXT("DXT5"));
static FName NameAutoDXT(TEXT("AutoDXT"));
static FName NameATC_RGB(TEXT("ATC_RGB"));
static FName NameATC_RGBA_E(TEXT("ATC_RGBA_E")); // explicit alpha
static FName NameATC_RGBA_I(TEXT("ATC_RGBA_I")); // interpolated alpha
static FName NameAutoATC(TEXT("AutoATC"));
static FName NameETC1(TEXT("ETC1"));
static FName NameAutoETC1(TEXT("AutoETC1")); // ETC1 or uncompressed RGBA, if alpha channel required
static FName NameETC2_RGB(TEXT("ETC2_RGB"));
static FName NameETC2_RGBA(TEXT("ETC2_RGBA"));
static FName NameAutoETC2(TEXT("AutoETC2"));
static FName NameASTC_4x4(TEXT("ASTC_4x4"));
static FName NameASTC_6x6(TEXT("ASTC_6x6"));
static FName NameASTC_8x8(TEXT("ASTC_8x8"));
static FName NameASTC_10x10(TEXT("ASTC_10x10"));
static FName NameASTC_12x12(TEXT("ASTC_12x12"));
static FName NameAutoASTC(TEXT("AutoASTC"));
// Uncompressed Texture Formats
static FName NameBGRA8(TEXT("BGRA8"));
static FName NameG8(TEXT("G8"));
static FName NameVU8(TEXT("VU8"));
static FName NameRGBA16F(TEXT("RGBA16F"));
// Error "formats" (uncompressed)
static FName NamePOTERROR(TEXT("POTERROR"));
}
/**
* FAndroidTargetPlatform, abstraction for cooking Android platforms
*/
template<class TPlatformProperties>
class FAndroidTargetPlatform
: public TTargetPlatformBase< TPlatformProperties >
{
public:
/**
* Default constructor.
*/
FAndroidTargetPlatform( );
/**
* Destructor
*/
~FAndroidTargetPlatform();
public:
/**
* Gets the name of the Android platform variant, i.e. ATC, DXT, PVRTC, etc.
*
* @param Variant name.
*/
virtual FString GetAndroidVariantName( )
{
return FString();
}
public:
//~ Begin ITargetPlatform Interface
virtual void EnableDeviceCheck(bool OnOff) override {}
virtual bool AddDevice( const FString& DeviceName, bool bDefault ) override
{
return false;
}
virtual void GetAllDevices( TArray<ITargetDevicePtr>& OutDevices ) const override;
virtual ECompressionFlags GetBaseCompressionMethod( ) const override;
virtual bool GenerateStreamingInstallManifest(const TMultiMap<FString, int32>& ChunkMap, const TSet<int32>& ChunkIDsInUse) const override
{
return true;
}
virtual ITargetDevicePtr GetDefaultDevice( ) const override;
virtual ITargetDevicePtr GetDevice( const FTargetDeviceId& DeviceId ) override;
virtual bool IsRunningPlatform( ) const override;
virtual bool IsServerOnly( ) const override
{
return false;
}
virtual bool IsSdkInstalled(bool bProjectHasCode, FString& OutDocumentationPath) const override;
virtual bool SupportsFeature( ETargetPlatformFeatures Feature ) const override;
virtual bool SupportsTextureFormat( FName Format ) const
{
// By default we support all texture formats.
return true;
}
virtual bool SupportsCompressedNonPOT( ) const
{
// most formats do support non-POT compressed textures
return true;
}
#if WITH_ENGINE
virtual void GetReflectionCaptureFormats( TArray<FName>& OutFormats ) const override;
virtual void GetAllPossibleShaderFormats( TArray<FName>& OutFormats ) const override;
virtual void GetAllTargetedShaderFormats(TArray<FName>& OutFormats) const override;
virtual void GetAllCachedShaderFormats( TArray<FName>& OutFormats ) const override {}
virtual const class FStaticMeshLODSettings& GetStaticMeshLODSettings() const override;
virtual void GetTextureFormats( const UTexture* InTexture, TArray<FName>& OutFormats ) const override;
virtual const UTextureLODSettings& GetTextureLODSettings() const override;
virtual void RegisterTextureLODSettings(const UTextureLODSettings* InTextureLODSettings) override
{
TextureLODSettings = InTextureLODSettings;
}
virtual FName GetWaveFormat( const class USoundWave* Wave ) const override;
#endif //WITH_ENGINE
virtual bool SupportsVariants() const override;
virtual FText GetVariantTitle() const override;
virtual void GetBuildProjectSettingKeys(FString& OutSection, TArray<FString>& InBoolKeys, TArray<FString>& InIntKeys, TArray<FString>& InStringKeys) const override
{
OutSection = TEXT("/Script/AndroidRuntimeSettings.AndroidRuntimeSettings");
InBoolKeys.Add(TEXT("bBuildForArmV7")); InBoolKeys.Add(TEXT("bBuildForArm64")); InBoolKeys.Add(TEXT("bBuildForX86"));
InBoolKeys.Add(TEXT("bBuildForX8664")); InBoolKeys.Add(TEXT("bBuildForES2")); InBoolKeys.Add(TEXT("bBuildForESDeferred"));
InBoolKeys.Add(TEXT("bBuildForES31"));
}
DECLARE_DERIVED_EVENT(FAndroidTargetPlatform, ITargetPlatform::FOnTargetDeviceDiscovered, FOnTargetDeviceDiscovered);
virtual FOnTargetDeviceDiscovered& OnDeviceDiscovered( ) override
{
return DeviceDiscoveredEvent;
}
DECLARE_DERIVED_EVENT(FAndroidTargetPlatform, ITargetPlatform::FOnTargetDeviceLost, FOnTargetDeviceLost);
virtual FOnTargetDeviceLost& OnDeviceLost( ) override
{
return DeviceLostEvent;
}
//~ End ITargetPlatform Interface
protected:
/**
* Adds the specified texture format to the OutFormats if this android target platforms supports it.
*
* @param Format - The format to add.
* @param OutFormats - The collection of formats to add to.
* @param bIsCompressedNonPOT - If this is true, the texture wants to be compressed but is not a power of 2
*/
void AddTextureFormatIfSupports( FName Format, TArray<FName>& OutFormats, bool bIsCompressedNonPOT=false ) const;
/**
* Return true if this device has a supported set of extensions for this platform.
*
* @param Extensions - The GL extensions string.
* @param GLESVersion - The GLES version reported by this device.
*/
virtual bool SupportedByExtensionsString( const FString& ExtensionsString, const int GLESVersion ) const
{
return true;
}
#if WITH_ENGINE
// Holds the Engine INI settings (for quick access).
FConfigFile EngineSettings;
#endif //WITH_ENGINE
private:
// Handles when the ticker fires.
bool HandleTicker( float DeltaTime );
// Holds a map of valid devices.
TMap<FString, FAndroidTargetDevicePtr> Devices;
// Holds a delegate to be invoked when the widget ticks.
FTickerDelegate TickDelegate;
// Handle to the registered TickDelegate.
FDelegateHandle TickDelegateHandle;
// Pointer to the device detection handler that grabs device ids in another thread
IAndroidDeviceDetection* DeviceDetection;
#if WITH_ENGINE
// Holds a cache of the target LOD settings.
const UTextureLODSettings* TextureLODSettings;
// Holds the static mesh LOD settings.
FStaticMeshLODSettings StaticMeshLODSettings;
ITargetDevicePtr DefaultDevice;
#endif //WITH_ENGINE
// Holds an event delegate that is executed when a new target device has been discovered.
FOnTargetDeviceDiscovered DeviceDiscoveredEvent;
// Holds an event delegate that is executed when a target device has been lost, i.e. disconnected or timed out.
FOnTargetDeviceLost DeviceLostEvent;
};
#include "AndroidTargetPlatform.inl"