summaryrefslogtreecommitdiffstats
path: root/src/core/web_engine_context.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/web_engine_context.cpp')
-rw-r--r--src/core/web_engine_context.cpp77
1 files changed, 57 insertions, 20 deletions
diff --git a/src/core/web_engine_context.cpp b/src/core/web_engine_context.cpp
index aee5be42f..e988fa23c 100644
--- a/src/core/web_engine_context.cpp
+++ b/src/core/web_engine_context.cpp
@@ -54,10 +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/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"
@@ -67,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"
@@ -85,16 +80,19 @@
#include "content/public/app/sandbox_helper_win.h"
#endif // OS_WIN
+#ifndef QT_NO_ACCESSIBILITY
+#include "accessibility_activation_observer.h"
+#endif
#include "api/qwebengineurlscheme.h"
-#include "profile_adapter.h"
#include "content_browser_client_qt.h"
#include "content_client_qt.h"
#include "content_main_delegate_qt.h"
#include "devtools_manager_delegate_qt.h"
#include "media_capture_devices_dispatcher.h"
#include "net/webui_controller_factory_qt.h"
-#include "type_conversion.h"
#include "ozone/gl_context_qt.h"
+#include "profile_adapter.h"
+#include "type_conversion.h"
#include "web_engine_library_info.h"
#include <QFileInfo>
@@ -214,6 +212,12 @@ void WebEngineContext::destroy()
{
if (m_devtoolsServer)
m_devtoolsServer->stop();
+
+ // Normally the GPU thread is shut down when the GpuProcessHost is destroyed
+ // on IO thread (triggered by ~BrowserMainRunner). But by that time the UI
+ // task runner is not working anymore so we need to do this earlier.
+ destroyGpuProcess();
+
base::MessagePump::Delegate *delegate =
static_cast<base::MessageLoop *>(m_runLoop->delegate_);
// Flush the UI message loop before quitting.
@@ -269,6 +273,8 @@ WebEngineContext *WebEngineContext::current()
qAddPostRoutine(WebEngineContext::destroyContextPostRoutine);
// Add a false reference so there is no race between unreferencing m_handle and a global QApplication.
m_handle->AddRef();
+ // This is need since gpu process start requires sync point manager;
+ m_handle->initialize();
}
return m_handle.get();
}
@@ -327,6 +333,10 @@ static void appendToFeatureSwitch(base::CommandLine *commandLine, const char *fe
WebEngineContext::WebEngineContext()
: m_mainDelegate(new ContentMainDelegateQt)
, m_globalQObject(new QObject())
+ , m_syncPointManager(new gpu::SyncPointManager())
+{}
+
+void WebEngineContext::initialize()
{
base::TaskScheduler::Create("Browser");
m_contentRunner.reset(content::ContentMainRunner::Create());
@@ -414,10 +424,23 @@ WebEngineContext::WebEngineContext()
// an OpenGL Core Profile context. If the switch is not set, it would always try to create a
// Core Profile context, even if Qt uses a legacy profile, which causes
// "Could not share GL contexts" warnings, because it's not possible to share between Core and
- // legacy profiles.
- // Given that Core profile is not currently supported on Windows anyway, pass this switch to
- // get rid of the warnings.
- parsedCommandLine->AppendSwitch(switches::kDisableES3GLContext);
+ // legacy profiles. See GLContextWGL::Initialize().
+ // Given that Desktop GL Core profile is not currently supported on Windows anyway, pass this
+ // switch to get rid of the warnings.
+ //
+ // The switch is also used to determine which version of OpenGL ES to use (2 or 3) when using
+ // ANGLE.
+ // If the switch is not set, Chromium will always try to create an ES3 context, even if Qt uses
+ // an ES2 context, which causes resource sharing issues (black screen),
+ // see gpu::gles2::GenerateGLContextAttribs().
+ // Make sure to disable ES3 context creation when using ES2.
+ const bool isGLES2Context = qt_gl_global_share_context()
+ && qt_gl_global_share_context()->isOpenGLES()
+ && qt_gl_global_share_context()->format().majorVersion() == 2;
+ const bool isDesktopGLOrSoftware = !usingANGLE();
+
+ if (isDesktopGLOrSoftware || isGLES2Context)
+ parsedCommandLine->AppendSwitch(switches::kDisableES3GLContext);
#endif
// Needed to allow navigations within pages that were set using setHtml(). One example is
// tst_QWebEnginePage::acceptNavigationRequest.
@@ -450,8 +473,7 @@ WebEngineContext::WebEngineContext()
#ifndef QT_NO_OPENGL
bool tryGL =
- !usingANGLE()
- && (!usingSoftwareDynamicGL()
+ (!usingSoftwareDynamicGL()
// If user requested WebGL support instead of using Skia rendering to
// bitmaps, use software rendering via software OpenGL. This might be less
// performant, but at least provides WebGL support.
@@ -461,10 +483,13 @@ WebEngineContext::WebEngineContext()
if (tryGL) {
if (qt_gl_global_share_context() && qt_gl_global_share_context()->isValid()) {
- // If the native handle is QEGLNativeContext try to use GL ES/2, if there is no native handle
- // assume we are using wayland and try GL ES/2, and finally Ozone demands GL ES/2 too.
+ // If the native handle is QEGLNativeContext try to use GL ES/2.
+ // If there is no native handle, assume we are using wayland and try GL ES/2.
+ // If we are using ANGLE on Windows, use OpenGL ES (2 or 3).
if (qt_gl_global_share_context()->nativeHandle().isNull()
- || !strcmp(qt_gl_global_share_context()->nativeHandle().typeName(), "QEGLNativeContext"))
+ || !strcmp(qt_gl_global_share_context()->nativeHandle().typeName(),
+ "QEGLNativeContext")
+ || usingANGLE())
{
if (qt_gl_global_share_context()->isOpenGLES()) {
glType = gl::kGLImplementationEGLName;
@@ -530,9 +555,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
+ threadedGpu = QOpenGLContext::supportsThreadedOpenGL();
+#endif
+ registerMainThreadFactories(threadedGpu);
mojo::core::Init();
@@ -584,6 +611,10 @@ WebEngineContext::WebEngineContext()
m_printJobManager.reset(new printing::PrintJobManager());
#endif
+#ifndef QT_NO_ACCESSIBILITY
+ m_accessibilityActivationObserver.reset(new AccessibilityActivationObserver());
+#endif
+
content::WebUIControllerFactory::RegisterFactory(WebUIControllerFactoryQt::GetInstance());
}
@@ -593,4 +624,10 @@ printing::PrintJobManager* WebEngineContext::getPrintJobManager()
return m_printJobManager.get();
}
#endif
+
+gpu::SyncPointManager *WebEngineContext::syncPointManager()
+{
+ return m_syncPointManager.get();
+}
+
} // namespace