2 #include <cef_browser.h>
3 #include <cef_client.h>
4 #include <cef_version.h>
8 #include "nageru_cef_app.h"
12 void NageruCefApp::OnBeforeCommandLineProcessing(
13 const CefString& process_type,
14 CefRefPtr<CefCommandLine> command_line)
16 command_line->AppendSwitch("disable-gpu");
17 command_line->AppendSwitch("disable-gpu-compositing");
18 command_line->AppendSwitch("enable-begin-frame-scheduling");
21 void NageruCefApp::initialize_cef()
23 unique_lock<mutex> lock(cef_mutex);
24 if (cef_thread_refcount++ == 0) {
25 cef_thread = thread(&NageruCefApp::cef_thread_func, this);
27 cef_initialized_cond.wait(lock, [this]{ return cef_initialized; });
30 void NageruCefApp::close_browser(CefRefPtr<CefBrowser> browser)
32 lock_guard<mutex> lock(cef_mutex);
33 browser->GetHost()->CloseBrowser(/*force_close=*/true);
36 void NageruCefApp::unref_cef()
38 unique_lock<mutex> lock(cef_mutex);
39 if (--cef_thread_refcount == 0) {
40 CefPostTask(TID_UI, new CEFTaskAdapter(&CefQuitMessageLoop));
46 void NageruCefApp::cef_thread_func()
48 CefMainArgs main_args;
50 //settings.log_severity = LOGSEVERITY_VERBOSE;
51 settings.windowless_rendering_enabled = true;
52 settings.no_sandbox = true;
53 settings.command_line_args_disabled = false;
54 CefInitialize(main_args, settings, this, nullptr);
57 lock_guard<mutex> lock(cef_mutex);
58 cef_initialized = true;
60 cef_initialized_cond.notify_all();