diff options
author | Samuel Rødal <samuel.rodal@nokia.com> | 2011-03-23 12:41:28 (GMT) |
---|---|---|
committer | Samuel Rødal <samuel.rodal@nokia.com> | 2011-03-23 13:07:52 (GMT) |
commit | 2905f11e8e8fe7e05d61cec9fcc1d78ff91f0f31 (patch) | |
tree | b6f17ae6df26f14496dbdeb2cc35ba3c76444935 /src | |
parent | 9f6eb99448d3ee8cbdd1c5b41903176759b1664f (diff) | |
download | Qt-2905f11e8e8fe7e05d61cec9fcc1d78ff91f0f31.zip Qt-2905f11e8e8fe7e05d61cec9fcc1d78ff91f0f31.tar.gz Qt-2905f11e8e8fe7e05d61cec9fcc1d78ff91f0f31.tar.bz2 |
Avoid duplicate calls to eglGetDisplay() in XCB / Xlib platforms.
Just call eglGetDisplay() once, as we also need to call eglInitialize()
before the display can be used validly.
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/platforms/eglconvenience/qxlibeglintegration.cpp | 4 | ||||
-rw-r--r-- | src/plugins/platforms/eglconvenience/qxlibeglintegration.h | 2 | ||||
-rw-r--r-- | src/plugins/platforms/xcb/qxcbwindow.cpp | 7 | ||||
-rw-r--r-- | src/plugins/platforms/xlib/qxlibintegration.cpp | 3 | ||||
-rw-r--r-- | src/plugins/platforms/xlib/qxlibscreen.cpp | 5 | ||||
-rw-r--r-- | src/plugins/platforms/xlib/qxlibscreen.h | 8 | ||||
-rw-r--r-- | src/plugins/platforms/xlib/qxlibwindow.cpp | 6 |
7 files changed, 22 insertions, 13 deletions
diff --git a/src/plugins/platforms/eglconvenience/qxlibeglintegration.cpp b/src/plugins/platforms/eglconvenience/qxlibeglintegration.cpp index 7f296c5..45746e9 100644 --- a/src/plugins/platforms/eglconvenience/qxlibeglintegration.cpp +++ b/src/plugins/platforms/eglconvenience/qxlibeglintegration.cpp @@ -52,13 +52,11 @@ static int countBits(unsigned long mask) return count; } -VisualID QXlibEglIntegration::getCompatibleVisualId(Display *display, EGLConfig config) +VisualID QXlibEglIntegration::getCompatibleVisualId(Display *display, EGLDisplay eglDisplay, EGLConfig config) { VisualID visualId = 0; EGLint eglValue = 0; - EGLDisplay eglDisplay = eglGetDisplay(display); - EGLint configRedSize = 0; eglGetConfigAttrib(eglDisplay, config, EGL_RED_SIZE, &configRedSize); diff --git a/src/plugins/platforms/eglconvenience/qxlibeglintegration.h b/src/plugins/platforms/eglconvenience/qxlibeglintegration.h index 51996da..6c2e266 100644 --- a/src/plugins/platforms/eglconvenience/qxlibeglintegration.h +++ b/src/plugins/platforms/eglconvenience/qxlibeglintegration.h @@ -47,7 +47,7 @@ class QXlibEglIntegration { public: - static VisualID getCompatibleVisualId(Display *display, EGLConfig config); + static VisualID getCompatibleVisualId(Display *display, EGLDisplay eglDisplay, EGLConfig config); }; #endif // QTESTLITEEGLINTEGRATION_H diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index cbf50f7..017a902 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -114,9 +114,9 @@ QXcbWindow::QXcbWindow(QWidget *tlw) #if defined(XCB_USE_GLX) XVisualInfo *visualInfo = QGLXContext::findVisualInfo(m_screen, tlw->platformWindowFormat()); #elif defined(XCB_USE_EGL) - EGLDisplay eglDisplay = eglGetDisplay(DISPLAY_FROM_XCB(this)); + EGLDisplay eglDisplay = connection()->egl_display(); EGLConfig eglConfig = q_configFromQPlatformWindowFormat(eglDisplay,tlw->platformWindowFormat(),true); - VisualID id = QXlibEglIntegration::getCompatibleVisualId(DISPLAY_FROM_XCB(this),eglConfig); + VisualID id = QXlibEglIntegration::getCompatibleVisualId(DISPLAY_FROM_XCB(this), eglDisplay, eglConfig); XVisualInfo visualInfoTemplate; memset(&visualInfoTemplate, 0, sizeof(XVisualInfo)); @@ -430,8 +430,7 @@ QPlatformGLContext *QXcbWindow::glContext() const } #elif defined(XCB_USE_EGL) if (!m_context) { - EGLDisplay display = eglGetDisplay(DISPLAY_FROM_XCB(this)); - + EGLDisplay display = connection()->egl_display(); EGLConfig config = q_configFromQPlatformWindowFormat(display,widget()->platformWindowFormat(),true); QVector<EGLint> eglContextAttrs; eglContextAttrs.append(EGL_CONTEXT_CLIENT_VERSION); diff --git a/src/plugins/platforms/xlib/qxlibintegration.cpp b/src/plugins/platforms/xlib/qxlibintegration.cpp index 6733ed1..63197b0 100644 --- a/src/plugins/platforms/xlib/qxlibintegration.cpp +++ b/src/plugins/platforms/xlib/qxlibintegration.cpp @@ -141,11 +141,12 @@ bool QXlibIntegration::hasOpenGL() const static bool wasEglInitialized = false; if (!eglHasbeenInitialized) { eglHasbeenInitialized = true; - const QXlibScreen *screen = static_cast<const QXlibScreen *>(mScreens.at(0)); + QXlibScreen *screen = static_cast<QXlibScreen *>(mScreens.at(0)); EGLint major, minor; eglBindAPI(EGL_OPENGL_ES_API); EGLDisplay disp = eglGetDisplay(screen->display()->nativeDisplay()); wasEglInitialized = eglInitialize(disp,&major,&minor); + screen->setEglDisplay(disp); } return wasEglInitialized; #endif diff --git a/src/plugins/platforms/xlib/qxlibscreen.cpp b/src/plugins/platforms/xlib/qxlibscreen.cpp index 23a2d07..7c8a367 100644 --- a/src/plugins/platforms/xlib/qxlibscreen.cpp +++ b/src/plugins/platforms/xlib/qxlibscreen.cpp @@ -191,6 +191,9 @@ qDebug() << "qt_x_errhandler" << err->error_code; QXlibScreen::QXlibScreen() : mFormat(QImage::Format_RGB32) +#if !defined(QT_NO_OPENGL) && defined(QT_OPENGL_ES_2) + , mEGLDisplay(0) +#endif { char *display_name = getenv("DISPLAY"); Display *display = XOpenDisplay(display_name); @@ -467,7 +470,7 @@ int QXlibScreen::xScreenNumber() const Visual * QXlibScreen::defaultVisual() const { - DefaultVisual(display()->nativeDisplay(), xScreenNumber()); + return DefaultVisual(display()->nativeDisplay(), xScreenNumber()); } QXlibKeyboard * QXlibScreen::keyboard() const diff --git a/src/plugins/platforms/xlib/qxlibscreen.h b/src/plugins/platforms/xlib/qxlibscreen.h index 35c0141..8c04c0f 100644 --- a/src/plugins/platforms/xlib/qxlibscreen.h +++ b/src/plugins/platforms/xlib/qxlibscreen.h @@ -82,6 +82,11 @@ public: QXlibKeyboard *keyboard() const; +#if !defined(QT_NO_OPENGL) && defined(QT_OPENGL_ES_2) + void *eglDisplay() const { return mEGLDisplay; } + void setEglDisplay(void *display) { mEGLDisplay = display; } +#endif + public slots: void eventDispatcher(); @@ -96,6 +101,9 @@ private: QXlibKeyboard *mKeyboard; QXlibDisplay * mDisplay; +#if !defined(QT_NO_OPENGL) && defined(QT_OPENGL_ES_2) + void *mEGLDisplay; +#endif int mScreen; }; diff --git a/src/plugins/platforms/xlib/qxlibwindow.cpp b/src/plugins/platforms/xlib/qxlibwindow.cpp index a7bc53c..01d4b8e 100644 --- a/src/plugins/platforms/xlib/qxlibwindow.cpp +++ b/src/plugins/platforms/xlib/qxlibwindow.cpp @@ -87,9 +87,9 @@ QXlibWindow::QXlibWindow(QWidget *window) #else QPlatformWindowFormat windowFormat = correctColorBuffers(window->platformWindowFormat()); - EGLDisplay eglDisplay = eglGetDisplay(mScreen->display()->nativeDisplay()); + EGLDisplay eglDisplay = mScreen->eglDisplay(); EGLConfig eglConfig = q_configFromQPlatformWindowFormat(eglDisplay,windowFormat); - VisualID id = QXlibEglIntegration::getCompatibleVisualId(mScreen->display()->nativeDisplay(),eglConfig); + VisualID id = QXlibEglIntegration::getCompatibleVisualId(mScreen->display()->nativeDisplay(), eglDisplay, eglConfig); XVisualInfo visualInfoTemplate; memset(&visualInfoTemplate, 0, sizeof(XVisualInfo)); @@ -663,7 +663,7 @@ QPlatformGLContext *QXlibWindow::glContext() const #if !defined(QT_OPENGL_ES_2) that->mGLContext = new QGLXContext(x_window, mScreen,widget()->platformWindowFormat()); #else - EGLDisplay display = eglGetDisplay(mScreen->display()->nativeDisplay()); + EGLDisplay display = mScreen->eglDisplay(); QPlatformWindowFormat windowFormat = correctColorBuffers(widget()->platformWindowFormat()); |