CEFInterfaceBrowserApp.cpp
2.0 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
// Engine/Source/Runtime/WebBrowser/Private/CEF/CEFBrowserApp.cpp
#include "CEF/CEFInterfaceBrowserApp.h"
#if WITH_CEF3
FCEFInterfaceBrowserApp::FCEFInterfaceBrowserApp(bool bInGPU)
: MessagePumpCountdown(0)
, bGPU(bInGPU)
{
}
void FCEFInterfaceBrowserApp::OnBeforeChildProcessLaunch(CefRefPtr<CefCommandLine> CommandLine)
{
}
void FCEFInterfaceBrowserApp::OnBeforeCommandLineProcessing(const CefString& ProcessType, CefRefPtr< CefCommandLine > CommandLine)
{
if (bGPU)
{
CommandLine->AppendSwitch("enable-gpu");
CommandLine->AppendSwitch("enable-gpu-compositing");
}
else
{
CommandLine->AppendSwitch("disable-gpu");
CommandLine->AppendSwitch("disable-gpu-compositing");
}
CommandLine->AppendSwitch("enable-begin-frame-scheduling");
}
void FCEFInterfaceBrowserApp::OnRenderProcessThreadCreated(CefRefPtr<CefListValue> ExtraInfo)
{
RenderProcessThreadCreatedDelegate.ExecuteIfBound(ExtraInfo);
}
#if !PLATFORM_LINUX
void FCEFInterfaceBrowserApp::OnScheduleMessagePumpWork(int64 delay_ms)
{
FScopeLock Lock(&MessagePumpCountdownCS);
// 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)
{
delay_ms = 0;
}
MessagePumpCountdown = delay_ms;
}
#endif
void FCEFInterfaceBrowserApp::TickMessagePump(float DeltaTime, bool bForce)
{
#if PLATFORM_LINUX
CefDoMessageLoopWork();
return;
#endif
bool bPump = false;
{
FScopeLock Lock(&MessagePumpCountdownCS);
// count down in order to call message pump
if (MessagePumpCountdown >= 0)
{
MessagePumpCountdown -= DeltaTime * 1000;
if (MessagePumpCountdown <= 0)
{
bPump = true;
}
if (bPump || bForce)
{
// -1 indicates that no countdown is currently happening
MessagePumpCountdown = -1;
}
}
}
if (bPump || bForce)
{
CefDoMessageLoopWork();
}
}
#endif