From 5fcd60f2560e8caf495ce67028a8da8bef27acad Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Wed, 18 May 2011 12:16:33 +0200 Subject: Fix broken drawing with large fonts using QStaticText and FreeType In FreeType, there's a fall back to QFontEngine::alphaMapForGlyph() when the fonts are very large. Since this uses a QPainterPath containing an unhinted glyph, the use of hinted metrics would sometimes lead to the glyphs being clipped because they would be positioned slightly outside the image they were painted into. When outline drawing is on, it makes sense to return unhinted metrics, since the glyphs we will actually use are unhinted. Task-number: QTBUG-19067 Reviewed-by: Jiang Jiang --- src/gui/text/qfontengine_ft.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/gui/text/qfontengine_ft.cpp b/src/gui/text/qfontengine_ft.cpp index 4dae2a3784..855eaec8c4 100644 --- a/src/gui/text/qfontengine_ft.cpp +++ b/src/gui/text/qfontengine_ft.cpp @@ -795,7 +795,7 @@ int QFontEngineFT::loadFlags(QGlyphSet *set, GlyphFormat format, int flags, if (set && set->outline_drawing) load_flags = FT_LOAD_NO_BITMAP; - if (default_hint_style == HintNone || (flags & HB_ShaperFlag_UseDesignMetrics)) + if (default_hint_style == HintNone || (flags & HB_ShaperFlag_UseDesignMetrics) || set->outline_drawing) load_flags |= FT_LOAD_NO_HINTING; else load_flags |= load_target; -- cgit v1.2.3 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') 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) --- src/gui/painting/qpaintengine_raster.cpp | 12 ++++++-- src/gui/painting/qpaintengineex.cpp | 35 ++++++++++++++++++++++ src/gui/painting/qpaintengineex_p.h | 2 +- .../gl2paintengineex/qpaintengineex_opengl2.cpp | 33 +++++++++++++------- 4 files changed, 68 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index f0bc0d6027..4f8af488a1 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -3029,8 +3029,16 @@ void QRasterPaintEngine::drawStaticTextItem(QStaticTextItem *textItem) ensurePen(); ensureState(); - drawCachedGlyphs(textItem->numGlyphs, textItem->glyphs, textItem->glyphPositions, - textItem->fontEngine()); + QRasterPaintEngineState *s = state(); + + QFontEngine *fontEngine = textItem->fontEngine(); + const qreal pixelSize = fontEngine->fontDef.pixelSize; + if (pixelSize * pixelSize * qAbs(s->matrix.determinant()) < 64 * 64) { + drawCachedGlyphs(textItem->numGlyphs, textItem->glyphs, textItem->glyphPositions, + fontEngine); + } else { + QPaintEngineEx::drawStaticTextItem(textItem); + } } /*! diff --git a/src/gui/painting/qpaintengineex.cpp b/src/gui/painting/qpaintengineex.cpp index bbdf76f0c0..304e5fc486 100644 --- a/src/gui/painting/qpaintengineex.cpp +++ b/src/gui/painting/qpaintengineex.cpp @@ -44,6 +44,8 @@ #include "qstroker_p.h" #include "qbezier_p.h" #include +#include +#include #include #include @@ -1057,5 +1059,38 @@ Q_GUI_EXPORT QPainterPath qt_painterPathFromVectorPath(const QVectorPath &path) return p; } +void QPaintEngineEx::drawStaticTextItem(QStaticTextItem *staticTextItem) +{ + QPainterPath path; +#ifndef Q_WS_MAC + path.setFillRule(Qt::WindingFill); +#endif + + if (staticTextItem->numGlyphs == 0) + return; + + QFontEngine *fontEngine = staticTextItem->fontEngine(); + fontEngine->addGlyphsToPath(staticTextItem->glyphs, staticTextItem->glyphPositions, + staticTextItem->numGlyphs, &path, 0); + if (!path.isEmpty()) { + QPainterState *s = state(); + QPainter::RenderHints oldHints = s->renderHints; + bool changedHints = false; + if (bool(oldHints & QPainter::TextAntialiasing) + && !bool(fontEngine->fontDef.styleStrategy & QFont::NoAntialias) + && !bool(oldHints & QPainter::Antialiasing)) { + s->renderHints |= QPainter::Antialiasing; + renderHintsChanged(); + changedHints = true; + } + + fill(qtVectorPathForPath(path), staticTextItem->color); + + if (changedHints) { + s->renderHints = oldHints; + renderHintsChanged(); + } + } +} QT_END_NAMESPACE diff --git a/src/gui/painting/qpaintengineex_p.h b/src/gui/painting/qpaintengineex_p.h index d12c602372..7d57eee43d 100644 --- a/src/gui/painting/qpaintengineex_p.h +++ b/src/gui/painting/qpaintengineex_p.h @@ -202,7 +202,7 @@ public: virtual void updateState(const QPaintEngineState &state); - virtual void drawStaticTextItem(QStaticTextItem *) = 0; + virtual void drawStaticTextItem(QStaticTextItem *); virtual void setState(QPainterState *s); inline QPainterState *state() { return static_cast(QPaintEngine::state); } 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 b9ee8487e944ceab211d7c5b77ba477e8d638933 Mon Sep 17 00:00:00 2001 From: Eckhart Koppen Date: Wed, 18 May 2011 17:35:04 +0300 Subject: Enable configuration for Xcb MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The xcb platform plugin can now be enabled using -xcb at configuration time. A configuration time compilation check will be added at a later point. Reviewed-by: Samuel Rødal --- src/plugins/platforms/platforms.pro | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/plugins/platforms/platforms.pro b/src/plugins/platforms/platforms.pro index 57015e7924..492569796f 100644 --- a/src/plugins/platforms/platforms.pro +++ b/src/plugins/platforms/platforms.pro @@ -6,3 +6,6 @@ contains(QT_CONFIG, wayland) { SUBDIRS += wayland } +contains(QT_CONFIG, xcb) { + SUBDIRS += xcb +} -- cgit v1.2.3 From 449b8a93170ecc19f2f438b160d0bc4122999401 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 18 May 2011 14:39:44 +0200 Subject: QUiLoader, QAbstractFormBuilder: Introduce errorString(). Introduce errorString() to be able to obtain load errors in Qt Designer. Remove automatic Qt 3 form conversion from Qt Designer (since uic3 no longer exists) and move all form load error checking logic including language check into QAbstractFormBuilder. Make language accessible in FormBuilderExtra in case Jambi is revived. Reviewed-by: hjk --- src/uitools/quiloader.cpp | 15 ++++++++++++++- src/uitools/quiloader.h | 2 ++ 2 files changed, 16 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/uitools/quiloader.cpp b/src/uitools/quiloader.cpp index 7f39b557ea..457c7ccd13 100644 --- a/src/uitools/quiloader.cpp +++ b/src/uitools/quiloader.cpp @@ -653,7 +653,7 @@ QUiLoader::~QUiLoader() Loads a form from the given \a device and creates a new widget with the given \a parentWidget to hold its contents. - \sa createWidget() + \sa createWidget(), errorString() */ QWidget *QUiLoader::load(QIODevice *device, QWidget *parentWidget) { @@ -936,6 +936,19 @@ bool QUiLoader::isTranslationEnabled() const return d->builder.trEnabled; } +/*! + Returns a human-readable description of the last error occurred in load(). + + \since 5.0 + \sa load() +*/ + +QString QUiLoader::errorString() const +{ + Q_D(const QUiLoader); + return d->builder.errorString(); +} + QT_END_NAMESPACE #include "quiloader.moc" diff --git a/src/uitools/quiloader.h b/src/uitools/quiloader.h index 214342ef83..0c21a276ee 100644 --- a/src/uitools/quiloader.h +++ b/src/uitools/quiloader.h @@ -90,6 +90,8 @@ public: void setTranslationEnabled(bool enabled); bool isTranslationEnabled() const; + QString errorString() const; + private: QScopedPointer d_ptr; Q_DECLARE_PRIVATE(QUiLoader) -- cgit v1.2.3