diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2017-12-05 12:50:46 +0100 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2017-12-05 12:50:46 +0100 |
commit | 6921ebd6d8bc8bb62d9118c7a1a750f2fd787897 (patch) | |
tree | d465cc6e4984808c6146d6f4ff8b21cb9aef406d /src/core/surface_factory_qt.cpp | |
parent | 716d179927c001934b177a36fab5dc209ac6d5c9 (diff) | |
parent | f979b271e158bc93b7361d4b891ed49ee58ab865 (diff) |
Merge remote-tracking branch 'origin/5.9' into 5.10
Change-Id: Ia24d831c2d2b04d13cf6eef2883d2ab2e4cad642
Diffstat (limited to 'src/core/surface_factory_qt.cpp')
-rw-r--r-- | src/core/surface_factory_qt.cpp | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/src/core/surface_factory_qt.cpp b/src/core/surface_factory_qt.cpp index c976e8b04..8c0bd6c82 100644 --- a/src/core/surface_factory_qt.cpp +++ b/src/core/surface_factory_qt.cpp @@ -56,13 +56,10 @@ #if defined(USE_OZONE) #include <EGL/egl.h> +#include <QOpenGLContext> +#include <dlfcn.h> -#ifndef QT_LIBDIR_EGL -#define QT_LIBDIR_EGL "/usr/lib" -#endif -#ifndef QT_LIBDIR_GLES2 -#define QT_LIBDIR_GLES2 QT_LIBDIR_EGL -#endif +Q_GUI_EXPORT QOpenGLContext *qt_gl_global_share_context(); namespace QtWebEngineCore { @@ -98,29 +95,32 @@ base::NativeLibrary LoadLibrary(const base::FilePath& filename) { bool GLOzoneQt::LoadGLES2Bindings(gl::GLImplementation /*implementation*/) { - base::FilePath libEGLPath = QtWebEngineCore::toFilePath(QT_LIBDIR_EGL); - libEGLPath = libEGLPath.Append("libEGL.so.1"); - base::NativeLibrary eglLibrary = LoadLibrary(libEGLPath); - if (!eglLibrary) + base::NativeLibrary eglgles2Library = dlopen(NULL, RTLD_LAZY); + if (!eglgles2Library) { + LOG(ERROR) << "Failed to open EGL/GLES2 context " << dlerror(); return false; + } - base::FilePath libGLES2Path = QtWebEngineCore::toFilePath(QT_LIBDIR_GLES2); - libGLES2Path = libGLES2Path.Append("libGLESv2.so.2"); - base::NativeLibrary gles2Library = LoadLibrary(libGLES2Path); - if (!gles2Library) - return false; + gl::GLGetProcAddressProc get_proc_address = + reinterpret_cast<gl::GLGetProcAddressProc>( + base::GetFunctionPointerFromNativeLibrary(eglgles2Library, + "eglGetProcAddress")); + if (!get_proc_address) { + // QTBUG-63341 most likely libgles2 not linked with libegl -> fallback to qpa + if (QOpenGLContext *context = qt_gl_global_share_context()) { + get_proc_address = reinterpret_cast<gl::GLGetProcAddressProc>( + context->getProcAddress("eglGetProcAddress")); + } + } - gl::GLGetProcAddressProc get_proc_address = reinterpret_cast<gl::GLGetProcAddressProc>(base::GetFunctionPointerFromNativeLibrary(eglLibrary, "eglGetProcAddress")); if (!get_proc_address) { LOG(ERROR) << "eglGetProcAddress not found."; - base::UnloadNativeLibrary(eglLibrary); - base::UnloadNativeLibrary(gles2Library); + base::UnloadNativeLibrary(eglgles2Library); return false; } gl::SetGLGetProcAddressProc(get_proc_address); - gl::AddGLNativeLibrary(eglLibrary); - gl::AddGLNativeLibrary(gles2Library); + gl::AddGLNativeLibrary(eglgles2Library); return true; } |