diff options
author | Qt Continuous Integration System <qt-info@nokia.com> | 2010-01-06 19:26:49 (GMT) |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2010-01-06 19:26:49 (GMT) |
commit | 7a5bca82738e6b782047e50a813972eccd928307 (patch) | |
tree | ada860439ffcc9b53c24972e4782ed19f2374247 /src/opengl/qgl_x11egl.cpp | |
parent | 69bc7ba41375e3f00b2111bda8d2743654960f71 (diff) | |
parent | 94759a0ed565b21c8dbfb4b12bfe6064f156b410 (diff) | |
download | Qt-7a5bca82738e6b782047e50a813972eccd928307.zip Qt-7a5bca82738e6b782047e50a813972eccd928307.tar.gz Qt-7a5bca82738e6b782047e50a813972eccd928307.tar.bz2 |
Merge branch '4.6' of scm.dev.nokia.troll.no:qt/oslo-staging-2 into 4.6-integration
* '4.6' of scm.dev.nokia.troll.no:qt/oslo-staging-2: (42 commits)
QBoxLayout::setGeometry would not respect the widget min/max width
Revert "QStyleSheetStyle: Fixed some text croped when having padding with native border."
Use QFile:rename when moving items in QFileystemModel.
Revert "Add GLfloat[2][2] & GLfloat[3][3] uniform setters to QGLShaderProgram"
Fix default filter selection when using HideNameFilterDetails option.
Don't write out fo:word-spacing if its the default value.
Improved initial startup time for a QGLWidget ontop of EGL/X11.
Document the QGraphicsView::IndirectPainting flag
Display broken symlinks in the filesystem model.
Fix typo in autotest testcase name.
Fixed a bug with distribution of spans.
Make unit test more robust
Compile with QT_NO_DOCKWIDGET
Removed temporary QGLWidget created during QGLWidget/X11 initialization.
Fix test: The bug is now fixed
Fix auto-test failure on Windows
QScript: Lookup the native setter from the prototype
Implement QScript::QObjectDelegate::getOwnPropertyDescriptor
fix compilation in GL2 paint engine for Windows
Move QGLTextureGlyphCache into it's own file
...
Diffstat (limited to 'src/opengl/qgl_x11egl.cpp')
-rw-r--r-- | src/opengl/qgl_x11egl.cpp | 116 |
1 files changed, 111 insertions, 5 deletions
diff --git a/src/opengl/qgl_x11egl.cpp b/src/opengl/qgl_x11egl.cpp index 19026b3..271f4de 100644 --- a/src/opengl/qgl_x11egl.cpp +++ b/src/opengl/qgl_x11egl.cpp @@ -52,6 +52,116 @@ QT_BEGIN_NAMESPACE + +bool qt_egl_setup_x11_visual(XVisualInfo &vi, EGLDisplay display, EGLConfig config, + const QX11Info &x11Info, bool useArgbVisual); +// +// QGLTempContext is a lass for creating a temporary GL context (which is +// needed during QGLWidget initialization to retrieve GL extension info). +// Faster to construct than a full QGLWidget. +// +class QGLTempContext +{ +public: + QGLTempContext(int screen = 0) : + initialized(false), + window(0), + context(0), + surface(0) + { + display = eglGetDisplay(EGLNativeDisplayType(X11->display)); + + if (!eglInitialize(display, NULL, NULL)) { + qWarning("QGLTempContext: Unable to initialize EGL display."); + return; + } + + EGLConfig config; + int numConfigs = 0; + EGLint attribs[] = { + EGL_SURFACE_TYPE, EGL_WINDOW_BIT, +#ifdef QT_OPENGL_ES_2 + EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, +#endif + EGL_NONE + }; + + eglChooseConfig(display, attribs, &config, 1, &numConfigs); + if (!numConfigs) { + qWarning("QGLTempContext: No EGL configurations available."); + return; + } + + XVisualInfo visualInfo; + XVisualInfo *vi; + int numVisuals; + EGLint id = 0; + + eglGetConfigAttrib(display, config, EGL_NATIVE_VISUAL_ID, &id); + if (id == 0) { + // EGL_NATIVE_VISUAL_ID is optional and might not be supported + // on some implementations - we'll have to do it the hard way + QX11Info xinfo; + qt_egl_setup_x11_visual(visualInfo, display, config, xinfo, false); + } else { + visualInfo.visualid = id; + } + vi = XGetVisualInfo(X11->display, VisualIDMask, &visualInfo, &numVisuals); + if (!vi || numVisuals < 1) { + qWarning("QGLTempContext: Unable to get X11 visual info id."); + return; + } + + window = XCreateWindow(X11->display, RootWindow(X11->display, screen), + 0, 0, 1, 1, 0, + vi->depth, InputOutput, vi->visual, + 0, 0); + + surface = eglCreateWindowSurface(display, config, (EGLNativeWindowType) window, NULL); + + if (surface == EGL_NO_SURFACE) { + qWarning("QGLTempContext: Error creating EGL surface."); + XFree(vi); + XDestroyWindow(X11->display, window); + return; + } + + EGLint contextAttribs[] = { +#ifdef QT_OPENGL_ES_2 + EGL_CONTEXT_CLIENT_VERSION, 2, +#endif + EGL_NONE + }; + context = eglCreateContext(display, config, 0, contextAttribs); + if (context != EGL_NO_CONTEXT + && eglMakeCurrent(display, surface, surface, context)) + { + initialized = true; + } else { + qWarning("QGLTempContext: Error creating EGL context."); + eglDestroySurface(display, surface); + XDestroyWindow(X11->display, window); + } + XFree(vi); + } + + ~QGLTempContext() { + if (initialized) { + eglMakeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); + eglDestroyContext(display, context); + eglDestroySurface(display, surface); + XDestroyWindow(X11->display, window); + } + } + +private: + bool initialized; + Window window; + EGLContext context; + EGLSurface surface; + EGLDisplay display; +}; + bool QGLFormat::hasOpenGLOverlays() { return false; @@ -446,12 +556,8 @@ void QGLExtensions::init() init_done = true; // We need a context current to initialize the extensions. - QGLWidget tmpWidget; - tmpWidget.makeCurrent(); - + QGLTempContext context; init_extensions(); - - tmpWidget.doneCurrent(); } // Re-creates the EGL surface if the window ID has changed or if force is true |