diff --git a/src/core/ozone/gl_ozone_glx_qt.cpp b/src/core/ozone/gl_ozone_glx_qt.cpp index 9a0fea7c75626679ab4db16e9d031f4079045981..2e7a28a0e6aa614d57f7fb0baa6d53a6c2ec3427 100644 --- a/src/core/ozone/gl_ozone_glx_qt.cpp +++ b/src/core/ozone/gl_ozone_glx_qt.cpp @@ -41,7 +41,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. - +#include <QGuiApplication> #include "gl_ozone_glx_qt.h" #include "gl_surface_glx_qt.h" #include "ui/gl/gl_context_glx.h" @@ -49,6 +49,13 @@ #include "ui/gl/gl_glx_api_implementation.h" #include <dlfcn.h> +#ifndef QT_NO_OPENGL +#include <QOpenGLContext> +QT_BEGIN_NAMESPACE +Q_GUI_EXPORT QOpenGLContext *qt_gl_global_share_context(); +QT_END_NAMESPACE +#endif + namespace ui { bool GLOzoneGLXQt::InitializeGLOneOffPlatform() { @@ -72,6 +79,16 @@ bool GLOzoneGLXQt::InitializeStaticGLBindings( reinterpret_cast<gl::GLGetProcAddressProc>( base::GetFunctionPointerFromNativeLibrary(library, "glXGetProcAddress")); + +#ifndef QT_NO_OPENGL + if (!get_proc_address) { + // glx handle not loaded, fallback to qpa + if (QOpenGLContext *context = qt_gl_global_share_context()) { + get_proc_address = reinterpret_cast<gl::GLGetProcAddressProc>( + context->getProcAddress("glXGetProcAddress")); + } + } +#endif if (!get_proc_address) { LOG(ERROR) << "glxGetProcAddress not found."; base::UnloadNativeLibrary(library);