diff options
author | Samuel Rødal <samuel.rodal@nokia.com> | 2011-04-13 06:49:52 (GMT) |
---|---|---|
committer | Samuel Rødal <samuel.rodal@nokia.com> | 2011-04-13 07:45:00 (GMT) |
commit | 3ba6c3b7a4261147addc1d7fb06060dae7522691 (patch) | |
tree | cded7ec5f02e5f6ea082110185c6da2e03d514e9 /src/plugins/platforms | |
parent | 0108e888480e47e65d82d94e10a7c7c910e42d79 (diff) | |
download | Qt-3ba6c3b7a4261147addc1d7fb06060dae7522691.zip Qt-3ba6c3b7a4261147addc1d7fb06060dae7522691.tar.gz Qt-3ba6c3b7a4261147addc1d7fb06060dae7522691.tar.bz2 |
Remove DefaultSharedContext from Lighthouse API.
QPlatformWindowFormat::setUseDefaultSharedContext was meant as a
convenience, but it adds complexity in the platform plugin
implementation, and can be implemented by the above layers using
QPlatformWindowFormat::setSharedContext.
Reviewed-by: Jørgen Lind
Diffstat (limited to 'src/plugins/platforms')
12 files changed, 15 insertions, 137 deletions
diff --git a/src/plugins/platforms/eglconvenience/qeglplatformcontext.cpp b/src/plugins/platforms/eglconvenience/qeglplatformcontext.cpp index 9a2bc61..ae5215f 100644 --- a/src/plugins/platforms/eglconvenience/qeglplatformcontext.cpp +++ b/src/plugins/platforms/eglconvenience/qeglplatformcontext.cpp @@ -146,11 +146,6 @@ void* QEGLPlatformContext::getProcAddress(const QString& procName) return (void *)eglGetProcAddress(qPrintable(procName)); } -void QEGLPlatformContext::makeDefaultSharedContext() -{ - setDefaultSharedContext(this); -} - QPlatformWindowFormat QEGLPlatformContext::platformWindowFormat() const { return m_windowFormat; diff --git a/src/plugins/platforms/eglconvenience/qeglplatformcontext.h b/src/plugins/platforms/eglconvenience/qeglplatformcontext.h index d688660..69835d7 100644 --- a/src/plugins/platforms/eglconvenience/qeglplatformcontext.h +++ b/src/plugins/platforms/eglconvenience/qeglplatformcontext.h @@ -56,8 +56,6 @@ public: void swapBuffers(); void* getProcAddress(const QString& procName); - void makeDefaultSharedContext(); - QPlatformWindowFormat platformWindowFormat() const; EGLContext eglContext() const; diff --git a/src/plugins/platforms/eglfs/qeglfsscreen.cpp b/src/plugins/platforms/eglfs/qeglfsscreen.cpp index 2200d1d..b6f2805 100644 --- a/src/plugins/platforms/eglfs/qeglfsscreen.cpp +++ b/src/plugins/platforms/eglfs/qeglfsscreen.cpp @@ -203,7 +203,6 @@ void QEglFSScreen::createAndSetPlatformContext() attribList[temp++] = EGL_NONE; QEGLPlatformContext *platformContext = new QEGLPlatformContext(m_dpy,config,attribList,m_surface,EGL_OPENGL_ES_API); - platformContext->makeDefaultSharedContext(); m_platformContext = platformContext; EGLint w,h; // screen size detection diff --git a/src/plugins/platforms/openkode/qopenkodeintegration.cpp b/src/plugins/platforms/openkode/qopenkodeintegration.cpp index 35e744be..e98f322 100644 --- a/src/plugins/platforms/openkode/qopenkodeintegration.cpp +++ b/src/plugins/platforms/openkode/qopenkodeintegration.cpp @@ -122,7 +122,9 @@ QOpenKODEScreen::QOpenKODEScreen(KDDisplayNV *kdDisplay, KDDesktopNV *kdDesktop } QOpenKODEIntegration::QOpenKODEIntegration() - : mEventLoopIntegration(0), mFontDb(new QGenericUnixFontDatabase()) + : mEventLoopIntegration(0) + , mFontDb(new QGenericUnixFontDatabase()) + , mMainGlContext(0) { if (kdInitializeNV() == KD_ENOTINITIALIZED) { qFatal("Did not manage to initialize openkode"); diff --git a/src/plugins/platforms/openkode/qopenkodeintegration.h b/src/plugins/platforms/openkode/qopenkodeintegration.h index 7582e60..a788091 100644 --- a/src/plugins/platforms/openkode/qopenkodeintegration.h +++ b/src/plugins/platforms/openkode/qopenkodeintegration.h @@ -106,10 +106,14 @@ public: static GLuint blitterProgram(); + void setMainGLContext(QEGLPlatformContext *ctx) { mMainGlContext = ctx; } + void mainGLContext() const { return mMainGlContext; } + private: QList<QPlatformScreen *> mScreens; QOpenKODEEventLoopIntegration *mEventLoopIntegration; QPlatformFontDatabase *mFontDb; + QEGLPlatformContext *mMainGlContext; }; QT_END_NAMESPACE diff --git a/src/plugins/platforms/openkode/qopenkodewindow.cpp b/src/plugins/platforms/openkode/qopenkodewindow.cpp index 66530a5..d34dff8 100644 --- a/src/plugins/platforms/openkode/qopenkodewindow.cpp +++ b/src/plugins/platforms/openkode/qopenkodewindow.cpp @@ -147,9 +147,9 @@ QOpenKODEWindow::QOpenKODEWindow(QWidget *tlw) } + QOpenKODEIntegration *integration = static_cast<QOpenKODEIntegration *>(QApplicationPrivate::platformIntegration()); - - if (!isFullScreen || (isFullScreen && !QPlatformGLContext::defaultSharedContext())) { + if (!isFullScreen || (isFullScreen && !integration->mainGLContext())) { if (kdRealizeWindow(m_kdWindow, &m_eglWindow)) { qErrnoWarning(kdGetError(), "Could not realize native window"); return; @@ -158,9 +158,9 @@ QOpenKODEWindow::QOpenKODEWindow(QWidget *tlw) EGLSurface surface = eglCreateWindowSurface(screen->eglDisplay(),m_eglConfig,m_eglWindow,m_eglWindowAttrs.constData()); m_platformGlContext = new QEGLPlatformContext(screen->eglDisplay(), m_eglConfig, m_eglContextAttrs.data(), surface, m_eglApi); - m_platformGlContext->makeDefaultSharedContext(); + integration->setMainGLContext(m_platformGLContext); } else { - m_platformGlContext = const_cast<QEGLPlatformContext *>(static_cast<const QEGLPlatformContext *>(QPlatformGLContext::defaultSharedContext())); + m_platformGlContext = integration->mainGLContext(); kdDestroyWindow(m_kdWindow); m_kdWindow = 0; } @@ -169,7 +169,7 @@ QOpenKODEWindow::QOpenKODEWindow(QWidget *tlw) QOpenKODEWindow::~QOpenKODEWindow() { - if (m_platformGlContext != QPlatformGLContext::defaultSharedContext()) { + if (m_platformGlContext != static_cast<QOpenKODEIntegration *>(QApplicationPrivate::platformIntegration())) { delete m_platformGlContext; } if (m_kdWindow) diff --git a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandglcontext.cpp b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandglcontext.cpp index 89ba12b..d293019 100644 --- a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandglcontext.cpp +++ b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandglcontext.cpp @@ -50,8 +50,6 @@ #include <QtGui/QPlatformWindowFormat> #include <QtCore/QMutex> -Q_GLOBAL_STATIC(QMutex,qt_defaultSharedContextMutex) - QWaylandGLContext::QWaylandGLContext(EGLDisplay eglDisplay, const QPlatformWindowFormat &format) : QPlatformGLContext() , mEglDisplay(eglDisplay) @@ -60,20 +58,7 @@ QWaylandGLContext::QWaylandGLContext(EGLDisplay eglDisplay, const QPlatformWindo , mFormat(qt_qPlatformWindowFormatFromConfig(mEglDisplay,mConfig)) { QPlatformGLContext *sharePlatformContext = 0; - if (format.useDefaultSharedContext()) { - if (!QPlatformGLContext::defaultSharedContext()) { - if (qt_defaultSharedContextMutex()->tryLock()){ - createDefaultSharedContext(eglDisplay); - qt_defaultSharedContextMutex()->unlock(); - } else { - qt_defaultSharedContextMutex()->lock(); //wait to the the shared context is created - qt_defaultSharedContextMutex()->unlock(); - } - } - sharePlatformContext = QPlatformGLContext::defaultSharedContext(); - } else { - sharePlatformContext = format.sharedGLContext(); - } + sharePlatformContext = format.sharedGLContext(); mFormat.setSharedContext(sharePlatformContext); EGLContext shareEGLContext = EGL_NO_CONTEXT; if (sharePlatformContext) @@ -128,20 +113,6 @@ void *QWaylandGLContext::getProcAddress(const QString &string) return (void *) eglGetProcAddress(string.toLatin1().data()); } -void QWaylandGLContext::createDefaultSharedContext(EGLDisplay display) -{ - QVector<EGLint> eglContextAttrs; - eglContextAttrs.append(EGL_CONTEXT_CLIENT_VERSION); - eglContextAttrs.append(2); - eglContextAttrs.append(EGL_NONE); - - QWaylandGLContext *defaultSharedContext = new QWaylandGLContext; - defaultSharedContext->mEglDisplay = display; - defaultSharedContext->mContext = eglCreateContext(mEglDisplay,mConfig, - EGL_NO_CONTEXT, eglContextAttrs.constData()); - QPlatformGLContext::setDefaultSharedContext(defaultSharedContext); -} - void QWaylandGLContext::setEglSurface(EGLSurface surface) { doneCurrent(); diff --git a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandglcontext.h b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandglcontext.h index a3befdc..76caffa 100644 --- a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandglcontext.h +++ b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandglcontext.h @@ -72,7 +72,6 @@ private: EGLConfig mConfig; QPlatformWindowFormat mFormat; - void createDefaultSharedContext(EGLDisplay eglDisplay); QWaylandGLContext(); }; diff --git a/src/plugins/platforms/xcb/qglxintegration.cpp b/src/plugins/platforms/xcb/qglxintegration.cpp index 19a9503..190221c 100644 --- a/src/plugins/platforms/xcb/qglxintegration.cpp +++ b/src/plugins/platforms/xcb/qglxintegration.cpp @@ -57,8 +57,6 @@ #include <dlfcn.h> #endif -QMutex QGLXContext::m_defaultSharedContextMutex(QMutex::Recursive); - QGLXContext::QGLXContext(Window window, QXcbScreen *screen, const QPlatformWindowFormat &format) : QPlatformGLContext() , m_screen(screen) @@ -67,20 +65,7 @@ QGLXContext::QGLXContext(Window window, QXcbScreen *screen, const QPlatformWindo { Q_XCB_NOOP(m_screen->connection()); const QPlatformGLContext *sharePlatformContext; - if (format.useDefaultSharedContext()) { - if (!QPlatformGLContext::defaultSharedContext()) { - if (m_defaultSharedContextMutex.tryLock()){ - createDefaultSharedContext(screen); - m_defaultSharedContextMutex.unlock(); - } else { - m_defaultSharedContextMutex.lock(); //wait to the the shared context is created - m_defaultSharedContextMutex.unlock(); - } - } - sharePlatformContext = QPlatformGLContext::defaultSharedContext(); - } else { - sharePlatformContext = format.sharedGLContext(); - } + sharePlatformContext = format.sharedGLContext(); GLXContext shareGlxContext = 0; if (sharePlatformContext) shareGlxContext = static_cast<const QGLXContext*>(sharePlatformContext)->glxContext(); @@ -105,35 +90,6 @@ QGLXContext::~QGLXContext() Q_XCB_NOOP(m_screen->connection()); } -void QGLXContext::createDefaultSharedContext(QXcbScreen *screen) -{ - Q_XCB_NOOP(screen->connection()); - int x = 0; - int y = 0; - int w = 3; - int h = 3; - - QPlatformWindowFormat format = QPlatformWindowFormat::defaultFormat(); - GLXContext context; - GLXFBConfig config = qglx_findConfig(DISPLAY_FROM_XCB(screen),screen->screenNumber(),format); - if (config) { - XVisualInfo *visualInfo = glXGetVisualFromFBConfig(DISPLAY_FROM_XCB(screen), config); - Colormap cmap = XCreateColormap(DISPLAY_FROM_XCB(screen), screen->root(), visualInfo->visual, AllocNone); - XSetWindowAttributes a; - a.colormap = cmap; - Window sharedWindow = XCreateWindow(DISPLAY_FROM_XCB(screen), screen->root(), x, y, w, h, - 0, visualInfo->depth, InputOutput, visualInfo->visual, - CWColormap, &a); - - context = glXCreateNewContext(DISPLAY_FROM_XCB(screen), config, GLX_RGBA_TYPE, 0, TRUE); - QPlatformGLContext *sharedContext = new QGLXContext(screen, sharedWindow, context); - QPlatformGLContext::setDefaultSharedContext(sharedContext); - } else { - qWarning("Warning no shared context created"); - } - Q_XCB_NOOP(screen->connection()); -} - void QGLXContext::makeCurrent() { Q_XCB_NOOP(m_screen->connection()); diff --git a/src/plugins/platforms/xcb/qglxintegration.h b/src/plugins/platforms/xcb/qglxintegration.h index 2e19cf2..99b72a0 100644 --- a/src/plugins/platforms/xcb/qglxintegration.h +++ b/src/plugins/platforms/xcb/qglxintegration.h @@ -73,8 +73,6 @@ private: QPlatformWindowFormat m_windowFormat; QGLXContext (QXcbScreen *screen, Drawable drawable, GLXContext context); - static QMutex m_defaultSharedContextMutex; - static void createDefaultSharedContext(QXcbScreen *xd); }; #endif diff --git a/src/plugins/platforms/xlib/qglxintegration.cpp b/src/plugins/platforms/xlib/qglxintegration.cpp index 6746e22..7a0f36d 100644 --- a/src/plugins/platforms/xlib/qglxintegration.cpp +++ b/src/plugins/platforms/xlib/qglxintegration.cpp @@ -61,8 +61,6 @@ QT_BEGIN_NAMESPACE -QMutex QGLXContext::m_defaultSharedContextMutex(QMutex::Recursive); - QGLXContext::QGLXContext(Window window, QXlibScreen *screen, const QPlatformWindowFormat &format) : QPlatformGLContext() , m_screen(screen) @@ -71,20 +69,7 @@ QGLXContext::QGLXContext(Window window, QXlibScreen *screen, const QPlatformWind { const QPlatformGLContext *sharePlatformContext; - if (format.useDefaultSharedContext()) { - if (!QPlatformGLContext::defaultSharedContext()) { - if (m_defaultSharedContextMutex.tryLock()){ - createDefaultSharedContext(screen); - m_defaultSharedContextMutex.unlock(); - } else { - m_defaultSharedContextMutex.lock(); //wait to the the shared context is created - m_defaultSharedContextMutex.unlock(); - } - } - sharePlatformContext = QPlatformGLContext::defaultSharedContext(); - } else { - sharePlatformContext = format.sharedGLContext(); - } + sharePlatformContext = format.sharedGLContext(); GLXContext shareGlxContext = 0; if (sharePlatformContext) shareGlxContext = static_cast<const QGLXContext*>(sharePlatformContext)->glxContext(); @@ -112,33 +97,6 @@ QGLXContext::~QGLXContext() } } -void QGLXContext::createDefaultSharedContext(QXlibScreen *screen) -{ - int x = 0; - int y = 0; - int w = 3; - int h = 3; - - QPlatformWindowFormat format = QPlatformWindowFormat::defaultFormat(); - GLXContext context; - GLXFBConfig config = qglx_findConfig(screen->display()->nativeDisplay(),screen->xScreenNumber(),format); - if (config) { - XVisualInfo *visualInfo = glXGetVisualFromFBConfig(screen->display()->nativeDisplay(),config); - Colormap cmap = XCreateColormap(screen->display()->nativeDisplay(),screen->rootWindow(),visualInfo->visual,AllocNone); - XSetWindowAttributes a; - a.colormap = cmap; - Window sharedWindow = XCreateWindow(screen->display()->nativeDisplay(), screen->rootWindow(),x, y, w, h, - 0, visualInfo->depth, InputOutput, visualInfo->visual, - CWColormap, &a); - - context = glXCreateNewContext(screen->display()->nativeDisplay(),config,GLX_RGBA_TYPE,0,TRUE); - QPlatformGLContext *sharedContext = new QGLXContext(screen,sharedWindow,context); - QPlatformGLContext::setDefaultSharedContext(sharedContext); - } else { - qWarning("Warning no shared context created"); - } -} - void QGLXContext::makeCurrent() { QPlatformGLContext::makeCurrent(); diff --git a/src/plugins/platforms/xlib/qglxintegration.h b/src/plugins/platforms/xlib/qglxintegration.h index cf6b006..57c716b 100644 --- a/src/plugins/platforms/xlib/qglxintegration.h +++ b/src/plugins/platforms/xlib/qglxintegration.h @@ -76,8 +76,6 @@ private: QPlatformWindowFormat m_windowFormat; QGLXContext (QXlibScreen *screen, Drawable drawable, GLXContext context); - static QMutex m_defaultSharedContextMutex; - static void createDefaultSharedContext(QXlibScreen *xd); }; QT_END_NAMESPACE |