Commit 0841e851 authored by Michal Klocek's avatar Michal Klocek Committed by Allan Sandfeld Jensen
Browse files

Add initialization of static bindings for egl and glx


Use lazy binding for static bindings initialization, the
same way we do in ozone.

Task-number: QTBUG-65682
Change-Id: I51ecdfa3b7daca8b1345cf2c0c89a4ac6e25a7c9
Reviewed-by: default avatarAllan Sandfeld Jensen <allan.jensen@qt.io>
Showing with 78 additions and 1 deletion
...@@ -52,13 +52,14 @@ ...@@ -52,13 +52,14 @@
#include "ozone/gl_surface_egl_qt.h" #include "ozone/gl_surface_egl_qt.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/threading/thread_restrictions.h"
#include "gpu/ipc/service/image_transport_surface.h" #include "gpu/ipc/service/image_transport_surface.h"
#include "ui/gl/gl_bindings.h" #include "ui/gl/gl_bindings.h"
#include "ui/gl/gl_context.h" #include "ui/gl/gl_context.h"
#include "ui/gl/gl_implementation.h" #include "ui/gl/gl_implementation.h"
#include "ui/gl/init/gl_initializer.h" #include "ui/gl/init/gl_initializer.h"
#include "ui/gl/init/gl_factory.h" #include "ui/gl/init/gl_factory.h"
#include "ui/gl/gl_gl_api_implementation.h"
#if defined(OS_WIN) #if defined(OS_WIN)
#include "ozone/gl_surface_wgl_qt.h" #include "ozone/gl_surface_wgl_qt.h"
...@@ -69,9 +70,12 @@ ...@@ -69,9 +70,12 @@
#if defined(USE_X11) #if defined(USE_X11)
#include "ozone/gl_surface_glx_qt.h" #include "ozone/gl_surface_glx_qt.h"
#include "ui/gl/gl_glx_api_implementation.h"
#include <dlfcn.h>
#endif #endif
#include "ozone/gl_surface_egl_qt.h" #include "ozone/gl_surface_egl_qt.h"
#include "ui/gl/gl_egl_api_implementation.h"
namespace gl { namespace gl {
...@@ -168,6 +172,79 @@ bool InitializeGLOneOffPlatform() ...@@ -168,6 +172,79 @@ bool InitializeGLOneOffPlatform()
return false; return false;
} }
#if defined(USE_X11)
// FIXME: This should be removed when we switch to OZONE only
bool InitializeStaticGLBindings(GLImplementation implementation) {
// Prevent reinitialization with a different implementation. Once the gpu
// unit tests have initialized with kGLImplementationMock, we don't want to
// later switch to another GL implementation.
DCHECK_EQ(kGLImplementationNone, GetGLImplementation());
base::ThreadRestrictions::ScopedAllowIO allow_io;
switch (implementation) {
case kGLImplementationOSMesaGL:
return false;
case kGLImplementationDesktopGL: {
base::NativeLibrary library = dlopen(NULL, RTLD_LAZY);
if (!library) {
LOG(ERROR) << "Failed to obtain glx handle" << dlerror();
return false;
}
GLGetProcAddressProc get_proc_address =
reinterpret_cast<GLGetProcAddressProc>(
base::GetFunctionPointerFromNativeLibrary(library,
"glXGetProcAddress"));
if (!get_proc_address) {
LOG(ERROR) << "glxGetProcAddress not found.";
base::UnloadNativeLibrary(library);
return false;
}
SetGLGetProcAddressProc(get_proc_address);
AddGLNativeLibrary(library);
SetGLImplementation(kGLImplementationDesktopGL);
InitializeStaticGLBindingsGL();
InitializeStaticGLBindingsGLX();
return true;
}
case kGLImplementationSwiftShaderGL:
case kGLImplementationEGLGLES2: {
base::NativeLibrary library = dlopen(NULL, RTLD_LAZY);
if (!library) {
LOG(ERROR) << "Failed to obtain egl handle" << dlerror();
return false;
}
GLGetProcAddressProc get_proc_address =
reinterpret_cast<GLGetProcAddressProc>(
base::GetFunctionPointerFromNativeLibrary(library,
"eglGetProcAddress"));
if (!get_proc_address) {
LOG(ERROR) << "eglGetProcAddress not found.";
base::UnloadNativeLibrary(library);
return false;
}
SetGLGetProcAddressProc(get_proc_address);
AddGLNativeLibrary(library);
SetGLImplementation(kGLImplementationEGLGLES2);
InitializeStaticGLBindingsGL();
InitializeStaticGLBindingsEGL();
return true;
}
case kGLImplementationMockGL:
case kGLImplementationStubGL:
return false;
default:
NOTREACHED();
}
return false;
}
#endif
bool usingSoftwareDynamicGL() bool usingSoftwareDynamicGL()
{ {
return QtWebEngineCore::usingSoftwareDynamicGL(); return QtWebEngineCore::usingSoftwareDynamicGL();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment