summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSamuel Rødal <samuel.rodal@nokia.com>2012-01-16 12:32:30 (GMT)
committerQt by Nokia <qt-info@nokia.com>2012-01-16 14:35:41 (GMT)
commitf13d0078d9f829cde2cd5b8b9eac40635a883ec6 (patch)
tree604fea39adcc3722443559934590c8d2bebdb38c
parentb1916b524b0d076dfc9fad2656d65493067b1b84 (diff)
downloadQt-f13d0078d9f829cde2cd5b8b9eac40635a883ec6.zip
Qt-f13d0078d9f829cde2cd5b8b9eac40635a883ec6.tar.gz
Qt-f13d0078d9f829cde2cd5b8b9eac40635a883ec6.tar.bz2
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 <kim.kalland@nokia.com>
-rw-r--r--src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp10
-rw-r--r--src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp6
-rw-r--r--src/opengl/gl2paintengineex/qtextureglyphcache_gl_p.h8
-rw-r--r--src/opengl/qglextensions.cpp4
4 files changed, 16 insertions, 12 deletions
diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
index 323b0c0..89a7264 100644
--- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
+++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
@@ -1455,7 +1455,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))
{
@@ -1518,7 +1519,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))
{
@@ -2139,7 +2141,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 571f482..ac11641 100644
--- a/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp
+++ b/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp
@@ -111,7 +111,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.
@@ -166,7 +166,7 @@ void QGLTextureGlyphCache::resizeTextureData(int width, int height)
GLuint oldTexture = glyphTexture->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());
@@ -286,7 +286,7 @@ void QGLTextureGlyphCache::fillTexture(const Coord &c, glyph_t glyph, QFixed sub
}
QGLGlyphTexture *glyphTexture = m_textureResource.value(ctx);
- if (ctx->d_ptr->workaround_brokenFBOReadBack) {
+ if (!QGLFramebufferObject::hasOpenGLFramebufferObjects() || ctx->d_ptr->workaround_brokenFBOReadBack) {
QImageTextureGlyphCache::fillTexture(c, glyph, subPixelPosition);
glBindTexture(GL_TEXTURE_2D, glyphTexture->m_texture);
diff --git a/src/opengl/gl2paintengineex/qtextureglyphcache_gl_p.h b/src/opengl/gl2paintengineex/qtextureglyphcache_gl_p.h
index bb34efb..c5a8857 100644
--- a/src/opengl/gl2paintengineex/qtextureglyphcache_gl_p.h
+++ b/src/opengl/gl2paintengineex/qtextureglyphcache_gl_p.h
@@ -56,6 +56,7 @@
#include <private/qtextureglyphcache_p.h>
#include <private/qgl_p.h>
#include <qglshaderprogram.h>
+#include <qglframebufferobject.h>
// #define QT_GL_TEXTURE_GLYPH_CACHE_DEBUG
@@ -66,10 +67,11 @@ class QGL2PaintEngineExPrivate;
struct QGLGlyphTexture
{
QGLGlyphTexture(const QGLContext *ctx)
- : m_width(0)
+ : 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
@@ -85,7 +87,7 @@ struct QGLGlyphTexture
// At this point, the context group is made current, so it's safe to
// release resources without a makeCurrent() call
if (ctx) {
- 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 c955728..60f7055 100644
--- a/src/opengl/qglextensions.cpp
+++ b/src/opengl/qglextensions.cpp
@@ -40,6 +40,7 @@
****************************************************************************/
#include "qgl_p.h"
+#include <qglframebufferobject.h>
QT_BEGIN_NAMESPACE
@@ -418,9 +419,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;