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>
(cherry picked from commit f13d0078d9f829cde2cd5b8b9eac40635a883ec6)
This commit is contained in:
Samuel Rødal 2012-01-17 09:05:38 +01:00 committed by Qt by Nokia
parent 147bbda067
commit 82340ea5cd
4 changed files with 15 additions and 11 deletions

View File

@ -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

View File

@ -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);

View File

@ -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
@ -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);

View File

@ -40,6 +40,7 @@
****************************************************************************/
#include "qgl_p.h"
#include <qglframebufferobject.h>
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;