diff options
-rw-r--r-- | mkspecs/features/functions.prf | 5 | ||||
-rw-r--r-- | src/core/chromium_overrides.cpp | 25 | ||||
-rw-r--r-- | src/core/config/desktop_linux.pri | 8 | ||||
-rw-r--r-- | src/core/config/embedded_linux.pri | 13 | ||||
-rw-r--r-- | src/core/config/linux.pri | 21 | ||||
-rw-r--r-- | src/core/configure.json | 15 | ||||
-rw-r--r-- | src/core/core_chromium.pri | 10 | ||||
-rw-r--r-- | src/core/delegated_frame_node.cpp | 12 | ||||
-rw-r--r-- | src/core/delegated_frame_node.h | 2 | ||||
-rw-r--r-- | src/core/gl_context_qt.cpp | 28 | ||||
-rw-r--r-- | src/core/gl_surface_qt.cpp | 120 | ||||
-rw-r--r-- | src/core/ozone/gl_ozone_egl_qt.cpp | 45 | ||||
-rw-r--r-- | src/core/ozone/gl_ozone_egl_qt.h | 20 | ||||
-rw-r--r-- | src/core/ozone/gl_ozone_glx_qt.cpp | 143 | ||||
-rw-r--r-- | src/core/ozone/gl_ozone_glx_qt.h | 85 | ||||
-rw-r--r-- | src/core/ozone/gl_surface_glx_qt.cpp | 5 | ||||
-rw-r--r-- | src/core/ozone/ozone_platform_qt.cpp | 1 | ||||
-rw-r--r-- | src/core/ozone/surface_factory_qt.cpp | 37 | ||||
-rw-r--r-- | src/core/ozone/surface_factory_qt.h | 4 | ||||
-rw-r--r-- | src/core/render_widget_host_view_qt.cpp | 4 | ||||
-rw-r--r-- | src/core/web_engine_context.cpp | 11 |
21 files changed, 381 insertions, 233 deletions
diff --git a/mkspecs/features/functions.prf b/mkspecs/features/functions.prf index 8564bad8a..ac84ad321 100644 --- a/mkspecs/features/functions.prf +++ b/mkspecs/features/functions.prf @@ -77,10 +77,7 @@ defineReplace(gnPath) { } defineReplace(gnArgs) { - linux { - qtConfig(webengine-embedded-build): include($$QTWEBENGINE_ROOT/src/core/config/embedded_linux.pri) - else: include($$QTWEBENGINE_ROOT/src/core/config/desktop_linux.pri) - } + linux: include($$QTWEBENGINE_ROOT/src/core/config/linux.pri) macos: include($$QTWEBENGINE_ROOT/src/core/config/mac_osx.pri) win32: include($$QTWEBENGINE_ROOT/src/core/config/windows.pri) isEmpty(gn_args): error(No gn_args found please make sure you have valid configuration.) diff --git a/src/core/chromium_overrides.cpp b/src/core/chromium_overrides.cpp index cb5674c37..3aa554eb6 100644 --- a/src/core/chromium_overrides.cpp +++ b/src/core/chromium_overrides.cpp @@ -59,10 +59,6 @@ #include <QFontDatabase> #include <QStringList> -#if defined(USE_X11) -#include "ui/gfx/x/x11_types.h" -#endif - #if defined(USE_AURA) && !defined(USE_OZONE) #include "ui/base/dragdrop/os_exchange_data.h" #include "ui/base/dragdrop/os_exchange_data_provider_aura.h" @@ -95,27 +91,6 @@ void GetScreenInfoFromNativeWindow(QWindow* window, content::ScreenInfo* results } // namespace QtWebEngineCore -#if defined(USE_X11) -XDisplay* GetQtXDisplay() -{ - return static_cast<XDisplay*>(GLContextHelper::getXDisplay()); -} - -namespace ui { -class DummyPlatformEventSource : public PlatformEventSource -{ -public: - DummyPlatformEventSource() { - DeviceDataManager::CreateInstance(); - } -}; - -std::unique_ptr<PlatformEventSource> PlatformEventSource::CreateDefault() { - return std::make_unique<DummyPlatformEventSource>(); -} -} // namespace ui -#endif // defined(USE_X11) - namespace content { class WebContentsImpl; class WebContentsView; diff --git a/src/core/config/desktop_linux.pri b/src/core/config/desktop_linux.pri deleted file mode 100644 index 70f1cf81e..000000000 --- a/src/core/config/desktop_linux.pri +++ /dev/null @@ -1,8 +0,0 @@ -include(linux.pri) - -gn_args += \ - use_sysroot=false \ - enable_session_service=false \ - toolkit_views=false - -!use_gold_linker: gn_args += use_gold=false diff --git a/src/core/config/embedded_linux.pri b/src/core/config/embedded_linux.pri deleted file mode 100644 index 8d9f09deb..000000000 --- a/src/core/config/embedded_linux.pri +++ /dev/null @@ -1,13 +0,0 @@ -include(linux.pri) - -gn_args += \ - is_desktop_linux=false \ - use_gold=false \ - use_ozone=true \ - use_sysroot=false \ - enable_session_service=false \ - ozone_auto_platforms=false \ - ozone_platform_headless=true \ - ozone_platform_external=true \ - ozone_platform=\"qt\" \ - toolkit_views=false diff --git a/src/core/config/linux.pri b/src/core/config/linux.pri index 7299819a6..f06679a3b 100644 --- a/src/core/config/linux.pri +++ b/src/core/config/linux.pri @@ -8,7 +8,26 @@ gn_args += \ use_kerberos=false \ linux_use_bundled_binutils=false \ use_udev=true \ - use_bundled_fontconfig=false + use_bundled_fontconfig=false \ + use_sysroot=false \ + enable_session_service=false \ + toolkit_views=false \ + use_ozone=true \ + ozone_auto_platforms=false \ + ozone_platform_headless=true \ + ozone_platform_external=true \ + ozone_platform=\"qt\" + +qtConfig(webengine-embedded-build) { + gn_args += is_desktop_linux=false + gn_args += use_gold=false +} else { + !use_gold_linker: gn_args += use_gold=false +} + +qtConfig(webengine-system-x11) { + gn_args += ozone_platform_x11=true +} clang { clang_full_path = $$which($${QMAKE_CXX}) diff --git a/src/core/configure.json b/src/core/configure.json index 51dd561e4..789da3351 100644 --- a/src/core/configure.json +++ b/src/core/configure.json @@ -208,9 +208,14 @@ "sources": [ { "type": "pkgConfig", "args": "freetype2 >= 2.4.2" } ] + }, + "webengine-x11" : { + "label" : "x11", + "sources": [ + { "type": "pkgConfig", "args": "x11" } + ] } }, - "tests" : { "webengine-alsa": { "label": "alsa", @@ -604,6 +609,11 @@ "condition": "config.unix && features.system-freetype && libs.webengine-freetype", "output": [ "privateFeature" ] }, + "webengine-system-x11" : { + "label": "x11", + "condition": "config.unix && libs.webengine-x11", + "output": [ "privateFeature" ] + }, "webengine-sanitizer" : { "label": "Sanitizer", "autoDetect": "config.sanitizer && tests.webengine-sanitizer", @@ -732,7 +742,8 @@ "webengine-system-png", "webengine-system-jpeg", "webengine-system-harfbuzz", - "webengine-system-freetype" + "webengine-system-freetype", + "webengine-system-x11" ] }, { diff --git a/src/core/core_chromium.pri b/src/core/core_chromium.pri index 7ed489f14..a2c22c5d2 100644 --- a/src/core/core_chromium.pri +++ b/src/core/core_chromium.pri @@ -84,7 +84,6 @@ SOURCES = \ net/webui_controller_factory_qt.cpp \ ozone/gl_ozone_egl_qt.cpp \ ozone/gl_surface_egl_qt.cpp \ - ozone/gl_surface_glx_qt.cpp \ ozone/gl_surface_wgl_qt.cpp \ ozone/ozone_platform_qt.cpp \ ozone/platform_window_qt.cpp \ @@ -174,7 +173,6 @@ HEADERS = \ net/webui_controller_factory_qt.h \ ozone/gl_ozone_egl_qt.h \ ozone/gl_surface_egl_qt.h \ - ozone/gl_surface_glx_qt.h \ ozone/gl_surface_wgl_qt.h \ ozone/ozone_platform_qt.h \ ozone/platform_window_qt.h \ @@ -219,6 +217,14 @@ HEADERS = \ web_engine_settings.h \ web_event_factory.h + +qtConfig(webengine-system-x11) { + HEADERS += ozone/gl_ozone_glx_qt.h \ + ozone/gl_surface_glx_qt.h + SOURCES += ozone/gl_surface_glx_qt.cpp \ + ozone/gl_ozone_glx_qt.cpp +} + qtConfig(webengine-pepper-plugins) { SOURCES += \ diff --git a/src/core/delegated_frame_node.cpp b/src/core/delegated_frame_node.cpp index 5b0983924..5257602cf 100644 --- a/src/core/delegated_frame_node.cpp +++ b/src/core/delegated_frame_node.cpp @@ -140,7 +140,7 @@ private: QSize m_textureSize; bool m_hasAlpha; GLenum m_target; -#if defined(USE_X11) +#if defined(USE_OZONE) bool m_ownsTexture; #endif #ifdef Q_OS_QNX @@ -571,7 +571,7 @@ MailboxTexture::MailboxTexture(const gpu::MailboxHolder &mailboxHolder, const QS , m_textureSize(textureSize) , m_hasAlpha(false) , m_target(GL_TEXTURE_2D) -#if defined(USE_X11) +#if defined(USE_OZONE) , m_ownsTexture(false) #endif { @@ -586,7 +586,7 @@ MailboxTexture::MailboxTexture(const gpu::MailboxHolder &mailboxHolder, const QS MailboxTexture::~MailboxTexture() { -#if defined(USE_X11) +#if defined(USE_OZONE) // This is rare case, where context is not shared // we created extra texture in current context, so // delete it now @@ -708,12 +708,12 @@ RectClipNode::RectClipNode(const QRectF &rect) DelegatedFrameNode::DelegatedFrameNode() : m_numPendingSyncPoints(0) -#if defined(USE_X11) && !defined(QT_NO_OPENGL) +#if defined(USE_OZONE) && !defined(QT_NO_OPENGL) , m_contextShared(true) #endif { setFlag(UsePreprocess); -#if defined(USE_X11) && !defined(QT_NO_OPENGL) +#if defined(USE_OZONE) && !defined(QT_NO_OPENGL) QOpenGLContext *currentContext = QOpenGLContext::currentContext() ; QOpenGLContext *sharedContext = qt_gl_global_share_context(); if (currentContext && sharedContext && !QOpenGLContext::areSharing(currentContext, sharedContext)) { @@ -1294,7 +1294,7 @@ void DelegatedFrameNode::fetchAndSyncMailboxes(QList<MailboxTexture *> &mailboxe deleteChromiumSync(&sync); } -#if defined(USE_X11) +#if defined(USE_OZONE) // Workaround when context is not shared QTBUG-48969 // Make slow copy between two contexts. if (!m_contextShared) { diff --git a/src/core/delegated_frame_node.h b/src/core/delegated_frame_node.h index 5d967841d..e37ad08a3 100644 --- a/src/core/delegated_frame_node.h +++ b/src/core/delegated_frame_node.h @@ -143,7 +143,7 @@ private: QWaitCondition m_mailboxesFetchedWaitCond; QMutex m_mutex; QList<gl::TransferableFence> m_textureFences; -#if defined(USE_X11) +#if defined(USE_OZONE) bool m_contextShared; QScopedPointer<QOffscreenSurface> m_offsurface; #endif diff --git a/src/core/gl_context_qt.cpp b/src/core/gl_context_qt.cpp index 954917094..ad78b7d2b 100644 --- a/src/core/gl_context_qt.cpp +++ b/src/core/gl_context_qt.cpp @@ -46,10 +46,6 @@ #include "ui/gl/gl_context_egl.h" #include "ui/gl/gl_implementation.h" -#if defined(USE_X11) -#include <X11/Xlib.h> -#endif - #if defined(OS_WIN) #include "ui/gl/gl_context_wgl.h" #endif @@ -128,15 +124,8 @@ void* GLContextHelper::getEGLDisplay() void* GLContextHelper::getXDisplay() { - void *display = qApp->platformNativeInterface()->nativeResourceForScreen(QByteArrayLiteral("display"), qApp->primaryScreen()); -#if defined(USE_X11) - if (!display) { - // XLib isn't available or has not been initialized, which is a decision we wish to - // support, for example for the GPU process. - display = XOpenDisplay(NULL); - } -#endif - return display; + return qApp->platformNativeInterface()->nativeResourceForScreen( + QByteArrayLiteral("display"), qApp->primaryScreen()); } void* GLContextHelper::getNativeDisplay() @@ -168,17 +157,14 @@ QFunctionPointer GLContextHelper::getEglGetProcAddress() QT_END_NAMESPACE -#if defined(USE_OZONE) || defined(OS_WIN) - +#if defined(OS_WIN) namespace gl { - namespace init { scoped_refptr<GLContext> CreateGLContext(GLShareGroup* share_group, GLSurface* compatible_surface, const GLContextAttribs& attribs) { -#if defined(OS_WIN) scoped_refptr<GLContext> context; if (GetGLImplementation() == kGLImplementationDesktopGL) { context = new GLContextWGL(share_group); @@ -188,18 +174,14 @@ scoped_refptr<GLContext> CreateGLContext(GLShareGroup* share_group, } else { context = new GLContextEGL(share_group); } -#else - scoped_refptr<GLContext> context = new GLContextEGL(share_group); -#endif if (!GLContextHelper::initializeContext(context.get(), compatible_surface, attribs)) - return NULL; + return nullptr; return context; } } // namespace init - } // namespace gl -#endif // defined(USE_OZONE) || defined(OS_WIN) +#endif // defined(OS_WIN) diff --git a/src/core/gl_surface_qt.cpp b/src/core/gl_surface_qt.cpp index 4d38d7c25..7cde289ae 100644 --- a/src/core/gl_surface_qt.cpp +++ b/src/core/gl_surface_qt.cpp @@ -68,13 +68,6 @@ #include "ui/gl/vsync_provider_win.h" #endif -#if defined(USE_X11) -#include "ozone/gl_surface_glx_qt.h" -#include "ui/gl/gl_glx_api_implementation.h" -#include <dlfcn.h> - -#endif - #include "ozone/gl_surface_egl_qt.h" #include "ui/gl/gl_egl_api_implementation.h" @@ -142,13 +135,11 @@ void* GLSurfaceQt::GetConfig() return g_config; } +#if defined(OS_WIN) namespace init { - bool InitializeGLOneOffPlatform() { -#if defined(OS_WIN) VSyncProviderWin::InitializeOneOff(); -#endif if (GetGLImplementation() == kGLImplementationOSMesaGL) return false; @@ -157,12 +148,8 @@ bool InitializeGLOneOffPlatform() return GLSurfaceEGLQt::InitializeOneOff(); if (GetGLImplementation() == kGLImplementationDesktopGL) { -#if defined(OS_WIN) return GLSurfaceWGLQt::InitializeOneOff(); -#elif defined(USE_X11) - if (GLSurfaceGLXQt::InitializeOneOff()) - return true; -#endif + // Fallback to trying EGL with desktop GL. if (GLSurfaceEGLQt::InitializeOneOff()) { g_initializedEGL = true; @@ -173,87 +160,6 @@ bool InitializeGLOneOffPlatform() return false; } -#if defined(USE_X11) -// FIXME: This should be removed when we switch to OZONE only -bool InitializeStaticGLBindings(GLImplementation implementation) { - // Prevent reinitialization with a different implementation. Once the gpu - // unit tests have initialized with kGLImplementationMock, we don't want to - // later switch to another GL implementation. - DCHECK_EQ(kGLImplementationNone, GetGLImplementation()); - base::ThreadRestrictions::ScopedAllowIO allow_io; - - switch (implementation) { - case kGLImplementationOSMesaGL: - return false; - case kGLImplementationDesktopGL: { - base::NativeLibrary library = dlopen(NULL, RTLD_LAZY); - if (!library) { - LOG(ERROR) << "Failed to obtain glx handle" << dlerror(); - return false; - } - - GLGetProcAddressProc get_proc_address = - reinterpret_cast<GLGetProcAddressProc>( - base::GetFunctionPointerFromNativeLibrary(library, - "glXGetProcAddress")); - if (!get_proc_address) { - QFunctionPointer address = GLContextHelper::getGlXGetProcAddress(); - get_proc_address = reinterpret_cast<gl::GLGetProcAddressProc>(address); - } - if (!get_proc_address) { - LOG(ERROR) << "glxGetProcAddress not found."; - base::UnloadNativeLibrary(library); - return false; - } - - SetGLGetProcAddressProc(get_proc_address); - AddGLNativeLibrary(library); - SetGLImplementation(kGLImplementationDesktopGL); - - InitializeStaticGLBindingsGL(); - InitializeStaticGLBindingsGLX(); - return true; - } - case kGLImplementationSwiftShaderGL: - case kGLImplementationEGLGLES2: { - base::NativeLibrary library = dlopen(NULL, RTLD_LAZY); - if (!library) { - LOG(ERROR) << "Failed to obtain egl handle" << dlerror(); - return false; - } - - GLGetProcAddressProc get_proc_address = - reinterpret_cast<GLGetProcAddressProc>( - base::GetFunctionPointerFromNativeLibrary(library, - "eglGetProcAddress")); - if (!get_proc_address) { - QFunctionPointer address = GLContextHelper::getEglGetProcAddress(); - get_proc_address = reinterpret_cast<gl::GLGetProcAddressProc>(address); - } - if (!get_proc_address) { - LOG(ERROR) << "eglGetProcAddress not found."; - base::UnloadNativeLibrary(library); - return false; - } - - SetGLGetProcAddressProc(get_proc_address); - AddGLNativeLibrary(library); - SetGLImplementation(kGLImplementationEGLGLES2); - - InitializeStaticGLBindingsGL(); - InitializeStaticGLBindingsEGL(); - return true; - } - case kGLImplementationMockGL: - case kGLImplementationStubGL: - return false; - default: - NOTREACHED(); - } - return false; -} -#endif - bool usingSoftwareDynamicGL() { return QtWebEngineCore::usingSoftwareDynamicGL(); @@ -266,19 +172,10 @@ CreateOffscreenGLSurfaceWithFormat(const gfx::Size& size, GLSurfaceFormat format switch (GetGLImplementation()) { case kGLImplementationDesktopGLCoreProfile: case kGLImplementationDesktopGL: { -#if defined(OS_WIN) surface = new GLSurfaceWGLQt(size); if (surface->Initialize(format)) return surface; break; -#elif defined(USE_X11) - if (!g_initializedEGL) { - surface = new GLSurfaceGLXQt(size); - if (surface->Initialize(format)) - return surface; - } - Q_FALLTHROUGH(); -#endif } case kGLImplementationEGLGLES2: { surface = new GLSurfaceEGLQt(size); @@ -313,8 +210,10 @@ CreateViewGLSurface(gfx::AcceleratedWidget window) } } // namespace init -} // namespace gl +#endif // defined(OS_WIN) +} // namespace gl +#if defined(OS_WIN) namespace gpu { class GpuCommandBufferStub; class GpuChannelManager; @@ -325,11 +224,10 @@ scoped_refptr<gl::GLSurface> ImageTransportSurface::CreateNativeSurface(base::We return scoped_refptr<gl::GLSurface>(); } -#if defined(OS_WIN) bool DirectCompositionSurfaceWin::IsHDRSupported() -{ return false; } -#endif - +{ + return false; +} } // namespace gpu - +#endif #endif // !defined(OS_MACOSX) diff --git a/src/core/ozone/gl_ozone_egl_qt.cpp b/src/core/ozone/gl_ozone_egl_qt.cpp index a9b3da5e2..bc7b2b756 100644 --- a/src/core/ozone/gl_ozone_egl_qt.cpp +++ b/src/core/ozone/gl_ozone_egl_qt.cpp @@ -38,11 +38,13 @@ ****************************************************************************/ #if defined(USE_OZONE) - +#include "gl_ozone_egl_qt.h" +#include "gl_context_qt.h" +#include "gl_surface_egl_qt.h" #include "base/files/file_path.h" #include "base/native_library.h" #include "gl_context_qt.h" -#include "ozone/gl_ozone_egl_qt.h" +#include "gl_ozone_egl_qt.h" #include "ui/gl/gl_context_egl.h" #include "ui/gl/gl_implementation.h" #include "ui/gl/gl_surface.h" @@ -55,10 +57,12 @@ #ifndef QT_NO_OPENGL #include <QOpenGLContext> +QT_BEGIN_NAMESPACE Q_GUI_EXPORT QOpenGLContext *qt_gl_global_share_context(); +QT_END_NAMESPACE #endif -namespace QtWebEngineCore { +namespace ui { base::NativeLibrary LoadLibrary(const base::FilePath& filename) { base::NativeLibraryLoadError error; @@ -103,6 +107,39 @@ bool GLOzoneEGLQt::LoadGLES2Bindings(gl::GLImplementation /*implementation*/) return true; } +bool GLOzoneEGLQt::InitializeGLOneOffPlatform() +{ + if (!gl::GLSurfaceEGLQt::InitializeOneOff()) { + LOG(ERROR) << "GLOzoneEGLQt::InitializeOneOff failed."; + return false; + } + return true; +} + +bool GLOzoneEGLQt::InitializeExtensionSettingsOneOffPlatform() +{ + return gl::GLSurfaceEGLQt::InitializeExtensionSettingsOneOff(); +} + +scoped_refptr<gl::GLSurface> GLOzoneEGLQt::CreateViewGLSurface(gfx::AcceleratedWidget window) +{ + return nullptr; +} + +scoped_refptr<gl::GLSurface> GLOzoneEGLQt::CreateOffscreenGLSurface(const gfx::Size &size) +{ + scoped_refptr<gl::GLSurface> surface = new gl::GLSurfaceEGLQt(size); + if (surface->Initialize(gl::GLSurfaceFormat())) + return surface; + + surface = new gl::GLSurfacelessQtEGL(size); + if (surface->Initialize(gl::GLSurfaceFormat())) + return surface; + + LOG(WARNING) << "Failed to create offscreen GL surface"; + return nullptr; +} + intptr_t GLOzoneEGLQt::GetNativeDisplay() { static void *display = GLContextHelper::getNativeDisplay(); @@ -113,6 +150,6 @@ intptr_t GLOzoneEGLQt::GetNativeDisplay() return reinterpret_cast<intptr_t>(EGL_DEFAULT_DISPLAY); } -} // namespace QtWebEngineCore +} // namespace ui #endif // defined(USE_OZONE) diff --git a/src/core/ozone/gl_ozone_egl_qt.h b/src/core/ozone/gl_ozone_egl_qt.h index fc609c51c..c24d03a81 100644 --- a/src/core/ozone/gl_ozone_egl_qt.h +++ b/src/core/ozone/gl_ozone_egl_qt.h @@ -44,18 +44,16 @@ #include "ui/ozone/common/gl_ozone_egl.h" -namespace QtWebEngineCore { +namespace ui { -class GLOzoneEGLQt : public ui::GLOzoneEGL { +class GLOzoneEGLQt : public GLOzoneEGL { public: - scoped_refptr<gl::GLSurface> CreateViewGLSurface(gfx::AcceleratedWidget /*window*/) override - { - return nullptr; - } - scoped_refptr<gl::GLSurface> CreateOffscreenGLSurface(const gfx::Size& /*size*/) override - { - return nullptr; - } + bool InitializeGLOneOffPlatform() override; + bool InitializeExtensionSettingsOneOffPlatform() override; + scoped_refptr<gl::GLSurface> CreateViewGLSurface( + gfx::AcceleratedWidget window) override; + scoped_refptr<gl::GLSurface> CreateOffscreenGLSurface( + const gfx::Size& size) override; protected: // Returns native platform display handle. This is used to obtain the EGL @@ -66,7 +64,7 @@ protected: bool LoadGLES2Bindings(gl::GLImplementation implementation) override; }; -} // namespace QtWebEngineCore +} // namespace ui #endif // defined(USE_OZONE) diff --git a/src/core/ozone/gl_ozone_glx_qt.cpp b/src/core/ozone/gl_ozone_glx_qt.cpp new file mode 100644 index 000000000..9a0fea7c7 --- /dev/null +++ b/src/core/ozone/gl_ozone_glx_qt.cpp @@ -0,0 +1,143 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtWebEngine module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// Copyright 2016 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + + +#include "gl_ozone_glx_qt.h" +#include "gl_surface_glx_qt.h" +#include "ui/gl/gl_context_glx.h" +#include "ui/gl/gl_gl_api_implementation.h" +#include "ui/gl/gl_glx_api_implementation.h" +#include <dlfcn.h> + +namespace ui { + +bool GLOzoneGLXQt::InitializeGLOneOffPlatform() { + if (!gl::GLSurfaceGLXQt::InitializeOneOff()) { + LOG(ERROR) << "GLSurfaceGLXQt::InitializeOneOff failed."; + return false; + } + return true; +} + +bool GLOzoneGLXQt::InitializeStaticGLBindings( + gl::GLImplementation implementation) { + + base::NativeLibrary library = dlopen(NULL, RTLD_LAZY); + if (!library) { + LOG(ERROR) << "Failed to open GL context " << dlerror(); + return false; + } + + gl::GLGetProcAddressProc get_proc_address = + reinterpret_cast<gl::GLGetProcAddressProc>( + base::GetFunctionPointerFromNativeLibrary(library, + "glXGetProcAddress")); + if (!get_proc_address) { + LOG(ERROR) << "glxGetProcAddress not found."; + base::UnloadNativeLibrary(library); + return false; + } + + gl::SetGLGetProcAddressProc(get_proc_address); + gl::AddGLNativeLibrary(library); + gl::SetGLImplementation(gl::kGLImplementationDesktopGL); + + gl::InitializeStaticGLBindingsGL(); + gl::InitializeStaticGLBindingsGLX(); + + return true; +} + +void GLOzoneGLXQt::InitializeDebugGLBindings() { + gl::InitializeDebugGLBindingsGL(); + gl::InitializeDebugGLBindingsGLX(); +} + +void GLOzoneGLXQt::SetDisabledExtensionsPlatform( + const std::string& disabled_extensions) { + gl::SetDisabledExtensionsGLX(disabled_extensions); +} + +void GLOzoneGLXQt::ShutdownGL() { + gl::ClearBindingsGL(); + gl::ClearBindingsGLX(); +} + +bool GLOzoneGLXQt::GetGLWindowSystemBindingInfo( + gl::GLWindowSystemBindingInfo* info) { + return gl::GetGLWindowSystemBindingInfoGLX(info); +} + +scoped_refptr<gl::GLContext> GLOzoneGLXQt::CreateGLContext( + gl::GLShareGroup* share_group, + gl::GLSurface* compatible_surface, + const gl::GLContextAttribs& attribs) { + return gl::InitializeGLContext(new gl::GLContextGLX(share_group), + compatible_surface, attribs); +} + +scoped_refptr<gl::GLSurface> GLOzoneGLXQt::CreateViewGLSurface( + gfx::AcceleratedWidget window) { + return nullptr; +} + +scoped_refptr<gl::GLSurface> GLOzoneGLXQt::CreateSurfacelessViewGLSurface( + gfx::AcceleratedWidget window) { + return nullptr; +} + +scoped_refptr<gl::GLSurface> GLOzoneGLXQt::CreateOffscreenGLSurface( + const gfx::Size& size) { + scoped_refptr<gl::GLSurface> surface = new gl::GLSurfaceGLXQt(size); + if (surface->Initialize(gl::GLSurfaceFormat())) + return surface; + LOG(WARNING) << "Failed to create offscreen GL surface"; + return nullptr; +} + +bool GLOzoneGLXQt::InitializeExtensionSettingsOneOffPlatform() +{ + return gl::GLSurfaceGLXQt::InitializeExtensionSettingsOneOff(); +} + +} // namespace ui diff --git a/src/core/ozone/gl_ozone_glx_qt.h b/src/core/ozone/gl_ozone_glx_qt.h new file mode 100644 index 000000000..ffbd60454 --- /dev/null +++ b/src/core/ozone/gl_ozone_glx_qt.h @@ -0,0 +1,85 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtWebEngine module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef UI_OZONE_GLX_QT_H_ +#define UI_OZONE_GLX_QT_H + +#include "base/macros.h" +#include "ui/gl/gl_implementation.h" +#include "ui/ozone/public/gl_ozone.h" + +namespace ui { + +class GLOzoneGLXQt : public GLOzone { + +public: + GLOzoneGLXQt() {} + ~GLOzoneGLXQt() override {} + + bool InitializeGLOneOffPlatform() override; + bool InitializeStaticGLBindings(gl::GLImplementation implementation) override; + void InitializeDebugGLBindings() override; + bool InitializeExtensionSettingsOneOffPlatform() override; + void ShutdownGL() override; + void SetDisabledExtensionsPlatform( + const std::string& disabled_extensions) override; + bool GetGLWindowSystemBindingInfo( + gl::GLWindowSystemBindingInfo* info) override; + + scoped_refptr<gl::GLContext> CreateGLContext( + gl::GLShareGroup* share_group, + gl::GLSurface* compatible_surface, + const gl::GLContextAttribs& attribs) override; + + scoped_refptr<gl::GLSurface> CreateViewGLSurface( + gfx::AcceleratedWidget window) override; + + scoped_refptr<gl::GLSurface> CreateSurfacelessViewGLSurface( + gfx::AcceleratedWidget window) override; + + scoped_refptr<gl::GLSurface> CreateOffscreenGLSurface( + const gfx::Size& size) override; + +private: + DISALLOW_COPY_AND_ASSIGN(GLOzoneGLXQt); +}; + +} // namespace ui + +#endif // UI_OZONE_GLX_QT_H diff --git a/src/core/ozone/gl_surface_glx_qt.cpp b/src/core/ozone/gl_surface_glx_qt.cpp index 51b0f58b0..32b85ff77 100644 --- a/src/core/ozone/gl_surface_glx_qt.cpp +++ b/src/core/ozone/gl_surface_glx_qt.cpp @@ -41,8 +41,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#if defined(USE_X11) - #include "gl_context_qt.h" #include "ozone/gl_surface_glx_qt.h" #include "ui/gl/gl_bindings.h" @@ -156,7 +154,7 @@ bool GLSurfaceGLXQt::InitializeExtensionSettingsOneOff() Display* display = static_cast<Display*>(g_display); GLSurfaceQt::g_extensions = glXQueryExtensionsString(display, 0); - g_driver_glx.InitializeExtensionBindings(); + g_driver_glx.InitializeExtensionBindings(g_extensions); return true; } @@ -210,4 +208,3 @@ void* GLSurfaceGLXQt::GetHandle() } //namespace gl -#endif // defined(USE_X11) diff --git a/src/core/ozone/ozone_platform_qt.cpp b/src/core/ozone/ozone_platform_qt.cpp index 8bb5007ef..a13f33301 100644 --- a/src/core/ozone/ozone_platform_qt.cpp +++ b/src/core/ozone/ozone_platform_qt.cpp @@ -145,7 +145,6 @@ void OzonePlatformQt::InitializeGPU(const ui::OzonePlatform::InitParams &) } // namespace - OzonePlatform* CreateOzonePlatformQt() { return new OzonePlatformQt; } gfx::ClientNativePixmapFactory* CreateClientNativePixmapFactoryQt() diff --git a/src/core/ozone/surface_factory_qt.cpp b/src/core/ozone/surface_factory_qt.cpp index f21e14c30..d2b2aab8a 100644 --- a/src/core/ozone/surface_factory_qt.cpp +++ b/src/core/ozone/surface_factory_qt.cpp @@ -37,6 +37,17 @@ ** ****************************************************************************/ +#include "surface_factory_qt.h" +#include "qtwebenginecoreglobal_p.h" +#include "gl_ozone_egl_qt.h" + +#if QT_CONFIG(webengine_system_x11) +#include "gl_ozone_glx_qt.h" +#endif + +#include "ui/gl/gl_surface.h" +#include <QGuiApplication> + #if defined(USE_OZONE) #include "ozone/gl_ozone_egl_qt.h" @@ -44,16 +55,34 @@ #include "ui/gl/gl_surface.h" namespace QtWebEngineCore { +SurfaceFactoryQt::SurfaceFactoryQt() +{ + // Fixme: make better platform switch handling + QString platform = qApp->platformName(); + if (platform == QLatin1String("xcb")) { + m_impls.push_back(gl::kGLImplementationDesktopGL); + } else { + m_impls.push_back(gl::kGLImplementationEGLGLES2); + } +} + std::vector<gl::GLImplementation> SurfaceFactoryQt::GetAllowedGLImplementations() { - std::vector<gl::GLImplementation> impls; - impls.push_back(gl::kGLImplementationEGLGLES2); - return impls; + return m_impls; } ui::GLOzone* SurfaceFactoryQt::GetGLOzone(gl::GLImplementation implementation) { - return new GLOzoneEGLQt(); + + QString platform = qApp->platformName(); + if (platform == QLatin1String("xcb")) { +#if QT_CONFIG(webengine_system_x11) + return new ui::GLOzoneGLXQt(); +#endif + return nullptr; + } else { + return new ui::GLOzoneEGLQt(); + } } } // namespace QtWebEngineCore diff --git a/src/core/ozone/surface_factory_qt.h b/src/core/ozone/surface_factory_qt.h index b7991829c..0ac2eca68 100644 --- a/src/core/ozone/surface_factory_qt.h +++ b/src/core/ozone/surface_factory_qt.h @@ -48,8 +48,12 @@ namespace QtWebEngineCore { class SurfaceFactoryQt : public ui::SurfaceFactoryOzone { +public: + SurfaceFactoryQt(); std::vector<gl::GLImplementation> GetAllowedGLImplementations() override; ui::GLOzone* GetGLOzone(gl::GLImplementation implementation) override; +private: + std::vector<gl::GLImplementation> m_impls; }; } // namespace QtWebEngineCore diff --git a/src/core/render_widget_host_view_qt.cpp b/src/core/render_widget_host_view_qt.cpp index b1f7a41dc..3e5d9bc4b 100644 --- a/src/core/render_widget_host_view_qt.cpp +++ b/src/core/render_widget_host_view_qt.cpp @@ -887,13 +887,13 @@ void RenderWidgetHostViewQt::OnTextSelectionChanged(content::TextInputManager *t if (!selection) return; -#if defined(USE_X11) +#if defined(USE_OZONE) if (!selection->selected_text().empty() && selection->user_initiated()) { // Set the CLIPBOARD_TYPE_SELECTION to the ui::Clipboard. ui::ScopedClipboardWriter clipboard_writer(ui::CLIPBOARD_TYPE_SELECTION); clipboard_writer.WriteText(selection->selected_text()); } -#endif // defined(USE_X11) +#endif // defined(USE_OZONE) m_imState |= ImStateFlags::TextSelectionUpdated; if (m_imState == ImStateFlags::AllFlags diff --git a/src/core/web_engine_context.cpp b/src/core/web_engine_context.cpp index 4eb689d93..33a5a5e0d 100644 --- a/src/core/web_engine_context.cpp +++ b/src/core/web_engine_context.cpp @@ -316,14 +316,6 @@ WebEngineContext::WebEngineContext() , m_browserRunner(content::BrowserMainRunner::Create()) , m_globalQObject(new QObject()) { -#if defined(USE_X11) - QString platform = qApp->platformName(); - if (platform != QLatin1String("xcb")) { - qWarning("WebEngine compiled with X11 support, however qpa backend is not xcb. " - "This may fail."); - } -#endif - #ifdef Q_OS_LINUX // Call qputenv before BrowserMainRunnerImpl::Initialize is called. // http://crbug.com/245466 @@ -453,9 +445,6 @@ WebEngineContext::WebEngineContext() // 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 (qt_gl_global_share_context()->nativeHandle().isNull() -#ifdef USE_OZONE - || true -#endif || !strcmp(qt_gl_global_share_context()->nativeHandle().typeName(), "QEGLNativeContext")) { if (qt_gl_global_share_context()->isOpenGLES()) { |