summaryrefslogtreecommitdiffstats
path: root/package/qt5/qt5webengine/5.6.3/0002-Load-libEGL-and-libGLES2-symbols-implicitly.patch
blob: 05ed2956d2922bb9355b7b55b5a1325298983857 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
From bdfd084296681bcead17c42f1e5cf0e24ee04f65 Mon Sep 17 00:00:00 2001
From: Viktor Engelmann <viktor.engelmann@qt.io>
Date: Fri, 7 Jul 2017 12:56:19 +0200
Subject: [PATCH] Load libEGL and libGLES2 symbols implicitly
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit

Instead of explicitly loading libraries from hard-coded locations,
we now just call dlopen(NULL, RTLD_LAZY). This returns a handle to
the host process'es context, which already contains the symbols of
both these libraries, because we link against them.
It was necessary to bypass LoadLibrary, because that expects a non-NULL
file path, so we couldn't pass NULL through that interface.

Upstream-Status: Merged
Task-number: QTBUG-57761
Change-Id: I29f037dfe542222b5188a33c7727c81a464a87bb
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Reviewed-by: Michal Klocek <michal.klocek@qt.io>
Signed-off-by: Gaël PORTAY <gael.portay@savoirfairelinux.com>
[gportay: backport from 5.9 and merge conflicts]
---
 src/core/surface_factory_qt.cpp | 40 ++++++++--------------------------------
 1 file changed, 8 insertions(+), 32 deletions(-)

diff --git a/src/core/surface_factory_qt.cpp b/src/core/surface_factory_qt.cpp
index 48c91bfc..c6059b67 100644
--- a/src/core/surface_factory_qt.cpp
+++ b/src/core/surface_factory_qt.cpp
@@ -51,51 +51,27 @@
 #if defined(USE_OZONE)
 
 #include <EGL/egl.h>
-
-#ifndef QT_LIBDIR_EGL
-#define QT_LIBDIR_EGL "/usr/lib"
-#endif
-#ifndef QT_LIBDIR_GLES2
-#define QT_LIBDIR_GLES2 QT_LIBDIR_EGL
-#endif
+#include <dlfcn.h>
 
 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(AddGLLibraryCallback add_gl_library, SetGLGetProcAddressProcCallback set_gl_get_proc_address)
 {
-    base::FilePath libEGLPath = QtWebEngineCore::toFilePath(QT_LIBDIR_EGL);
-    libEGLPath = libEGLPath.Append("libEGL.so.1");
-    base::NativeLibrary eglLibrary = LoadLibrary(libEGLPath);
-    if (!eglLibrary)
-        return false;
-
-    base::FilePath libGLES2Path = QtWebEngineCore::toFilePath(QT_LIBDIR_GLES2);
-    libGLES2Path = libGLES2Path.Append("libGLESv2.so.2");
-    base::NativeLibrary gles2Library = LoadLibrary(libGLES2Path);
-    if (!gles2Library)
+    base::NativeLibrary eglgles2Library = dlopen(NULL, RTLD_LAZY);
+    if (!eglgles2Library) {
+        LOG(ERROR) << "Failed to open EGL/GLES2 context " << dlerror();
         return false;
+    }
 
-    gfx::GLGetProcAddressProc get_proc_address = reinterpret_cast<gfx::GLGetProcAddressProc>(base::GetFunctionPointerFromNativeLibrary(eglLibrary, "eglGetProcAddress"));
+    gfx::GLGetProcAddressProc get_proc_address = reinterpret_cast<gfx::GLGetProcAddressProc>(base::GetFunctionPointerFromNativeLibrary(eglgles2Library, "eglGetProcAddress"));
     if (!get_proc_address) {
         LOG(ERROR) << "eglGetProcAddress not found.";
-        base::UnloadNativeLibrary(eglLibrary);
-        base::UnloadNativeLibrary(gles2Library);
+        base::UnloadNativeLibrary(eglgles2Library);
         return false;
     }
 
     gfx::SetGLGetProcAddressProc(get_proc_address);
-    gfx::AddGLNativeLibrary(eglLibrary);
-    gfx::AddGLNativeLibrary(gles2Library);
+    gfx::AddGLNativeLibrary(eglgles2Library);
     return true;
 }
 
-- 
2.15.0

OpenPOWER on IntegriCloud