summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMichal Klocek <michal.klocek@qt.io>2017-10-26 12:46:58 +0200
committerMichal Klocek <michal.klocek@qt.io>2017-11-15 08:23:16 +0000
commite812237b6980584fc5939f49f6a18315cc694c3a (patch)
tree522ec15e1f1f374081ca0b72a74df92d7ce6574e /src
parent61eb7b4ff6e4f2de5b5df6d7a76191cbf8dd9312 (diff)
Restore loading libEGL and libGLES2 symbols implicitly
This recommits d4c621f6a6b87f2a86069fa393b9f7c4f9e7b9ad and fixes the issue that on some platforms "eglGetProcAddress" call was not resolved. On some platforms libGLESv2 does not link to libEGL and eglGetProcAddress is resolved in qpa plugin, therefore use it as fallback. Task-number: QTBUG-63341 Task-number: QTBUG-57761 Change-Id: I14f0853a1b92f8f2a9ae7e40f16ce80ab55db331 Reviewed-by: Viktor Engelmann <viktor.engelmann@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/core/surface_factory_qt.cpp50
1 files changed, 20 insertions, 30 deletions
diff --git a/src/core/surface_factory_qt.cpp b/src/core/surface_factory_qt.cpp
index 36c05ec5d..9b47d74a7 100644
--- a/src/core/surface_factory_qt.cpp
+++ b/src/core/surface_factory_qt.cpp
@@ -51,51 +51,41 @@
#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 {
-base::NativeLibrary LoadLibrary(const base::FilePath& filename) {
- base::NativeLibraryLoadError error;
- base::NativeLibrary library = base::LoadNativeLibrary(filename, &error);
- if (!library) {
- LOG(ERROR) << "Failed to load " << filename.MaybeAsASCII() << ": " << error.ToString();
- return NULL;
- }
- return library;
-}
-
bool SurfaceFactoryQt::LoadEGLGLES2Bindings()
{
- 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;
}