diff options
author | Martin Smith <msmith@trolltech.com> | 2010-04-27 08:45:30 (GMT) |
---|---|---|
committer | Martin Smith <msmith@trolltech.com> | 2010-04-27 08:45:30 (GMT) |
commit | 9cea45515ef283c9a870c6f515da50d31addafcf (patch) | |
tree | d14fdf2b17a2a52c90ac514c39ad60be200cc7d7 /src/opengl | |
parent | 6749edd4c6f647c4963793183a452bb1ae769c1c (diff) | |
parent | 13dff164d2ab13b1258d31693b67acebc8636890 (diff) | |
download | Qt-9cea45515ef283c9a870c6f515da50d31addafcf.zip Qt-9cea45515ef283c9a870c6f515da50d31addafcf.tar.gz Qt-9cea45515ef283c9a870c6f515da50d31addafcf.tar.bz2 |
Merge branch '4.7' of git@scm.dev.nokia.troll.no:qt/oslo-staging-1 into 4.7
Diffstat (limited to 'src/opengl')
-rw-r--r-- | src/opengl/qgl_x11egl.cpp | 1 | ||||
-rw-r--r-- | src/opengl/qgraphicssystem_gl.cpp | 22 | ||||
-rw-r--r-- | src/opengl/qgraphicssystem_gl_p.h | 4 | ||||
-rw-r--r-- | src/opengl/qpixmapdata_x11gl_egl.cpp | 23 | ||||
-rw-r--r-- | src/opengl/qwindowsurface_gl.cpp | 11 |
5 files changed, 37 insertions, 24 deletions
diff --git a/src/opengl/qgl_x11egl.cpp b/src/opengl/qgl_x11egl.cpp index c0b1515..9d28de0 100644 --- a/src/opengl/qgl_x11egl.cpp +++ b/src/opengl/qgl_x11egl.cpp @@ -351,7 +351,6 @@ void QGLWidgetPrivate::recreateEglSurface() } if (glcx->d_func()->eglSurface == EGL_NO_SURFACE) { - qDebug("Re-creating the surface"); glcx->d_func()->eglSurface = glcx->d_func()->eglContext->createSurface(q); eglSurfaceWindowId = currentId; } diff --git a/src/opengl/qgraphicssystem_gl.cpp b/src/opengl/qgraphicssystem_gl.cpp index a282e4c..58cc28a 100644 --- a/src/opengl/qgraphicssystem_gl.cpp +++ b/src/opengl/qgraphicssystem_gl.cpp @@ -40,6 +40,7 @@ ****************************************************************************/ #include "qgraphicssystem_gl_p.h" +#include <QGraphicsView> #include "private/qpixmap_raster_p.h" #include "private/qpixmapdata_gl_p.h" @@ -47,7 +48,7 @@ #include "private/qgl_p.h" #include <private/qwindowsurface_raster_p.h> -#if defined(Q_WS_X11) && defined(QT_OPENGL_ES) +#if defined(Q_WS_X11) && !defined(QT_NO_EGL) #include "private/qpixmapdata_x11gl_p.h" #include "private/qwindowsurface_x11gl_p.h" #endif @@ -58,10 +59,6 @@ extern QGLWidget *qt_gl_getShareWidget(); QPixmapData *QGLGraphicsSystem::createPixmapData(QPixmapData::PixelType type) const { -#if defined(Q_WS_X11) && defined(QT_OPENGL_ES) - if (type == QPixmapData::PixmapType && QX11GLPixmapData::hasX11GLPixmaps()) - return new QX11GLPixmapData(); -#endif return new QGLPixmapData(type); } @@ -75,9 +72,18 @@ QWindowSurface *QGLGraphicsSystem::createWindowSurface(QWidget *widget) const return new QRasterWindowSurface(widget); #endif -#if defined(Q_WS_X11) && defined(QT_OPENGL_ES) - if (QX11GLPixmapData::hasX11GLPixmaps()) - return new QX11GLWindowSurface(widget); +#if defined(Q_WS_X11) && !defined(QT_NO_EGL) + if (m_useX11GL && QX11GLPixmapData::hasX11GLPixmaps()) { + // If the widget is a QGraphicsView which will be re-drawing the entire + // scene each frame anyway, we should use QGLWindowSurface as this may + // provide proper buffer flipping, which should be faster than QX11GL's + // blitting approach: + QGraphicsView* qgv = qobject_cast<QGraphicsView*>(widget); + if (qgv && qgv->viewportUpdateMode() == QGraphicsView::FullViewportUpdate) + return new QGLWindowSurface(widget); + else + return new QX11GLWindowSurface(widget); + } #endif return new QGLWindowSurface(widget); diff --git a/src/opengl/qgraphicssystem_gl_p.h b/src/opengl/qgraphicssystem_gl_p.h index ff47854..9d2d506 100644 --- a/src/opengl/qgraphicssystem_gl_p.h +++ b/src/opengl/qgraphicssystem_gl_p.h @@ -62,10 +62,12 @@ QT_BEGIN_NAMESPACE class Q_OPENGL_EXPORT QGLGraphicsSystem : public QGraphicsSystem { public: - QGLGraphicsSystem(); + QGLGraphicsSystem(bool useX11GL); QPixmapData *createPixmapData(QPixmapData::PixelType type) const; QWindowSurface *createWindowSurface(QWidget *widget) const; +private: + bool m_useX11GL; }; QT_END_NAMESPACE diff --git a/src/opengl/qpixmapdata_x11gl_egl.cpp b/src/opengl/qpixmapdata_x11gl_egl.cpp index 58d34fc..2c11a0b 100644 --- a/src/opengl/qpixmapdata_x11gl_egl.cpp +++ b/src/opengl/qpixmapdata_x11gl_egl.cpp @@ -74,7 +74,6 @@ public: EGLint rgbConfigId; EGLint argbConfigId; - do { EGLConfig rgbConfig = QEgl::defaultConfig(QInternal::Pixmap, QEgl::OpenGL, QEgl::Renderable); EGLConfig argbConfig = QEgl::defaultConfig(QInternal::Pixmap, QEgl::OpenGL, @@ -138,6 +137,7 @@ public: valid = argbContext->makeCurrent(argbPixmapSurface); argbContext->doneCurrent(); eglDestroySurface(QEgl::display(), argbPixmapSurface); + argbPixmapData->gl_surface = 0; } if (!valid) { @@ -150,7 +150,6 @@ public: QGLTextureCache::instance(); } while(0); - if (!valid) cleanup(); else @@ -158,6 +157,10 @@ public: } + ~QX11GLSharedContexts() { + cleanup(); + } + void cleanup() { if (sharedQGLContext) { delete sharedQGLContext; @@ -216,18 +219,16 @@ QX11GLSharedContexts* QX11GLPixmapData::sharedContexts() bool QX11GLPixmapData::hasX11GLPixmaps() { - static bool checkedForX11Pixmaps = false; - static bool haveX11Pixmaps = false; - - if (checkedForX11Pixmaps) - return haveX11Pixmaps; + static bool checkedForX11GLPixmaps = false; + static bool haveX11GLPixmaps = false; - checkedForX11Pixmaps = true; + if (checkedForX11GLPixmaps) + return haveX11GLPixmaps; - if (!qgetenv("QT_USE_X11GL_PIXMAPS").isEmpty() && sharedContexts()->isValid()) - haveX11Pixmaps = true; + haveX11GLPixmaps = qt_x11gl_share_contexts()->isValid(); + checkedForX11GLPixmaps = true; - return haveX11Pixmaps; + return haveX11GLPixmaps; } QX11GLPixmapData::QX11GLPixmapData() diff --git a/src/opengl/qwindowsurface_gl.cpp b/src/opengl/qwindowsurface_gl.cpp index b693245..92a347b 100644 --- a/src/opengl/qwindowsurface_gl.cpp +++ b/src/opengl/qwindowsurface_gl.cpp @@ -82,7 +82,7 @@ #define GLX_SAMPLES_ARB 100001 #endif -#ifdef QT_OPENGL_ES +#ifndef QT_NO_EGL #include <private/qeglcontext_p.h> #endif @@ -94,8 +94,8 @@ QT_BEGIN_NAMESPACE #ifdef Q_WS_WIN extern Q_GUI_EXPORT bool qt_win_owndc_required; #endif -QGLGraphicsSystem::QGLGraphicsSystem() - : QGraphicsSystem() +QGLGraphicsSystem::QGLGraphicsSystem(bool useX11GL) + : QGraphicsSystem(), m_useX11GL(useX11GL) { QGLWindowSurface::surfaceFormat.setSampleBuffers(true); #if defined(Q_WS_X11) && !defined(QT_OPENGL_ES) @@ -354,6 +354,11 @@ void QGLWindowSurface::hijackWindow(QWidget *widget) QGLContext *ctx = new QGLContext(surfaceFormat, widget); ctx->create(qt_gl_share_widget()->context()); +#ifndef QT_NO_EGL + if (ctx->d_func()->eglContext->configAttrib(EGL_SWAP_BEHAVIOR) != EGL_BUFFER_PRESERVED) + setPartialUpdateSupport(false); // Force full-screen updates +#endif + widgetPrivate->extraData()->glContext = ctx; union { QGLContext **ctxPtr; void **voidPtr; }; |