diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2018-11-15 11:07:50 +0100 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2018-11-16 09:27:30 +0000 |
commit | af29cec0a428108274a60fca3738f67cadbaf23b (patch) | |
tree | 2b9cf987a7ccbbb3baef57f2d6acc15b085d0a2a /src/core/web_engine_context.cpp | |
parent | 396ca081d7b0d9dab7de14ebaec7943c3f857a24 (diff) |
Move thread setup out of the web_engine_context.cpp
This helps avoid conflicts between Qt and Chromium OpenGL
headers.
Change-Id: Ib77d0d985397ef2b9792b26df4bec69bbfbe4611
Reviewed-by: Jüri Valdmann <juri.valdmann@qt.io>
Diffstat (limited to 'src/core/web_engine_context.cpp')
-rw-r--r-- | src/core/web_engine_context.cpp | 72 |
1 files changed, 4 insertions, 68 deletions
diff --git a/src/core/web_engine_context.cpp b/src/core/web_engine_context.cpp index 096568570..dc7459e9f 100644 --- a/src/core/web_engine_context.cpp +++ b/src/core/web_engine_context.cpp @@ -54,12 +54,6 @@ #include "components/viz/common/features.h" #include "components/web_cache/browser/web_cache_manager.h" #include "content/browser/devtools/devtools_http_handler.h" -#include "content/browser/gpu/gpu_main_thread_factory.h" -#include "content/browser/renderer_host/render_process_host_impl.h" -#include "content/browser/utility_process_host.h" -#include "content/gpu/gpu_child_thread.h" -#include "content/gpu/gpu_process.h" -#include "content/gpu/in_process_gpu_thread.h" #include "content/public/app/content_main.h" #include "content/public/app/content_main_runner.h" #include "content/public/browser/browser_main_runner.h" @@ -69,9 +63,8 @@ #include "content/public/common/content_paths.h" #include "content/public/common/content_switches.h" #include "content/public/common/main_function_params.h" -#include "content/renderer/in_process_renderer_thread.h" -#include "content/utility/in_process_utility_thread.h" #include "gpu/command_buffer/service/gpu_switches.h" +#include "gpu/command_buffer/service/sync_point_manager.h" #include "gpu/ipc/host/gpu_switches.h" #include "media/audio/audio_manager.h" #include "mojo/core/embedder/embedder.h" @@ -551,13 +544,11 @@ WebEngineContext::WebEngineContext() parsedCommandLine->AppendSwitch(switches::kDisableGpu); } - content::UtilityProcessHost::RegisterUtilityMainThreadFactory(content::CreateInProcessUtilityThread); - content::RenderProcessHostImpl::RegisterRendererMainThreadFactory(content::CreateInProcessRendererThread); - content::RegisterGpuMainThreadFactory(content::CreateInProcessGpuThread); + bool threadedGpu = true; #ifndef QT_NO_OPENGL - if (!QOpenGLContext::supportsThreadedOpenGL()) - content::RegisterGpuMainThreadFactory(createGpuThreadController); + threadedGpu = QOpenGLContext::supportsThreadedOpenGL(); #endif + registerMainThreadFactories(threadedGpu); mojo::core::Init(); @@ -619,59 +610,4 @@ printing::PrintJobManager* WebEngineContext::getPrintJobManager() } #endif -// static -std::unique_ptr<content::GpuThreadController> WebEngineContext::createGpuThreadController( - const content::InProcessChildThreadParams ¶ms, const gpu::GpuPreferences &gpuPreferences) -{ - struct Controller : content::GpuThreadController - { - Controller(const content::InProcessChildThreadParams ¶ms, const gpu::GpuPreferences &gpuPreferences) - { - content::BrowserThread::PostTask( - content::BrowserThread::UI, FROM_HERE, - base::BindOnce(&WebEngineContext::createGpuProcess, params, gpuPreferences)); - } - ~Controller() - { - content::BrowserThread::PostTask( - content::BrowserThread::UI, FROM_HERE, - base::BindOnce(&WebEngineContext::destroyGpuProcess)); - } - }; - return std::make_unique<Controller>(params, gpuPreferences); -} - -// static -void WebEngineContext::createGpuProcess( - const content::InProcessChildThreadParams ¶ms, const gpu::GpuPreferences &gpuPreferences) -{ - DCHECK_CURRENTLY_ON(content::BrowserThread::UI); - - WebEngineContext *context = current(); - if (!context || context->m_gpuProcessDestroyed) - return; - - context->m_gpuProcess = std::make_unique<content::GpuProcess>(base::ThreadPriority::NORMAL); - auto gpuInit = std::make_unique<gpu::GpuInit>(); - gpuInit->InitializeInProcess(base::CommandLine::ForCurrentProcess(), gpuPreferences); - auto childThread = new content::GpuChildThread(params, std::move(gpuInit)); - childThread->Init(base::Time::Now()); - context->m_gpuProcess->set_main_thread(childThread); -} - -// static -void WebEngineContext::destroyGpuProcess() -{ - DCHECK_CURRENTLY_ON(content::BrowserThread::UI); - - WebEngineContext *context = current(); - if (!context) - return; - - // viz::GpuServiceImpl::~GpuServiceImpl waits for io task. - base::ScopedAllowBaseSyncPrimitivesForTesting allow; - context->m_gpuProcess.reset(); - context->m_gpuProcessDestroyed = true; -} - } // namespace |