summaryrefslogtreecommitdiffstats
path: root/src/core/gl_surface_qt.cpp
diff options
context:
space:
mode:
authorMichal Klocek <michal.klocek@qt.io>2017-09-21 11:39:17 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2018-08-02 20:52:21 +0000
commit3ee51f8f085da394851857b0d6a42df537ca99da (patch)
tree9c4e81cd778caeedbb45c075301cb8dc0506b948 /src/core/gl_surface_qt.cpp
parent20abae270a20d312d45fc7f850af44603f5f38de (diff)
Use ozone for x11
Switch to use ozone also for x11/glx. This way we have a more elegant approach to hook in our gl surface classes and we use ozone for all linux qpa backends. Moreover, we have now also more fine grain control to reimplement gl surface handling logic. This also aims to fix currently broken wayland backend, but instead of patching the broken x11 calls, we simply reuse ozone which does not use x11 for ozone egl. Add webengine-x11 check to handle ozone glx plugin compilation. For ozone egl backend reimplement missing functions. Task-number: QTBUG-65682 Task-number: QTBUG-51631 Change-Id: I8b45c6f4d09a1c703efb12b6452d78ab385371ab Reviewed-by: Jüri Valdmann <juri.valdmann@qt.io>
Diffstat (limited to 'src/core/gl_surface_qt.cpp')
-rw-r--r--src/core/gl_surface_qt.cpp120
1 files changed, 9 insertions, 111 deletions
diff --git a/src/core/gl_surface_qt.cpp b/src/core/gl_surface_qt.cpp
index 4d38d7c25..7cde289ae 100644
--- a/src/core/gl_surface_qt.cpp
+++ b/src/core/gl_surface_qt.cpp
@@ -68,13 +68,6 @@
#include "ui/gl/vsync_provider_win.h"
#endif
-#if defined(USE_X11)
-#include "ozone/gl_surface_glx_qt.h"
-#include "ui/gl/gl_glx_api_implementation.h"
-#include <dlfcn.h>
-
-#endif
-
#include "ozone/gl_surface_egl_qt.h"
#include "ui/gl/gl_egl_api_implementation.h"
@@ -142,13 +135,11 @@ void* GLSurfaceQt::GetConfig()
return g_config;
}
+#if defined(OS_WIN)
namespace init {
-
bool InitializeGLOneOffPlatform()
{
-#if defined(OS_WIN)
VSyncProviderWin::InitializeOneOff();
-#endif
if (GetGLImplementation() == kGLImplementationOSMesaGL)
return false;
@@ -157,12 +148,8 @@ bool InitializeGLOneOffPlatform()
return GLSurfaceEGLQt::InitializeOneOff();
if (GetGLImplementation() == kGLImplementationDesktopGL) {
-#if defined(OS_WIN)
return GLSurfaceWGLQt::InitializeOneOff();
-#elif defined(USE_X11)
- if (GLSurfaceGLXQt::InitializeOneOff())
- return true;
-#endif
+
// Fallback to trying EGL with desktop GL.
if (GLSurfaceEGLQt::InitializeOneOff()) {
g_initializedEGL = true;
@@ -173,87 +160,6 @@ bool InitializeGLOneOffPlatform()
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) {
- QFunctionPointer address = GLContextHelper::getGlXGetProcAddress();
- get_proc_address = reinterpret_cast<gl::GLGetProcAddressProc>(address);
- }
- 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) {
- QFunctionPointer address = GLContextHelper::getEglGetProcAddress();
- get_proc_address = reinterpret_cast<gl::GLGetProcAddressProc>(address);
- }
- 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()
{
return QtWebEngineCore::usingSoftwareDynamicGL();
@@ -266,19 +172,10 @@ CreateOffscreenGLSurfaceWithFormat(const gfx::Size& size, GLSurfaceFormat format
switch (GetGLImplementation()) {
case kGLImplementationDesktopGLCoreProfile:
case kGLImplementationDesktopGL: {
-#if defined(OS_WIN)
surface = new GLSurfaceWGLQt(size);
if (surface->Initialize(format))
return surface;
break;
-#elif defined(USE_X11)
- if (!g_initializedEGL) {
- surface = new GLSurfaceGLXQt(size);
- if (surface->Initialize(format))
- return surface;
- }
- Q_FALLTHROUGH();
-#endif
}
case kGLImplementationEGLGLES2: {
surface = new GLSurfaceEGLQt(size);
@@ -313,8 +210,10 @@ CreateViewGLSurface(gfx::AcceleratedWidget window)
}
} // namespace init
-} // namespace gl
+#endif // defined(OS_WIN)
+} // namespace gl
+#if defined(OS_WIN)
namespace gpu {
class GpuCommandBufferStub;
class GpuChannelManager;
@@ -325,11 +224,10 @@ scoped_refptr<gl::GLSurface> ImageTransportSurface::CreateNativeSurface(base::We
return scoped_refptr<gl::GLSurface>();
}
-#if defined(OS_WIN)
bool DirectCompositionSurfaceWin::IsHDRSupported()
-{ return false; }
-#endif
-
+{
+ return false;
+}
} // namespace gpu
-
+#endif
#endif // !defined(OS_MACOSX)