@@ -117,7 +117,8 @@ class SimpleBrowserViewDelegate : public CefBrowserViewDelegate {
117117SimpleApp::SimpleApp (bool use_viewes, bool supress_log,
118118 THttpServer *serv, const std::string &url, const std::string &cont,
119119 int width, int height, bool headless)
120- : CefApp(), CefBrowserProcessHandler(), fUseViewes(use_viewes), fSupressLog(supress_log), fFirstServer(serv), fFirstUrl(url), fFirstContent(cont), fFirstHeadless(headless)
120+ : CefApp(), CefBrowserProcessHandler(), fUseViewes(use_viewes), fSupressLog(supress_log),
121+ fFirstServer(serv), fFirstUrl(url), fFirstContent(cont), fFirstHeadless(headless)
121122{
122123 fFirstRect .Set (0 , 0 , width, height);
123124
@@ -157,18 +158,41 @@ void SimpleApp::OnBeforeCommandLineProcessing(const CefString &process_type, Cef
157158 command_line->AppendSwitchWithValue (" enable-logging" , " none" );
158159 }
159160
160- #ifdef OS_MACOSX
161+ if (fNextHeadless ) {
162+ command_line->AppendSwitchWithValue (" user-data-dir" , " ." );
163+ command_line->AppendSwitch (" allow-file-access-from-files" );
164+ command_line->AppendSwitch (" disable-web-security" );
165+ command_line->AppendSwitch (" off-screen-rendering-enabled" );
166+ }
161167
168+ #ifdef OS_MACOSX
162169 if (fNextHeadless ) {
170+ command_line->AppendSwitch (" headless" );
163171 command_line->AppendSwitchWithValue (" use-angle" , " swiftshader" );
164172 command_line->AppendSwitch (" enable-unsafe-swiftshader" );
165173 command_line->AppendSwitch (" disable-gpu" );
174+ // command_line->AppendSwitch("enable-gpu-rasterization");
175+ // if (fUseViewes)
176+ // command_line->AppendSwitchWithValue("ozone-platform", "headless");
166177 } else {
167178 command_line->AppendSwitchWithValue (" use-angle" , " metal" );
168179 command_line->AppendSwitch (" ignore-gpu-blocklist" );
169180 command_line->AppendSwitch (" enable-webgl" );
170181 }
171182#endif
183+
184+ #ifdef OS_LINUX
185+ if (fNextHeadless ) {
186+ command_line->AppendSwitch (" headless" );
187+ command_line->AppendSwitchWithValue (" use-gl" , " swiftshader" );
188+ command_line->AppendSwitch (" disable-gpu" );
189+ command_line->AppendSwitch (" ignore-gpu-blocklist" );
190+ command_line->AppendSwitch (" enable-unsafe-swiftshader" );
191+
192+ if (fUseViewes )
193+ command_line->AppendSwitchWithValue (" ozone-platform" , " headless" );
194+ }
195+ #endif
172196}
173197
174198void SimpleApp::OnBeforeChildProcessLaunch (CefRefPtr<CefCommandLine> command_line)
@@ -180,18 +204,18 @@ void SimpleApp::OnContextInitialized()
180204 CEF_REQUIRE_UI_THREAD ();
181205
182206 if (!fFirstUrl .empty () || !fFirstContent .empty ()) {
183- StartWindow (fFirstServer , fFirstUrl , fFirstContent , fFirstRect );
207+ StartWindow (fFirstServer , fFirstUrl , fFirstContent , fFirstRect , fFirstHeadless );
184208 fFirstUrl .clear ();
185209 fFirstContent .clear ();
186210 }
187211}
188212
189213
190- void SimpleApp::StartWindow (THttpServer *serv, const std::string &addr, const std::string &cont, CefRect &rect)
214+ void SimpleApp::StartWindow (THttpServer *serv, const std::string &addr, const std::string &cont, CefRect &rect, bool is_headless )
191215{
192216 CEF_REQUIRE_UI_THREAD ();
193217
194- bool is_batch = addr.empty () && !cont.empty ();
218+ bool is_batch = ( addr.empty () && !cont.empty ()) || is_headless ;
195219
196220 if (!fGuiHandler )
197221 fGuiHandler = new GuiHandler (fUseViewes );
0 commit comments