From b1d187399b79b980bc49cb9f78320466da54f977 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Fri, 16 Apr 2010 06:42:09 +0200 Subject: Don't resolve geometry shaders every time... This was a huge extra cost in all QPainter::begin's on GL target surfaces Reviewed-by: Rhys Weatherley --- src/opengl/qglextensions.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/opengl/qglextensions.cpp b/src/opengl/qglextensions.cpp index ef3c4cd..8e2bbd4 100644 --- a/src/opengl/qglextensions.cpp +++ b/src/opengl/qglextensions.cpp @@ -235,11 +235,6 @@ bool qt_resolve_eglimage_gl_extensions(QGLContext *ctx) bool qt_resolve_glsl_extensions(QGLContext *ctx) { - // Geometry shaders are optional... - glProgramParameteriEXT = (_glProgramParameteriEXT) ctx->getProcAddress(QLatin1String("glProgramParameteriEXT")); - glFramebufferTextureEXT = (_glFramebufferTextureEXT) ctx->getProcAddress(QLatin1String("glFramebufferTextureEXT")); - glFramebufferTextureLayerEXT = (_glFramebufferTextureLayerEXT) ctx->getProcAddress(QLatin1String("glFramebufferTextureLayerEXT")); - glFramebufferTextureFaceEXT = (_glFramebufferTextureFaceEXT) ctx->getProcAddress(QLatin1String("glFramebufferTextureFaceEXT")); #if defined(QT_OPENGL_ES_2) // The GLSL shader functions are always present in OpenGL/ES 2.0. @@ -254,6 +249,12 @@ bool qt_resolve_glsl_extensions(QGLContext *ctx) if (glCreateShader) return true; + // Geometry shaders are optional... + glProgramParameteriEXT = (_glProgramParameteriEXT) ctx->getProcAddress(QLatin1String("glProgramParameteriEXT")); + glFramebufferTextureEXT = (_glFramebufferTextureEXT) ctx->getProcAddress(QLatin1String("glFramebufferTextureEXT")); + glFramebufferTextureLayerEXT = (_glFramebufferTextureLayerEXT) ctx->getProcAddress(QLatin1String("glFramebufferTextureLayerEXT")); + glFramebufferTextureFaceEXT = (_glFramebufferTextureFaceEXT) ctx->getProcAddress(QLatin1String("glFramebufferTextureFaceEXT")); + glCreateShader = (_glCreateShader) ctx->getProcAddress(QLatin1String("glCreateShader")); if (glCreateShader) { glShaderSource = (_glShaderSource) ctx->getProcAddress(QLatin1String("glShaderSource")); -- cgit v0.12 From edc6e0218b5fad73476f1f18529b5ec48a3e100f Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Mon, 19 Apr 2010 07:25:15 +0200 Subject: Swapped x and y values in qt_painterpath_check_crossing Reviewed-by: Kim --- src/gui/painting/qpainterpath.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/painting/qpainterpath.cpp b/src/gui/painting/qpainterpath.cpp index f78de34..965b84c 100644 --- a/src/gui/painting/qpainterpath.cpp +++ b/src/gui/painting/qpainterpath.cpp @@ -1914,7 +1914,7 @@ static bool qt_painterpath_check_crossing(const QPainterPath *path, const QRectF case QPainterPath::MoveToElement: if (i > 0 - && qFuzzyCompare(last_pt.x(), last_start.y()) + && qFuzzyCompare(last_pt.x(), last_start.x()) && qFuzzyCompare(last_pt.y(), last_start.y()) && qt_painterpath_isect_line_rect(last_pt.x(), last_pt.y(), last_start.x(), last_start.y(), rect)) -- cgit v0.12 From c799eeffc43a186747f06a7d36a747cce59925dd Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Mon, 19 Apr 2010 07:26:44 +0200 Subject: Don't crash when calling drawPixmapFragements with a null pixmap --- src/gui/painting/qpaintengineex.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/gui/painting/qpaintengineex.cpp b/src/gui/painting/qpaintengineex.cpp index 9366513..a78cafb 100644 --- a/src/gui/painting/qpaintengineex.cpp +++ b/src/gui/painting/qpaintengineex.cpp @@ -974,6 +974,9 @@ void QPaintEngineEx::drawTiledPixmap(const QRectF &r, const QPixmap &pixmap, con void QPaintEngineEx::drawPixmapFragments(const QPainter::PixmapFragment *fragments, int fragmentCount, const QPixmap &pixmap, QPainter::PixmapFragmentHints /*hints*/) { + if (pixmap.isNull()) + return; + qreal oldOpacity = state()->opacity; QTransform oldTransform = state()->matrix; -- cgit v0.12 From 8fffbc7768be28fb2b31727bf79b2e2357ce9814 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Mon, 19 Apr 2010 10:17:30 +0200 Subject: Use QGLContextPrivate to track attribarray enabled state. Reviewed-by: Trond Reviewed-by: Tom --- src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index c89d34f..955a129 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -573,9 +573,9 @@ void QGL2PaintEngineExPrivate::resetGLState() glStencilMask(0xff); glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); glStencilFunc(GL_ALWAYS, 0, 0xff); - glDisableVertexAttribArray(QT_TEXTURE_COORDS_ATTR); - glDisableVertexAttribArray(QT_VERTEX_COORDS_ATTR); - glDisableVertexAttribArray(QT_OPACITY_ATTR); + ctx->d_func()->setVertexAttribArrayEnabled(QT_TEXTURE_COORDS_ATTR, false); + ctx->d_func()->setVertexAttribArrayEnabled(QT_VERTEX_COORDS_ATTR, false); + ctx->d_func()->setVertexAttribArrayEnabled(QT_OPACITY_ATTR, false); #ifndef QT_OPENGL_ES_2 glColor4f(1.0f, 1.0f, 1.0f, 1.0f); // color may have been changed by glVertexAttrib() #endif -- cgit v0.12 From 5ce428cf7f20cd37f4cf0d92ddcceddd07c5a0db Mon Sep 17 00:00:00 2001 From: Tom Cooksey Date: Fri, 16 Apr 2010 18:20:37 +0200 Subject: QX11GL: Fix bug with pixmaps drawn on multiple top-levels Reviewed-By: TrustMe --- src/opengl/qpixmapdata_x11gl_egl.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/opengl/qpixmapdata_x11gl_egl.cpp b/src/opengl/qpixmapdata_x11gl_egl.cpp index 3ab385a..4d726b6 100644 --- a/src/opengl/qpixmapdata_x11gl_egl.cpp +++ b/src/opengl/qpixmapdata_x11gl_egl.cpp @@ -66,7 +66,8 @@ QT_BEGIN_NAMESPACE // different contexts: Q_GLOBAL_STATIC(QEglContext, qt_x11gl_rgbContext); -Q_GLOBAL_STATIC(QEglContext, qt_x11gl_argbContext) +Q_GLOBAL_STATIC(QEglContext, qt_x11gl_argbContext); +Q_GLOBAL_STATIC_WITH_ARGS(QGLContext, qt_x11gl_fake_shared_context, (QX11GLPixmapData::glFormat())); QEglContext* QX11GLPixmapData::rgbContext = 0; QEglContext* QX11GLPixmapData::argbContext = 0; @@ -112,7 +113,13 @@ bool QX11GLPixmapData::hasX11GLPixmaps() if (!argbContext) { argbContext = qt_x11gl_argbContext(); argbContext->setConfig(argbConfig); - argbContext->createContext(); + bool success = argbContext->createContext(rgbContext); + if (!success) { + qWarning("QX11GLPixmapData - RGB & ARGB contexts aren't shared"); + success = argbContext->createContext(); + if (!success) + argbContext = rgbContext; // Might work, worth a shot at least. + } } if (!argbContext->isValid()) @@ -258,6 +265,14 @@ QPaintEngine* QX11GLPixmapData::paintEngine() const ctx = new QGLContext(glFormat()); Q_ASSERT(ctx->d_func()->eglContext == 0); ctx->d_func()->eglContext = hasAlphaChannel() ? argbContext : rgbContext; + + // While we use a seperate QGLContext for each pixmap, the underlying QEglContext is + // the same. So we must use a "fake" QGLContext and fool the texture cache into thinking + // each pixmap's QGLContext is sharing with this central one. The only place this is + // going to fail is where we the underlying EGL RGB and ARGB contexts aren't sharing. + ctx->d_func()->sharing = true; + QGLContextGroup::addShare(ctx, qt_x11gl_fake_shared_context()); + // Update the glFormat for the QGLContext: qt_glformat_from_eglconfig(ctx->d_func()->glFormat, ctx->d_func()->eglContext->config()); } -- cgit v0.12 From bce9c47d5437812b137c47ff3c602ff23ffa5e22 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Mon, 19 Apr 2010 10:27:29 +0200 Subject: Mac: Fix off-by-one in vertical position for elided and non-elided text In the code path that draws the elided text, we would truncate the position before passing it to the painter. With a font engine that supports fractional values (mac), this would potentially give us the wrong position compared to the code path that draws the complete text, which essentially rounds off the number. The result was that when you resized the width an item view to make its items elide the text, then they would potentially shift up or down by one pixel. Task-number: QTBUG-9879 Reviewed-by: Gunnar --- src/gui/styles/qcommonstyle.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/styles/qcommonstyle.cpp b/src/gui/styles/qcommonstyle.cpp index b0e2d37..8036728 100644 --- a/src/gui/styles/qcommonstyle.cpp +++ b/src/gui/styles/qcommonstyle.cpp @@ -981,7 +981,7 @@ void QCommonStylePrivate::viewItemDrawText(QPainter *p, const QStyleOptionViewIt qreal y = position.y() + line.y() + line.ascent(); p->save(); p->setFont(option->font); - p->drawText(int(x), int(y), elidedText); + p->drawText(QPointF(x, y), elidedText); p->restore(); break; } -- cgit v0.12