From 82340ea5cd148253eb07877468bf3c8873f90e56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Tue, 17 Jan 2012 09:05:38 +0100 Subject: Fixed crash in GL 2 paint engine on Intel Atom. The GPU in question supports GL 2 but not framebuffer objects. Since we anyway have a font rendering path that doesn't use FBOs we might as well not require framebuffer objects in order to use the GL 2 engine. Task-number: QTBUG-22483 Change-Id: I2a80343fedda276e73e603ffe54edff58801af5b Reviewed-by: Kim M. Kalland (cherry picked from commit f13d0078d9f829cde2cd5b8b9eac40635a883ec6) --- src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp | 10 +++++++--- src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp | 6 +++--- src/opengl/gl2paintengineex/qtextureglyphcache_gl_p.h | 6 ++++-- src/opengl/qglextensions.cpp | 4 +--- 4 files changed, 15 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index 85773fa3cc..04ccb6fc01 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -1438,7 +1438,8 @@ void QGL2PaintEngineEx::drawStaticTextItem(QStaticTextItem *textItem) ? QFontEngineGlyphCache::Type(textItem->fontEngine()->glyphFormat) : d->glyphCacheType; if (glyphType == QFontEngineGlyphCache::Raster_RGBMask) { - if (d->device->alphaRequested() || s->matrix.type() > QTransform::TxTranslate + if (!QGLFramebufferObject::hasOpenGLFramebufferObjects() + || d->device->alphaRequested() || s->matrix.type() > QTransform::TxTranslate || (s->composition_mode != QPainter::CompositionMode_Source && s->composition_mode != QPainter::CompositionMode_SourceOver)) { @@ -1500,7 +1501,8 @@ void QGL2PaintEngineEx::drawTextItem(const QPointF &p, const QTextItem &textItem if (glyphType == QFontEngineGlyphCache::Raster_RGBMask) { - if (d->device->alphaRequested() || txtype > QTransform::TxTranslate + if (!QGLFramebufferObject::hasOpenGLFramebufferObjects() + || d->device->alphaRequested() || txtype > QTransform::TxTranslate || (state()->composition_mode != QPainter::CompositionMode_Source && state()->composition_mode != QPainter::CompositionMode_SourceOver)) { @@ -1980,7 +1982,9 @@ bool QGL2PaintEngineEx::begin(QPaintDevice *pdev) #if !defined(QT_OPENGL_ES_2) bool success = qt_resolve_version_2_0_functions(d->ctx) - && qt_resolve_buffer_extensions(d->ctx); + && qt_resolve_buffer_extensions(d->ctx) + && (!QGLFramebufferObject::hasOpenGLFramebufferObjects() + || qt_resolve_framebufferobject_extensions(d->ctx)); Q_ASSERT(success); Q_UNUSED(success); #endif diff --git a/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp b/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp index c3f0257100..904612e2aa 100644 --- a/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp +++ b/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp @@ -96,7 +96,7 @@ void QGLTextureGlyphCache::createTextureData(int width, int height) // create in QImageTextureGlyphCache baseclass is meant to be called // only to create the initial image and does not preserve the content, // so we don't call when this function is called from resize. - if (ctx->d_ptr->workaround_brokenFBOReadBack && image().isNull()) + if ((!QGLFramebufferObject::hasOpenGLFramebufferObjects() || ctx->d_ptr->workaround_brokenFBOReadBack) && image().isNull()) QImageTextureGlyphCache::createTextureData(width, height); // Make the lower glyph texture size 16 x 16. @@ -156,7 +156,7 @@ void QGLTextureGlyphCache::resizeTextureData(int width, int height) GLuint oldTexture = m_textureResource->m_texture; createTextureData(width, height); - if (ctx->d_ptr->workaround_brokenFBOReadBack) { + if (!QGLFramebufferObject::hasOpenGLFramebufferObjects() || ctx->d_ptr->workaround_brokenFBOReadBack) { QImageTextureGlyphCache::resizeTextureData(width, height); Q_ASSERT(image().depth() == 8); glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width, oldHeight, GL_ALPHA, GL_UNSIGNED_BYTE, image().constBits()); @@ -276,7 +276,7 @@ void QGLTextureGlyphCache::fillTexture(const Coord &c, glyph_t glyph, QFixed sub return; } - if (ctx->d_ptr->workaround_brokenFBOReadBack) { + if (!QGLFramebufferObject::hasOpenGLFramebufferObjects() || ctx->d_ptr->workaround_brokenFBOReadBack) { QImageTextureGlyphCache::fillTexture(c, glyph, subPixelPosition); glBindTexture(GL_TEXTURE_2D, m_textureResource->m_texture); diff --git a/src/opengl/gl2paintengineex/qtextureglyphcache_gl_p.h b/src/opengl/gl2paintengineex/qtextureglyphcache_gl_p.h index ca5832ca4a..4314aa9841 100644 --- a/src/opengl/gl2paintengineex/qtextureglyphcache_gl_p.h +++ b/src/opengl/gl2paintengineex/qtextureglyphcache_gl_p.h @@ -56,6 +56,7 @@ #include #include #include +#include // #define QT_GL_TEXTURE_GLYPH_CACHE_DEBUG @@ -67,10 +68,11 @@ struct QGLGlyphTexture : public QOpenGLSharedResource { QGLGlyphTexture(const QGLContext *ctx) : QOpenGLSharedResource(ctx->contextHandle()->shareGroup()) + , m_fbo(0) , m_width(0) , m_height(0) { - if (ctx && !ctx->d_ptr->workaround_brokenFBOReadBack) + if (ctx && QGLFramebufferObject::hasOpenGLFramebufferObjects() && !ctx->d_ptr->workaround_brokenFBOReadBack) glGenFramebuffers(1, &m_fbo); #ifdef QT_GL_TEXTURE_GLYPH_CACHE_DEBUG @@ -84,7 +86,7 @@ struct QGLGlyphTexture : public QOpenGLSharedResource #ifdef QT_GL_TEXTURE_GLYPH_CACHE_DEBUG qDebug("~QGLGlyphTexture() %p for context %p.", this, ctx); #endif - if (!ctx->d_ptr->workaround_brokenFBOReadBack) + if (m_fbo) glDeleteFramebuffers(1, &m_fbo); if (m_width || m_height) glDeleteTextures(1, &m_texture); diff --git a/src/opengl/qglextensions.cpp b/src/opengl/qglextensions.cpp index 34196b6181..6cf0879d64 100644 --- a/src/opengl/qglextensions.cpp +++ b/src/opengl/qglextensions.cpp @@ -40,6 +40,7 @@ ****************************************************************************/ #include "qgl_p.h" +#include QT_BEGIN_NAMESPACE @@ -397,9 +398,6 @@ bool qt_resolve_version_2_0_functions(QGLContext *ctx) if (!qt_resolve_version_1_3_functions(ctx)) gl2supported = false; - if (!qt_resolve_framebufferobject_extensions(ctx)) - gl2supported = false; - if (glStencilOpSeparate) return gl2supported; -- cgit v1.2.3