From e8c95790d9d03678f9c0d30a7cc7c2edec6eba81 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Wed, 18 May 2011 15:31:14 +0200 Subject: Add ability to work around non-standard GLES implementations Reviewed-by: Gunnar --- src/opengl/qglshaderprogram.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/opengl') diff --git a/src/opengl/qglshaderprogram.cpp b/src/opengl/qglshaderprogram.cpp index 4598bffabb..8ca95a88c9 100644 --- a/src/opengl/qglshaderprogram.cpp +++ b/src/opengl/qglshaderprogram.cpp @@ -362,17 +362,17 @@ QGLShader::ShaderType QGLShader::shaderType() const // The precision qualifiers are useful on OpenGL/ES systems, // but usually not present on desktop systems. Define the // keywords to empty strings on desktop systems. -#ifndef QT_OPENGL_ES +#if !defined(QT_OPENGL_ES) || defined(QT_OPENGL_FORCE_SHADER_DEFINES) #define QGL_DEFINE_QUALIFIERS 1 static const char qualifierDefines[] = "#define lowp\n" "#define mediump\n" "#define highp\n"; -#endif + +#else // The "highp" qualifier doesn't exist in fragment shaders // on all ES platforms. When it doesn't exist, use "mediump". -#ifdef QT_OPENGL_ES #define QGL_REDEFINE_HIGHP 1 static const char redefineHighp[] = "#ifndef GL_FRAGMENT_PRECISION_HIGH\n" -- cgit v1.2.3 From f4c1c2f939e1cd6e08197284edb84b202cd6749e Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Wed, 18 May 2011 15:10:40 +0200 Subject: Fall back to using paths for large fonts in drawStaticText() QStaticText had an implicit risk which meant you had to make sure the text size did not grow unreasonably large. This was intended to avoid hiding the performance impact of using QStaticText for such a purpose, but it's too inconvenient. Thus, the same fall back as in drawTextItem() has been introduced. This will also fix a bug recently introduced when we started using the FT cache to draw static text in the raster engine, since this will fail for large fonts. Task-number: QTBUG-19084, QTBUG-19370 Reviewed-by: Jiang Jiang (cherry picked from commit 0aa9b30432cec3b7f366983f451fc9a7f8f83243) --- .../gl2paintengineex/qpaintengineex_opengl2.cpp | 33 ++++++++++++++-------- 1 file changed, 22 insertions(+), 11 deletions(-) (limited to 'src/opengl') diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index 38bd58d91c..3cf8faa086 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -1436,19 +1436,30 @@ void QGL2PaintEngineEx::drawStaticTextItem(QStaticTextItem *textItem) ensureActive(); - QFontEngineGlyphCache::Type glyphType = textItem->fontEngine()->glyphFormat >= 0 - ? QFontEngineGlyphCache::Type(textItem->fontEngine()->glyphFormat) - : d->glyphCacheType; - if (glyphType == QFontEngineGlyphCache::Raster_RGBMask) { - if (d->device->alphaRequested() || state()->matrix.type() > QTransform::TxTranslate - || (state()->composition_mode != QPainter::CompositionMode_Source - && state()->composition_mode != QPainter::CompositionMode_SourceOver)) - { - glyphType = QFontEngineGlyphCache::Raster_A8; + QPainterState *s = state(); + float det = s->matrix.determinant(); + + // don't try to cache huge fonts or vastly transformed fonts + QFontEngine *fontEngine = textItem->fontEngine(); + const qreal pixelSize = fontEngine->fontDef.pixelSize; + if (pixelSize * pixelSize * qAbs(det) < QT_MAX_CACHED_GLYPH_SIZE * QT_MAX_CACHED_GLYPH_SIZE || + det < 0.25f || det > 4.f) { + QFontEngineGlyphCache::Type glyphType = fontEngine->glyphFormat >= 0 + ? QFontEngineGlyphCache::Type(textItem->fontEngine()->glyphFormat) + : d->glyphCacheType; + if (glyphType == QFontEngineGlyphCache::Raster_RGBMask) { + if (d->device->alphaRequested() || s->matrix.type() > QTransform::TxTranslate + || (s->composition_mode != QPainter::CompositionMode_Source + && s->composition_mode != QPainter::CompositionMode_SourceOver)) + { + glyphType = QFontEngineGlyphCache::Raster_A8; + } } - } - d->drawCachedGlyphs(glyphType, textItem); + d->drawCachedGlyphs(glyphType, textItem); + } else { + QPaintEngineEx::drawStaticTextItem(textItem); + } } bool QGL2PaintEngineEx::drawTexture(const QRectF &dest, GLuint textureId, const QSize &size, const QRectF &src) -- cgit v1.2.3 From 3d34c9b78ee96b20c5b99358fa574ce057e9ef47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Thu, 19 May 2011 16:18:21 +0200 Subject: Full translucent background support in xcb and xlib backend. Make sure to pick an alpha visual also for non-GL surface types, and to ask for alpha in the window format if the WA_TranslucentBackground attribute is set. Reviewed-by: Janusz Lewandowski (cherry picked from commit 6241e39cff9311c943430ff2f31236b13618f2ac) --- src/opengl/qgl_qpa.cpp | 2 ++ src/opengl/qwindowsurface_gl.cpp | 18 +++++++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) (limited to 'src/opengl') diff --git a/src/opengl/qgl_qpa.cpp b/src/opengl/qgl_qpa.cpp index 994344c6eb..9da650f98d 100644 --- a/src/opengl/qgl_qpa.cpp +++ b/src/opengl/qgl_qpa.cpp @@ -150,6 +150,8 @@ bool QGLContext::chooseContext(const QGLContext* shareContext) if (shareContext) { winFormat.setSharedContext(shareContext->d_func()->platformContext); } + if (widget->testAttribute(Qt::WA_TranslucentBackground)) + winFormat.setAlpha(true); winFormat.setWindowApi(QPlatformWindowFormat::OpenGL); winFormat.setWindowSurface(false); widget->setPlatformWindowFormat(winFormat); diff --git a/src/opengl/qwindowsurface_gl.cpp b/src/opengl/qwindowsurface_gl.cpp index 49b3dc2dae..ff5744678d 100644 --- a/src/opengl/qwindowsurface_gl.cpp +++ b/src/opengl/qwindowsurface_gl.cpp @@ -542,19 +542,27 @@ void QGLWindowSurface::beginPaint(const QRegion &) d_ptr->did_paint = true; updateGeometry(); - if (!context()) - return; - int clearFlags = 0; - if (context()->d_func()->workaround_needsFullClearOnEveryFrame) + QGLContext *ctx = reinterpret_cast(window()->d_func()->extraData()->glContext); + + if (!ctx) + return; + + if (ctx->d_func()->workaround_needsFullClearOnEveryFrame) clearFlags = GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT; - else if (context()->format().alpha()) + else if (ctx->format().alpha()) clearFlags = GL_COLOR_BUFFER_BIT; if (clearFlags) { + if (d_ptr->fbo) + d_ptr->fbo->bind(); + glClearColor(0.0, 0.0, 0.0, 0.0); glClear(clearFlags); + + if (d_ptr->fbo) + d_ptr->fbo->release(); } } -- cgit v1.2.3