diff options
author | Kim Motoyoshi Kalland <kim.kalland@nokia.com> | 2010-02-11 14:32:02 (GMT) |
---|---|---|
committer | Kim Motoyoshi Kalland <kim.kalland@nokia.com> | 2010-02-12 09:12:26 (GMT) |
commit | c82bb3f049793d42e0589521c42576c2a95b2661 (patch) | |
tree | 1b803625d729152357b572c8c1447102d9ed45c3 /src/opengl/gl2paintengineex | |
parent | c23a5c09d6b8896f4b61164a2dc61ce6ac3f5edb (diff) | |
download | Qt-c82bb3f049793d42e0589521c42576c2a95b2661.zip Qt-c82bb3f049793d42e0589521c42576c2a95b2661.tar.gz Qt-c82bb3f049793d42e0589521c42576c2a95b2661.tar.bz2 |
Turned off subpixel AA text on surface with alpha in GL2 engine.
Subpixel antialiased text does not look good on translucent
surfaces, so turn it off if the surface the text is rendered on
has an alpha channel. This makes change
eb84acd899aee992f5631ee0b9c0d992c8fbbd5a redundant.
Task-number: QTBUG-7190
Reviewed-by: Gunnar
Diffstat (limited to 'src/opengl/gl2paintengineex')
-rw-r--r-- | src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp | 31 | ||||
-rw-r--r-- | src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h | 1 |
2 files changed, 25 insertions, 7 deletions
diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index 07f3159..1263a56 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -1231,14 +1231,14 @@ void QGL2PaintEngineEx::drawTextItem(const QPointF &p, const QTextItem &textItem ? QFontEngineGlyphCache::Type(ti.fontEngine->glyphFormat) : d->glyphCacheType; - if (txtype > QTransform::TxTranslate) - glyphType = QFontEngineGlyphCache::Raster_A8; - if (glyphType == QFontEngineGlyphCache::Raster_RGBMask - && state()->composition_mode != QPainter::CompositionMode_Source - && state()->composition_mode != QPainter::CompositionMode_SourceOver) - { - drawCached = false; + if (glyphType == QFontEngineGlyphCache::Raster_RGBMask) { + if (d->deviceHasAlpha || txtype > QTransform::TxTranslate + || (state()->composition_mode != QPainter::CompositionMode_Source + && state()->composition_mode != QPainter::CompositionMode_SourceOver)) + { + glyphType = QFontEngineGlyphCache::Raster_A8; + } } if (drawCached) { @@ -1529,6 +1529,23 @@ bool QGL2PaintEngineEx::begin(QPaintDevice *pdev) d->dirtyStencilRegion = QRect(0, 0, d->width, d->height); d->stencilClean = true; + switch (pdev->devType()) { + case QInternal::Pixmap: + d->deviceHasAlpha = static_cast<QPixmap *>(pdev)->hasAlphaChannel(); + break; + case QInternal::FramebufferObject: + { + GLenum f = static_cast<QGLFramebufferObject *>(pdev)->format().internalTextureFormat(); + d->deviceHasAlpha = (f != GL_RGB && f != GL_RGB5 && f != GL_RGB8); + } + break; + default: + // widget, pbuffer + d->deviceHasAlpha = d->ctx->d_func()->reqFormat.alpha(); + break; + } + + // Calling begin paint should make the correct context current. So, any // code which calls into GL or otherwise needs a current context *must* // go after beginPaint: diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h index 8fa0eff..fe577be 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h @@ -278,6 +278,7 @@ public: bool needsSync; bool multisamplingAlwaysEnabled; + bool deviceHasAlpha; GLfloat depthRange[2]; |