2
1

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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. From d4c621f6a6b87f2a86069fa393b9f7c4f9e7b9ad 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. Instead of explicitly loading libraries from hard-coded locations,
  6. we now just call dlopen(NULL, RTLD_LAZY). This returns a handle to
  7. the host process'es context, which already contains the symbols of
  8. both these libraries, because we link against them.
  9. It was necessary to bypass LoadLibrary, because that expects a non-NULL
  10. file path, so we couldn't pass NULL through that interface.
  11. Task-number: QTBUG-57761
  12. Change-Id: I29f037dfe542222b5188a33c7727c81a464a87bb
  13. Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
  14. Reviewed-by: Michal Klocek <michal.klocek@qt.io>
  15. Upstream-Status: Merged
  16. Signed-off-by: Gaël PORTAY <gael.portay@savoirfairelinux.com>
  17. ---
  18. src/core/surface_factory_qt.cpp | 40 ++++++++--------------------------------
  19. 1 file changed, 8 insertions(+), 32 deletions(-)
  20. diff --git a/src/core/surface_factory_qt.cpp b/src/core/surface_factory_qt.cpp
  21. index 36c05ec5..e8be8480 100644
  22. --- a/src/core/surface_factory_qt.cpp
  23. +++ b/src/core/surface_factory_qt.cpp
  24. @@ -51,51 +51,27 @@
  25. #if defined(USE_OZONE)
  26. #include <EGL/egl.h>
  27. -
  28. -#ifndef QT_LIBDIR_EGL
  29. -#define QT_LIBDIR_EGL "/usr/lib"
  30. -#endif
  31. -#ifndef QT_LIBDIR_GLES2
  32. -#define QT_LIBDIR_GLES2 QT_LIBDIR_EGL
  33. -#endif
  34. +#include <dlfcn.h>
  35. namespace QtWebEngineCore {
  36. -base::NativeLibrary LoadLibrary(const base::FilePath& filename) {
  37. - base::NativeLibraryLoadError error;
  38. - base::NativeLibrary library = base::LoadNativeLibrary(filename, &error);
  39. - if (!library) {
  40. - LOG(ERROR) << "Failed to load " << filename.MaybeAsASCII() << ": " << error.ToString();
  41. - return NULL;
  42. - }
  43. - return library;
  44. -}
  45. -
  46. bool SurfaceFactoryQt::LoadEGLGLES2Bindings()
  47. {
  48. - base::FilePath libEGLPath = QtWebEngineCore::toFilePath(QT_LIBDIR_EGL);
  49. - libEGLPath = libEGLPath.Append("libEGL.so.1");
  50. - base::NativeLibrary eglLibrary = LoadLibrary(libEGLPath);
  51. - if (!eglLibrary)
  52. - return false;
  53. -
  54. - base::FilePath libGLES2Path = QtWebEngineCore::toFilePath(QT_LIBDIR_GLES2);
  55. - libGLES2Path = libGLES2Path.Append("libGLESv2.so.2");
  56. - base::NativeLibrary gles2Library = LoadLibrary(libGLES2Path);
  57. - if (!gles2Library)
  58. + base::NativeLibrary eglgles2Library = dlopen(NULL, RTLD_LAZY);
  59. + if (!eglgles2Library) {
  60. + LOG(ERROR) << "Failed to open EGL/GLES2 context " << dlerror();
  61. return false;
  62. + }
  63. - gl::GLGetProcAddressProc get_proc_address = reinterpret_cast<gl::GLGetProcAddressProc>(base::GetFunctionPointerFromNativeLibrary(eglLibrary, "eglGetProcAddress"));
  64. + gl::GLGetProcAddressProc get_proc_address = reinterpret_cast<gl::GLGetProcAddressProc>(base::GetFunctionPointerFromNativeLibrary(eglgles2Library, "eglGetProcAddress"));
  65. if (!get_proc_address) {
  66. LOG(ERROR) << "eglGetProcAddress not found.";
  67. - base::UnloadNativeLibrary(eglLibrary);
  68. - base::UnloadNativeLibrary(gles2Library);
  69. + base::UnloadNativeLibrary(eglgles2Library);
  70. return false;
  71. }
  72. gl::SetGLGetProcAddressProc(get_proc_address);
  73. - gl::AddGLNativeLibrary(eglLibrary);
  74. - gl::AddGLNativeLibrary(gles2Library);
  75. + gl::AddGLNativeLibrary(eglgles2Library);
  76. return true;
  77. }
  78. --
  79. 2.13.2