2019-12-26 14:45:42 -05:00
// Copyright Epic Games, Inc. All Rights Reserved.
2014-10-02 10:53:05 -04:00
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
# include "CEF/CEFBrowserApp.h"
2021-09-29 17:45:16 -04:00
# include "HAL/IConsoleManager.h"
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
2014-10-02 10:53:05 -04:00
# if WITH_CEF3
2022-05-31 08:44:08 -04:00
# include "WebBrowserLog.h"
//#define DEBUG_CEFMESSAGELOOP_FRAMERATE 1 // uncomment this to have debug spew about the FPS we call the CefDoMessageLoopWork function
2016-09-23 17:31:51 -04:00
2021-09-29 17:45:16 -04:00
DEFINE_LOG_CATEGORY ( LogCEFBrowser ) ;
static bool bCEFGPUAcceleration = true ;
static FAutoConsoleVariableRef CVarCEFGPUAcceleration (
TEXT ( " r.CEFGPUAcceleration " ) ,
bCEFGPUAcceleration ,
TEXT ( " Enables GPU acceleration in CEF \n " ) ,
ECVF_Default ) ;
2016-09-23 17:31:51 -04:00
FCEFBrowserApp : : FCEFBrowserApp ( )
2018-09-25 10:11:35 -04:00
: MessagePumpCountdown ( 0 )
2014-10-02 10:53:05 -04:00
{
}
2016-09-23 17:31:51 -04:00
void FCEFBrowserApp : : OnBeforeChildProcessLaunch ( CefRefPtr < CefCommandLine > CommandLine )
2015-04-02 09:42:37 -04:00
{
}
2016-09-23 17:31:51 -04:00
void FCEFBrowserApp : : OnBeforeCommandLineProcessing ( const CefString & ProcessType , CefRefPtr < CefCommandLine > CommandLine )
2015-12-08 16:59:43 -05:00
{
2021-09-29 17:45:16 -04:00
if ( bCEFGPUAcceleration )
{
UE_LOG ( LogCEFBrowser , Log , TEXT ( " CEF GPU acceleration enabled " ) ) ;
CommandLine - > AppendSwitch ( " enable-gpu " ) ;
CommandLine - > AppendSwitch ( " enable-gpu-compositing " ) ;
}
else
{
UE_LOG ( LogCEFBrowser , Log , TEXT ( " CEF GPU acceleration disabled " ) ) ;
CommandLine - > AppendSwitch ( " disable-gpu " ) ;
CommandLine - > AppendSwitch ( " disable-gpu-compositing " ) ;
}
2015-12-08 16:59:43 -05:00
CommandLine - > AppendSwitch ( " enable-begin-frame-scheduling " ) ;
2021-03-09 01:37:10 -04:00
CommandLine - > AppendSwitch ( " disable-pinch " ) ; // the web pages we have don't expect zoom to work right now so disable touchpad pinch zoom
CommandLine - > AppendSwitch ( " disable-gpu-shader-disk-cache " ) ; // Don't create a "GPUCache" directory when cache-path is unspecified.
# if PLATFORM_MAC
CommandLine - > AppendSwitch ( " use-mock-keychain " ) ; // Disable the toolchain prompt on macOS.
# endif
2022-05-31 08:44:08 -04:00
// Uncomment these to lines to create a FULL network log from chrome, which can then be inspected using https://netlog-viewer.appspot.com/
//CommandLine->AppendSwitchWithValue("log-net-log", "c:\\temp\\cef_net_log.json");
//CommandLine->AppendSwitchWithValue("net-log-capture-mode", "IncludeCookiesAndCredentials");
2015-12-08 16:59:43 -05:00
}
2015-04-02 09:42:37 -04:00
2018-09-25 10:11:35 -04:00
void FCEFBrowserApp : : OnScheduleMessagePumpWork ( int64 delay_ms )
{
FScopeLock Lock ( & MessagePumpCountdownCS ) ;
2020-01-07 17:54:50 -05:00
// As per CEF documentation, if delay_ms is <= 0, then the call to CefDoMessageLoopWork should happen reasonably soon. If delay_ms is > 0, then the call
// to CefDoMessageLoopWork should be scheduled to happen after the specified delay and any currently pending scheduled call should be canceled.
if ( delay_ms < 0 )
2018-09-25 10:11:35 -04:00
{
2020-01-07 17:54:50 -05:00
delay_ms = 0 ;
2018-09-25 10:11:35 -04:00
}
2020-01-07 17:54:50 -05:00
MessagePumpCountdown = delay_ms ;
2018-09-25 10:11:35 -04:00
}
2021-03-09 01:37:10 -04:00
bool FCEFBrowserApp : : TickMessagePump ( float DeltaTime , bool bForce )
2018-09-25 10:11:35 -04:00
{
2020-01-07 17:54:50 -05:00
bool bPump = false ;
2018-09-25 10:11:35 -04:00
{
2020-01-07 17:54:50 -05:00
FScopeLock Lock ( & MessagePumpCountdownCS ) ;
// count down in order to call message pump
if ( MessagePumpCountdown > = 0 )
2018-09-25 10:11:35 -04:00
{
2021-03-09 01:37:10 -04:00
MessagePumpCountdown - = ( DeltaTime * 1000 ) ;
2020-01-07 17:54:50 -05:00
if ( MessagePumpCountdown < = 0 )
{
bPump = true ;
}
if ( bPump | | bForce )
{
// -1 indicates that no countdown is currently happening
MessagePumpCountdown = - 1 ;
}
2018-09-25 10:11:35 -04:00
}
}
2020-01-07 17:54:50 -05:00
2022-05-31 08:44:08 -04:00
# ifdef DEBUG_CEFMESSAGELOOP_FRAMERATE
static float SecondsFrameRate = 0 ;
static int NumFrames = 0 ;
SecondsFrameRate + = DeltaTime ;
# endif
2018-09-25 10:11:35 -04:00
if ( bPump | | bForce )
{
2022-05-31 08:44:08 -04:00
# ifdef DEBUG_CEFMESSAGELOOP_FRAMERATE
+ + NumFrames ;
if ( NumFrames % 100 = = 0 | | SecondsFrameRate > 5.0f )
{
UE_LOG ( LogWebBrowser , Error , TEXT ( " CefDoMessageLoopWork call Frame Rate %0.2f " ) , NumFrames / SecondsFrameRate ) ;
SecondsFrameRate = 0 ;
NumFrames = 0 ;
}
# endif
2018-09-25 10:11:35 -04:00
CefDoMessageLoopWork ( ) ;
2021-03-09 01:37:10 -04:00
return true ;
2018-09-25 10:11:35 -04:00
}
2021-03-09 01:37:10 -04:00
return false ;
2018-09-25 10:11:35 -04:00
}
2014-10-02 10:53:05 -04:00
# endif