summaryrefslogtreecommitdiffstats
path: root/src/core/gl_context_qt.cpp
diff options
context:
space:
mode:
authorAndras Becsi <andras.becsi@digia.com>2014-06-13 18:17:07 +0200
committerAndras Becsi <andras.becsi@digia.com>2014-08-02 10:28:49 +0200
commitddd8ab311271b59514ce0748301e634ca988b62b (patch)
tree7f2cf020558a4eb20b16c000efb77b029f56f076 /src/core/gl_context_qt.cpp
parent4ffc07ddb8739da9e94a2b23b03c63fd7b74c09a (diff)
Implement GLSurfaceQt and exclude chromium's implementation
This makes it possible to use the same EGLConfig that is used by Qt when initializing the EGL surface instead of relying on eglChooseConfig. We can use the native interface to query the used config from Qt to avoid EGL_BAD_MATCH errors during initialization. This depends on patches in the qtbase dev branch, which will become Qt 5.4 at some point, therefore we can only merge this patch if we make Qt 5.4 a hard-dependency of QtWebEngine. Change-Id: I94319433b0790994ecbf543b74e7d12fa4767e32 Reviewed-by: Michael Bruning <michael.bruning@digia.com>
Diffstat (limited to 'src/core/gl_context_qt.cpp')
-rw-r--r--src/core/gl_context_qt.cpp62
1 files changed, 58 insertions, 4 deletions
diff --git a/src/core/gl_context_qt.cpp b/src/core/gl_context_qt.cpp
index f440679cf..e0cca2bd8 100644
--- a/src/core/gl_context_qt.cpp
+++ b/src/core/gl_context_qt.cpp
@@ -45,10 +45,32 @@
#include <QThread>
#include "ui/gl/gl_context_egl.h"
+#include <private/qopenglcontext_p.h>
+#include <private/qsgcontext_p.h>
+#include <qpa/qplatformnativeinterface.h>
+
+#if defined(USE_X11)
+#include <X11/Xlib.h>
+#endif
+
QT_BEGIN_NAMESPACE
GLContextHelper* GLContextHelper::contextHelper = 0;
+namespace {
+
+inline void *resourceForContext(const QByteArray &resource)
+{
+ return qApp->platformNativeInterface()->nativeResourceForContext(resource, QOpenGLContextPrivate::globalShareContext());
+}
+
+inline void *resourceForIntegration(const QByteArray &resource)
+{
+ return qApp->platformNativeInterface()->nativeResourceForIntegration(resource);
+}
+
+}
+
void GLContextHelper::initialize()
{
if (!contextHelper)
@@ -77,9 +99,43 @@ bool GLContextHelper::initializeContext(gfx::GLContext* context, gfx::GLSurface*
return ret;
}
+void* GLContextHelper::getEGLConfig()
+{
+ QByteArray resource = QByteArrayLiteral("eglconfig");
+ return resourceForContext(resource);
+}
+
+void* GLContextHelper::getXConfig()
+{
+ return resourceForContext(QByteArrayLiteral("glxconfig"));
+}
+
+void* GLContextHelper::getEGLDisplay()
+{
+ return resourceForContext(QByteArrayLiteral("egldisplay"));
+}
+
+void* GLContextHelper::getXDisplay()
+{
+ void *display = qApp->platformNativeInterface()->nativeResourceForScreen(QByteArrayLiteral("display"), qApp->primaryScreen());
+#if defined(USE_X11)
+ if (!display) {
+ // XLib isn't available or has not been initialized, which is a decision we wish to
+ // support, for example for the GPU process.
+ display = XOpenDisplay(NULL);
+ }
+#endif
+ return display;
+}
+
+void* GLContextHelper::getNativeDisplay()
+{
+ return resourceForIntegration(QByteArrayLiteral("nativedisplay"));
+}
+
QT_END_NAMESPACE
-#if defined(USE_OZONE) || defined(OS_ANDROID)
+#if defined(USE_OZONE) || defined(OS_ANDROID) || defined(OS_WIN)
namespace gfx {
@@ -94,6 +150,4 @@ scoped_refptr<GLContext> GLContext::CreateGLContext(GLShareGroup* share_group, G
} // namespace gfx
-#endif // defined(USE_OZONE)
-
-
+#endif // defined(USE_OZONE) || defined(OS_ANDROID) || defined(OS_WIN)