Commit 19671359 authored by Joone Hur's avatar Joone Hur Committed by Commit Bot

Add support for GPU acceleration in headless Chromium for Linux

Bug: 617551, 765284
Test: headless_shell --use-gl=egl

Change-Id: Id35866d675bac896aa73cca48e479b5b1efdee38
Reviewed-on: https://chromium-review.googlesource.com/c/1474442Reviewed-by: default avatarSami Kyöstilä <skyostil@chromium.org>
Reviewed-by: default avatarKenneth Russell <kbr@chromium.org>
Commit-Queue: Joone Hur <joone.hur@intel.com>
Cr-Commit-Position: refs/heads/master@{#637081}
parent 20e94900
......@@ -585,12 +585,14 @@ void GpuDataManagerImplPrivate::AppendGpuCommandLine(
#if !defined(OS_MACOSX)
// MacOSX bots use real GPU in tests.
if (browser_command_line->HasSwitch(
switches::kOverrideUseSoftwareGLForTests) ||
browser_command_line->HasSwitch(switches::kHeadless)) {
// TODO(zmo): We should also pass in kUseGL here.
// See https://crbug.com/805204.
command_line->AppendSwitch(switches::kOverrideUseSoftwareGLForTests);
if (browser_command_line->HasSwitch(switches::kHeadless)) {
if (command_line->HasSwitch(switches::kUseGL)) {
use_gl = command_line->GetSwitchValueASCII(switches::kUseGL);
// Don't append kOverrideUseSoftwareGLForTests when we need to enable GPU
// hardware for headless chromium.
if (use_gl != gl::kGLImplementationEGLName)
command_line->AppendSwitch(switches::kOverrideUseSoftwareGLForTests);
}
}
#endif // !OS_MACOSX
}
......
......@@ -124,7 +124,16 @@ bool HeadlessContentMainDelegate::BasicStartupComplete(int* exit_code) {
command_line->AppendSwitchASCII(::switches::kOzonePlatform, "headless");
#endif
if (!command_line->HasSwitch(::switches::kUseGL)) {
if (command_line->HasSwitch(::switches::kUseGL)) {
std::string use_gl = command_line->GetSwitchValueASCII(switches::kUseGL);
if (use_gl != gl::kGLImplementationEGLName) {
// Headless uses a software output device which will cause us to fall back
// to software compositing anyway, but only after attempting and failing
// to initialize GPU compositing. We disable GPU compositing here
// explicitly to preempt this attempt.
command_line->AppendSwitch(::switches::kDisableGpuCompositing);
}
} else {
if (!browser_->options()->gl_implementation.empty()) {
command_line->AppendSwitchASCII(::switches::kUseGL,
browser_->options()->gl_implementation);
......@@ -133,12 +142,6 @@ bool HeadlessContentMainDelegate::BasicStartupComplete(int* exit_code) {
}
}
// Headless uses a software output device which will cause us to fall back to
// software compositing anyway, but only after attempting and failing to
// initialize GPU compositing. We disable GPU compositing here explicitly to
// preempt this attempt.
command_line->AppendSwitch(::switches::kDisableGpuCompositing);
content::Profiling::ProcessStarted();
SetContentClient(&content_client_);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment