diff options
author | Qt Continuous Integration System <qt-info@nokia.com> | 2010-03-10 11:18:09 (GMT) |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2010-03-10 11:18:09 (GMT) |
commit | 504fb8a30ffef1f90a4cd4d61ab7f73c95fd9a03 (patch) | |
tree | ac7456cb14db561af960a579a1608d043c905c54 | |
parent | 12d63b05a942281e688d857d17c190564c77b698 (diff) | |
parent | 66e22b5b65b09cf4824dbfbc91e8dea04e8e4214 (diff) | |
download | Qt-504fb8a30ffef1f90a4cd4d61ab7f73c95fd9a03.zip Qt-504fb8a30ffef1f90a4cd4d61ab7f73c95fd9a03.tar.gz Qt-504fb8a30ffef1f90a4cd4d61ab7f73c95fd9a03.tar.bz2 |
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-2 into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-2:
MAke the SIMD fiunctions be used even when the QT_NO_DEBUG macro is used
Make sure 16-bit EGL configs are chosen over 32-bit configs
Make the EGL contexts in QX11GLPixmapData Q_GLOBAL_STATIC
Handle EGLSurfaces better, including more error detection
Make sure pixmap hooks get installed so EGL surfaces are cleaned up
Don't show resize cursor for fixed-size windows
-rw-r--r-- | src/gui/egl/qegl.cpp | 7 | ||||
-rw-r--r-- | src/gui/egl/qegl_x11.cpp | 2 | ||||
-rw-r--r-- | src/gui/embedded/qwsmanager_qws.cpp | 6 | ||||
-rw-r--r-- | src/gui/image/qpixmap_x11_p.h | 2 | ||||
-rw-r--r-- | src/gui/painting/qdrawhelper.cpp | 3 | ||||
-rw-r--r-- | src/opengl/qgl_egl.cpp | 83 | ||||
-rw-r--r-- | src/opengl/qgl_x11.cpp | 2 | ||||
-rw-r--r-- | src/opengl/qgl_x11egl.cpp | 12 | ||||
-rw-r--r-- | src/opengl/qpixmapdata_x11gl_egl.cpp | 30 |
9 files changed, 97 insertions, 50 deletions
diff --git a/src/gui/egl/qegl.cpp b/src/gui/egl/qegl.cpp index 485bfbf..6e0331f 100644 --- a/src/gui/egl/qegl.cpp +++ b/src/gui/egl/qegl.cpp @@ -392,6 +392,11 @@ bool QEglContext::makeCurrent(EGLSurface surface) return false; } + if (surface == EGL_NO_SURFACE) { + qWarning() << "QEglContext::makeCurrent(): Cannot make invalid surface current"; + return false; + } + // If lazyDoneCurrent() was called on the surface, then we may be able // to assume that it is still current within the thread. if (surface == currentSurface && currentContext(apiType) == this) { @@ -417,7 +422,7 @@ bool QEglContext::makeCurrent(EGLSurface surface) bool ok = eglMakeCurrent(QEgl::display(), surface, surface, ctx); if (!ok) - qWarning() << "QEglContext::makeCurrent():" << QEgl::errorString(); + qWarning() << "QEglContext::makeCurrent(" << surface << "):" << QEgl::errorString(); return ok; } diff --git a/src/gui/egl/qegl_x11.cpp b/src/gui/egl/qegl_x11.cpp index 53c4711..91423c8 100644 --- a/src/gui/egl/qegl_x11.cpp +++ b/src/gui/egl/qegl_x11.cpp @@ -408,7 +408,7 @@ EGLSurface QEgl::createSurface(QPaintDevice *device, EGLConfig config, const QEg EGLSurface surf = eglCreatePixmapSurface(QEgl::display(), config, (EGLNativePixmapType) x11PixmapData->handle(), surfaceAttribs.properties()); - x11PixmapData->gl_surface = (Qt::HANDLE)surf; + x11PixmapData->gl_surface = (void*)surf; QImagePixmapCleanupHooks::enableCleanupHooks(x11PixmapData); return surf; } diff --git a/src/gui/embedded/qwsmanager_qws.cpp b/src/gui/embedded/qwsmanager_qws.cpp index d6ef148..79076c5 100644 --- a/src/gui/embedded/qwsmanager_qws.cpp +++ b/src/gui/embedded/qwsmanager_qws.cpp @@ -267,8 +267,10 @@ void QWSManager::mouseMoveEvent(QMouseEvent *e) #ifndef QT_NO_CURSOR - QWSDisplay *qwsd = QApplication::desktop()->qwsDisplay(); - qwsd->selectCursor(d->managed, regionToShape(d->cachedRegionAt())); + if (d->managed->minimumSize() != d->managed->maximumSize()) { + QWSDisplay *qwsd = QApplication::desktop()->qwsDisplay(); + qwsd->selectCursor(d->managed, regionToShape(d->cachedRegionAt())); + } #endif //QT_NO_CURSOR if (d->activeRegion) diff --git a/src/gui/image/qpixmap_x11_p.h b/src/gui/image/qpixmap_x11_p.h index 521a612..7575838 100644 --- a/src/gui/image/qpixmap_x11_p.h +++ b/src/gui/image/qpixmap_x11_p.h @@ -94,7 +94,7 @@ public: static Qt::HANDLE createBitmapFromImage(const QImage &image); - Qt::HANDLE gl_surface; + void* gl_surface; #ifndef QT_NO_XRENDER void convertToARGB32(bool preserveContents = true); #endif diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp index 5f70cb7..581b538 100644 --- a/src/gui/painting/qdrawhelper.cpp +++ b/src/gui/painting/qdrawhelper.cpp @@ -7820,7 +7820,6 @@ void qInitDrawhelperAsm() CompositionFunction *functionForModeAsm = 0; CompositionFunctionSolid *functionForModeSolidAsm = 0; -#ifdef QT_NO_DEBUG const uint features = qDetectCPUFeatures(); if (false) { #ifdef QT_HAVE_SSE2 @@ -7944,8 +7943,6 @@ void qInitDrawhelperAsm() } #endif // IWMMXT -#endif // QT_NO_DEBUG - #if defined(Q_CC_RVCT) && defined(QT_HAVE_ARMV6) functionForModeAsm = qt_functionForMode_ARMv6; functionForModeSolidAsm = qt_functionForModeSolid_ARMv6; diff --git a/src/opengl/qgl_egl.cpp b/src/opengl/qgl_egl.cpp index 91b271b..3d146b7 100644 --- a/src/opengl/qgl_egl.cpp +++ b/src/opengl/qgl_egl.cpp @@ -53,35 +53,62 @@ QT_BEGIN_NAMESPACE void qt_eglproperties_set_glformat(QEglProperties& eglProperties, const QGLFormat& glFormat) { - // NOTE: QGLFormat uses a magic value of -1 to indicate "don't care", even when a buffer of that - // type has been requested. - if (glFormat.depth()) { - int depthSize = glFormat.depthBufferSize(); - eglProperties.setValue(EGL_DEPTH_SIZE, depthSize == -1 ? 1 : depthSize); + int redSize = glFormat.redBufferSize(); + int greenSize = glFormat.greenBufferSize(); + int blueSize = glFormat.blueBufferSize(); + int alphaSize = glFormat.alphaBufferSize(); + int depthSize = glFormat.depthBufferSize(); + int stencilSize = glFormat.stencilBufferSize(); + int sampleCount = glFormat.samples(); + + // QGLFormat uses a magic value of -1 to indicate "don't care", even when a buffer of that + // type has been requested. So we must check QGLFormat's booleans too if size is -1: + if (glFormat.alpha() && alphaSize <= 0) { + qDebug("QGLFormat::alpha() returned true"); + alphaSize = 1; } - if (glFormat.stencil()) { - int stencilSize = glFormat.stencilBufferSize(); - eglProperties.setValue(EGL_STENCIL_SIZE, stencilSize == -1 ? 1 : stencilSize); - } - if (glFormat.sampleBuffers()) { - int sampleCount = glFormat.samples(); - eglProperties.setValue(EGL_SAMPLES, sampleCount == -1 ? 1 : sampleCount); - eglProperties.setValue(EGL_SAMPLE_BUFFERS, 1); - } - if (glFormat.alpha()) { - int alphaSize = glFormat.alphaBufferSize(); - eglProperties.setValue(EGL_ALPHA_SIZE, alphaSize == -1 ? 1 : alphaSize); - } - - int redSize = glFormat.redBufferSize(); - int greenSize = glFormat.greenBufferSize(); - int blueSize = glFormat.blueBufferSize(); - int alphaSize = glFormat.alphaBufferSize(); - - eglProperties.setValue(EGL_RED_SIZE, redSize > 0 ? redSize : 1); - eglProperties.setValue(EGL_GREEN_SIZE, greenSize > 0 ? greenSize : 1); - eglProperties.setValue(EGL_BLUE_SIZE, blueSize > 0 ? blueSize : 1); - eglProperties.setValue(EGL_ALPHA_SIZE, alphaSize > 0 ? alphaSize : 0); + if (glFormat.depth() && depthSize <= 0) + depthSize = 1; + if (glFormat.stencil() && stencilSize <= 0) + stencilSize = 1; + if (glFormat.sampleBuffers() && sampleCount <= 0) + sampleCount = 1; + + // We want to make sure 16-bit configs are chosen over 32-bit configs as they will provide + // the best performance. The EGL config selection algorithm is a bit stange in this regard: + // The selection criteria for EGL_BUFFER_SIZE is "AtLeast", so we can't use it to discard + // 32-bit configs completely from the selection. So it then comes to the sorting algorithm. + // The red/green/blue sizes have a sort priority of 3, so they are sorted by first. The sort + // order is special and described as "by larger _total_ number of color bits.". So EGL will + // put 32-bit configs in the list before the 16-bit configs. However, the spec also goes on + // to say "If the requested number of bits in attrib_list for a particular component is 0, + // then the number of bits for that component is not considered". This part of the spec also + // seems to imply that setting the red/green/blue bits to zero means none of the components + // are considered and EGL disregards the entire sorting rule. It then looks to the next + // highest priority rule, which is EGL_BUFFER_SIZE. Despite the selection criteria being + // "AtLeast" for EGL_BUFFER_SIZE, it's sort order is "smaller" meaning 16-bit configs are + // put in the list before 32-bit configs. So, to make sure 16-bit is preffered over 32-bit, + // we must set the red/green/blue sizes to zero. This has an unfortunate consequence that + // if the application sets the red/green/blue size to 5/6/5 on the QGLFormat, they will + // probably get a 32-bit config, even when there's an RGB565 config avaliable. Oh well. + + // Now normalize the values so -1 becomes 0 + redSize = redSize > 0 ? redSize : 0; + greenSize = greenSize > 0 ? greenSize : 0; + blueSize = blueSize > 0 ? blueSize : 0; + alphaSize = alphaSize > 0 ? alphaSize : 0; + depthSize = depthSize > 0 ? depthSize : 0; + stencilSize = stencilSize > 0 ? stencilSize : 0; + sampleCount = sampleCount > 0 ? sampleCount : 0; + + eglProperties.setValue(EGL_RED_SIZE, redSize); + eglProperties.setValue(EGL_GREEN_SIZE, greenSize); + eglProperties.setValue(EGL_BLUE_SIZE, blueSize); + eglProperties.setValue(EGL_ALPHA_SIZE, alphaSize); + eglProperties.setValue(EGL_DEPTH_SIZE, depthSize); + eglProperties.setValue(EGL_STENCIL_SIZE, stencilSize); + eglProperties.setValue(EGL_SAMPLES, sampleCount); + eglProperties.setValue(EGL_SAMPLE_BUFFERS, sampleCount ? 1 : 0); } diff --git a/src/opengl/qgl_x11.cpp b/src/opengl/qgl_x11.cpp index f0b06ef5..4fa1467 100644 --- a/src/opengl/qgl_x11.cpp +++ b/src/opengl/qgl_x11.cpp @@ -1753,7 +1753,7 @@ QGLTexture *QGLContextPrivate::bindTextureFromNativePixmap(QPixmapData *pmd, con if (!glxPixmap) return 0; - pixmapData->gl_surface = (Qt::HANDLE)glxPixmap; + pixmapData->gl_surface = (void*)glxPixmap; // Make sure the cleanup hook gets called so we can delete the glx pixmap QImagePixmapCleanupHooks::enableCleanupHooks(pixmapData); diff --git a/src/opengl/qgl_x11egl.cpp b/src/opengl/qgl_x11egl.cpp index fdcc412..a7c92cf 100644 --- a/src/opengl/qgl_x11egl.cpp +++ b/src/opengl/qgl_x11egl.cpp @@ -198,10 +198,6 @@ bool QGLContext::chooseContext(const QGLContext* shareContext) configProps.setRenderableType(QEgl::OpenGL); qt_eglproperties_set_glformat(configProps, d->glFormat); - // Use EGL_BUFFER_SIZE to make sure we prefer a 16-bit config over a 32-bit config - if (device()->depth() == 16 && !d->glFormat.alpha()) - configProps.setValue(EGL_BUFFER_SIZE, 16); - if (!d->eglContext->chooseConfig(configProps, QEgl::BestPixelFormat)) { delete d->eglContext; d->eglContext = 0; @@ -243,7 +239,7 @@ bool QGLContext::chooseContext(const QGLContext* shareContext) if (x11PixmapData->gl_surface) eglDestroySurface(d->eglContext->display(), (EGLSurface)x11PixmapData->gl_surface); - x11PixmapData->gl_surface = (Qt::HANDLE)QEgl::createSurface(device(), d->eglContext->config()); + x11PixmapData->gl_surface = (void*)QEgl::createSurface(device(), d->eglContext->config()); } return true; @@ -404,8 +400,8 @@ QGLTexture *QGLContextPrivate::bindTextureFromNativePixmap(QPixmapData* pd, cons hasAlpha ? QEgl::Translucent : QEgl::NoOptions); QPixmap tmpPixmap(pixmapData); //### - pixmapData->gl_surface = (Qt::HANDLE)QEgl::createSurface(&tmpPixmap, config); - if (pixmapData->gl_surface == (Qt::HANDLE)EGL_NO_SURFACE) { + pixmapData->gl_surface = (void*)QEgl::createSurface(&tmpPixmap, config); + if (pixmapData->gl_surface == (void*)EGL_NO_SURFACE) { haveTFP = false; return 0; } @@ -423,7 +419,7 @@ QGLTexture *QGLContextPrivate::bindTextureFromNativePixmap(QPixmapData* pd, cons if (success == EGL_FALSE) { qWarning() << "eglBindTexImage() failed:" << QEgl::errorString(); eglDestroySurface(eglContext->display(), (EGLSurface)pixmapData->gl_surface); - pixmapData->gl_surface = (Qt::HANDLE)EGL_NO_SURFACE; + pixmapData->gl_surface = (void*)EGL_NO_SURFACE; haveTFP = false; return 0; } diff --git a/src/opengl/qpixmapdata_x11gl_egl.cpp b/src/opengl/qpixmapdata_x11gl_egl.cpp index 34915f5..d7fae16 100644 --- a/src/opengl/qpixmapdata_x11gl_egl.cpp +++ b/src/opengl/qpixmapdata_x11gl_egl.cpp @@ -61,6 +61,10 @@ QT_BEGIN_NAMESPACE // On 16bpp systems, RGB & ARGB pixmaps are different bit-depths and therefore need // different contexts: + +Q_GLOBAL_STATIC(QEglContext, qt_x11gl_rgbContext); +Q_GLOBAL_STATIC(QEglContext, qt_x11gl_argbContext) + QEglContext* QX11GLPixmapData::rgbContext = 0; QEglContext* QX11GLPixmapData::argbContext = 0; @@ -75,6 +79,9 @@ bool QX11GLPixmapData::hasX11GLPixmaps() checkedForX11Pixmaps = true; + EGLint rgbConfigId; + EGLint argbConfigId; + do { if (qgetenv("QT_USE_X11GL_PIXMAPS").isEmpty()) break; @@ -83,8 +90,11 @@ bool QX11GLPixmapData::hasX11GLPixmaps() EGLConfig argbConfig = QEgl::defaultConfig(QInternal::Pixmap, QEgl::OpenGL, QEgl::Renderable | QEgl::Translucent); + eglGetConfigAttrib(QEgl::display(), rgbConfig, EGL_CONFIG_ID, &rgbConfigId); + eglGetConfigAttrib(QEgl::display(), argbConfig, EGL_CONFIG_ID, &argbConfigId); + if (!rgbContext) { - rgbContext = new QEglContext; + rgbContext = qt_x11gl_rgbContext(); rgbContext->setConfig(rgbConfig); rgbContext->createContext(); } @@ -97,7 +107,7 @@ bool QX11GLPixmapData::hasX11GLPixmaps() argbContext = rgbContext; if (!argbContext) { - argbContext = new QEglContext; + argbContext = qt_x11gl_argbContext(); argbContext->setConfig(argbConfig); argbContext->createContext(); } @@ -138,6 +148,10 @@ bool QX11GLPixmapData::hasX11GLPixmaps() break; } } + + // The pixmap surface destruction hooks are installed by QGLTextureCache, so we + // must make sure this is instanciated: + QGLTextureCache::instance(); } while (0); if (!haveX11Pixmaps) { @@ -152,7 +166,7 @@ bool QX11GLPixmapData::hasX11GLPixmaps() } if (haveX11Pixmaps) - qDebug("QX11GLPixmapData is supported"); + qDebug("Using QX11GLPixmapData with EGL config %d for ARGB and config %d for RGB", argbConfigId, rgbConfigId); else qDebug("QX11GLPixmapData is *NOT* being used"); @@ -231,8 +245,14 @@ void QX11GLPixmapData::beginPaint() if ((EGLSurface)gl_surface == EGL_NO_SURFACE) { QPixmap tmpPixmap(this); EGLConfig cfg = ctx->d_func()->eglContext->config(); - gl_surface = (Qt::HANDLE)QEgl::createSurface(&tmpPixmap, cfg); - ctx->d_func()->eglSurface = (EGLSurface)gl_surface; + + EGLSurface surface = QEgl::createSurface(&tmpPixmap, cfg); + if (surface == EGL_NO_SURFACE) { + qWarning() << "Error creating EGL surface for pixmap:" << QEgl::errorString(); + return; + } + gl_surface = (void*)surface; + ctx->d_func()->eglSurface = surface; ctx->d_func()->valid = true; } QGLPaintDevice::beginPaint(); |