From f4d1db4ddb2339fdbf9d4c15a4eebcc1c55ad33a Mon Sep 17 00:00:00 2001 From: con Date: Tue, 5 Apr 2011 10:54:31 +0200 Subject: Fix QPA prerendered fonts in combination with GL paint engine. QPA uses the Indexed8 image format but stores 8 bit gray values in it. The OpenVG and Raster paint engines handle that, but the OpenGL engine didn't. Reviewed-by: Paul Olav Tvete --- src/opengl/qpaintengine_opengl.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/opengl/qpaintengine_opengl.cpp b/src/opengl/qpaintengine_opengl.cpp index 2c01ac4..9da811a 100644 --- a/src/opengl/qpaintengine_opengl.cpp +++ b/src/opengl/qpaintengine_opengl.cpp @@ -4736,7 +4736,7 @@ void QGLGlyphCache::cacheGlyphs(QGLContext *context, QFontEngine *fontEngine, // qDebug() << "new context" << context << font_cache; qt_context_cache.insert(context, font_cache); if (context->isValid()) { - if (context->device()->devType() == QInternal::Widget) { + if (context->device() && context->device()->devType() == QInternal::Widget) { QWidget *widget = static_cast(context->device()); connect(widget, SIGNAL(destroyed(QObject*)), SLOT(widgetDestroyed(QObject*))); } @@ -4832,7 +4832,6 @@ void QGLGlyphCache::cacheGlyphs(QGLContext *context, QFontEngine *fontEngine, } QImage glyph_im(fontEngine->alphaMapForGlyph(glyphs[i])); - glyph_im = glyph_im.convertToFormat(QImage::Format_Indexed8); glyph_width = glyph_im.width(); Q_ASSERT(glyph_width >= 0); // pad the glyph width to an even number @@ -4855,15 +4854,21 @@ void QGLGlyphCache::cacheGlyphs(QGLContext *context, QFontEngine *fontEngine, #endif if (!glyph_im.isNull()) { - int idx = 0; uchar *tex_data = (uchar *) malloc(glyph_width*glyph_im.height()*2); memset(tex_data, 0, glyph_width*glyph_im.height()*2); + bool is8BitGray = false; +#ifdef Q_WS_QPA + if (glyph_im.format() == QImage::Format_Indexed8) { + is8BitGray = true; + } +#endif + glyph_im = glyph_im.convertToFormat(QImage::Format_Indexed8); for (int y=0; y