0002-Load-libEGL-and-libGLES2-symbols-implicitly.patch 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. From bdfd084296681bcead17c42f1e5cf0e24ee04f65 Mon Sep 17 00:00:00 2001
  2. From: Viktor Engelmann <viktor.engelmann@qt.io>
  3. Date: Fri, 7 Jul 2017 12:56:19 +0200
  4. Subject: [PATCH] Load libEGL and libGLES2 symbols implicitly
  5. MIME-Version: 1.0
  6. Content-Type: text/plain; charset=utf-8
  7. Content-Transfer-Encoding: 8bit
  8. Instead of explicitly loading libraries from hard-coded locations,
  9. we now just call dlopen(NULL, RTLD_LAZY). This returns a handle to
  10. the host process'es context, which already contains the symbols of
  11. both these libraries, because we link against them.
  12. It was necessary to bypass LoadLibrary, because that expects a non-NULL
  13. file path, so we couldn't pass NULL through that interface.
  14. Upstream-Status: Merged
  15. Task-number: QTBUG-57761
  16. Change-Id: I29f037dfe542222b5188a33c7727c81a464a87bb
  17. Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
  18. Reviewed-by: Michal Klocek <michal.klocek@qt.io>
  19. Signed-off-by: Gaël PORTAY <gael.portay@savoirfairelinux.com>
  20. [gportay: backport from 5.9 and merge conflicts]
  21. ---
  22. src/core/surface_factory_qt.cpp | 40 ++++++++--------------------------------
  23. 1 file changed, 8 insertions(+), 32 deletions(-)
  24. diff --git a/src/core/surface_factory_qt.cpp b/src/core/surface_factory_qt.cpp
  25. index 48c91bfc..c6059b67 100644
  26. --- a/src/core/surface_factory_qt.cpp
  27. +++ b/src/core/surface_factory_qt.cpp
  28. @@ -51,51 +51,27 @@
  29. #if defined(USE_OZONE)
  30. #include <EGL/egl.h>
  31. -
  32. -#ifndef QT_LIBDIR_EGL
  33. -#define QT_LIBDIR_EGL "/usr/lib"
  34. -#endif
  35. -#ifndef QT_LIBDIR_GLES2
  36. -#define QT_LIBDIR_GLES2 QT_LIBDIR_EGL
  37. -#endif
  38. +#include <dlfcn.h>
  39. namespace QtWebEngineCore {
  40. -base::NativeLibrary LoadLibrary(const base::FilePath& filename) {
  41. - base::NativeLibraryLoadError error;
  42. - base::NativeLibrary library = base::LoadNativeLibrary(filename, &error);
  43. - if (!library) {
  44. - LOG(ERROR) << "Failed to load " << filename.MaybeAsASCII() << ": " << error.ToString();
  45. - return NULL;
  46. - }
  47. - return library;
  48. -}
  49. -
  50. bool SurfaceFactoryQt::LoadEGLGLES2Bindings(AddGLLibraryCallback add_gl_library, SetGLGetProcAddressProcCallback set_gl_get_proc_address)
  51. {
  52. - base::FilePath libEGLPath = QtWebEngineCore::toFilePath(QT_LIBDIR_EGL);
  53. - libEGLPath = libEGLPath.Append("libEGL.so.1");
  54. - base::NativeLibrary eglLibrary = LoadLibrary(libEGLPath);
  55. - if (!eglLibrary)
  56. - return false;
  57. -
  58. - base::FilePath libGLES2Path = QtWebEngineCore::toFilePath(QT_LIBDIR_GLES2);
  59. - libGLES2Path = libGLES2Path.Append("libGLESv2.so.2");
  60. - base::NativeLibrary gles2Library = LoadLibrary(libGLES2Path);
  61. - if (!gles2Library)
  62. + base::NativeLibrary eglgles2Library = dlopen(NULL, RTLD_LAZY);
  63. + if (!eglgles2Library) {
  64. + LOG(ERROR) << "Failed to open EGL/GLES2 context " << dlerror();
  65. return false;
  66. + }
  67. - gfx::GLGetProcAddressProc get_proc_address = reinterpret_cast<gfx::GLGetProcAddressProc>(base::GetFunctionPointerFromNativeLibrary(eglLibrary, "eglGetProcAddress"));
  68. + gfx::GLGetProcAddressProc get_proc_address = reinterpret_cast<gfx::GLGetProcAddressProc>(base::GetFunctionPointerFromNativeLibrary(eglgles2Library, "eglGetProcAddress"));
  69. if (!get_proc_address) {
  70. LOG(ERROR) << "eglGetProcAddress not found.";
  71. - base::UnloadNativeLibrary(eglLibrary);
  72. - base::UnloadNativeLibrary(gles2Library);
  73. + base::UnloadNativeLibrary(eglgles2Library);
  74. return false;
  75. }
  76. gfx::SetGLGetProcAddressProc(get_proc_address);
  77. - gfx::AddGLNativeLibrary(eglLibrary);
  78. - gfx::AddGLNativeLibrary(gles2Library);
  79. + gfx::AddGLNativeLibrary(eglgles2Library);
  80. return true;
  81. }
  82. --
  83. 2.15.0