diff options
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/image/qicon.cpp | 2 | ||||
-rw-r--r-- | src/gui/image/qimagereader.cpp | 4 | ||||
-rw-r--r-- | src/gui/kernel/qevent.cpp | 1 | ||||
-rw-r--r-- | src/gui/kernel/qevent.h | 7 | ||||
-rw-r--r-- | src/gui/kernel/qguiapplication.cpp | 9 | ||||
-rw-r--r-- | src/gui/kernel/qplatformsystemtrayicon_qpa.cpp | 2 | ||||
-rw-r--r-- | src/gui/kernel/qsurfaceformat.cpp | 4 | ||||
-rw-r--r-- | src/gui/kernel/qwindow.cpp | 5 | ||||
-rw-r--r-- | src/gui/kernel/qwindow.h | 30 | ||||
-rw-r--r-- | src/gui/opengl/qopenglpaintengine.cpp | 50 | ||||
-rw-r--r-- | src/gui/opengl/qopenglvertexarrayobject.cpp | 27 | ||||
-rw-r--r-- | src/gui/opengl/qopenglvertexarrayobject.h | 1 | ||||
-rw-r--r-- | src/gui/painting/qbezier.cpp | 55 | ||||
-rw-r--r-- | src/gui/painting/qpaintengine_raster.cpp | 10 | ||||
-rw-r--r-- | src/gui/painting/qpathclipper.cpp | 10 | ||||
-rw-r--r-- | src/gui/painting/qpdf.cpp | 16 | ||||
-rw-r--r-- | src/gui/painting/qpdf_p.h | 1 | ||||
-rw-r--r-- | src/gui/painting/qpdfwriter.cpp | 4 | ||||
-rw-r--r-- | src/gui/text/qfontengine_ft.cpp | 8 | ||||
-rw-r--r-- | src/gui/text/qfontengine_ft_p.h | 2 |
20 files changed, 127 insertions, 121 deletions
diff --git a/src/gui/image/qicon.cpp b/src/gui/image/qicon.cpp index f2f822331d..cb508ae6c7 100644 --- a/src/gui/image/qicon.cpp +++ b/src/gui/image/qicon.cpp @@ -181,7 +181,7 @@ void QPixmapIconEngine::paint(QPainter *painter, const QRect &rect, QIcon::Mode { QSize pixmapSize = rect.size() * qt_effective_device_pixel_ratio(0); QPixmap px = pixmap(pixmapSize, mode, state); - painter->drawPixmap(rect, pixmap(pixmapSize, mode, state)); + painter->drawPixmap(rect, px); } static inline int area(const QSize &s) { return s.width() * s.height(); } diff --git a/src/gui/image/qimagereader.cpp b/src/gui/image/qimagereader.cpp index 5dd51843fb..ec55cb85a3 100644 --- a/src/gui/image/qimagereader.cpp +++ b/src/gui/image/qimagereader.cpp @@ -311,7 +311,7 @@ static QImageIOHandler *createReadHandlerHelper(QIODevice *device, QImageIOPlugin *plugin = qobject_cast<QImageIOPlugin *>(l->instance(i)); if (plugin && plugin->capabilities(device, testFormat) & QImageIOPlugin::CanRead) { #ifdef QIMAGEREADER_DEBUG - qDebug() << "QImageReader::createReadHandler: the" << keys.at(i) << "plugin can read this format"; + qDebug() << "QImageReader::createReadHandler: the" << keyMap.keys().at(i) << "plugin can read this format"; #endif handler = plugin->create(device, testFormat); break; @@ -392,7 +392,7 @@ static QImageIOHandler *createReadHandlerHelper(QIODevice *device, if (plugin && plugin->capabilities(device, QByteArray()) & QImageIOPlugin::CanRead) { handler = plugin->create(device, testFormat); #ifdef QIMAGEREADER_DEBUG - qDebug() << "QImageReader::createReadHandler: the" << keys.at(i) << "plugin can read this data"; + qDebug() << "QImageReader::createReadHandler: the" << keyMap.keys().at(i) << "plugin can read this data"; #endif break; } diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index ba97db4d39..fa289bbf8b 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -4217,6 +4217,7 @@ void QTouchEvent::TouchPoint::setFlags(InfoFlags flags) QScrollPrepareEvent::QScrollPrepareEvent(const QPointF &startPos) : QEvent(QEvent::ScrollPrepare), m_target(0), m_startPos(startPos) { + Q_UNUSED(m_target); } /*! diff --git a/src/gui/kernel/qevent.h b/src/gui/kernel/qevent.h index 82276c5342..7142450322 100644 --- a/src/gui/kernel/qevent.h +++ b/src/gui/kernel/qevent.h @@ -860,14 +860,7 @@ public: void setContentPos(const QPointF &pos); private: -#ifdef Q_CC_CLANG -# pragma clang diagnostic push -# pragma clang diagnostic ignored "-Wunused-private-field" -#endif // Q_CC_CLANG QObject* m_target; // Qt 6 remove. -#ifdef Q_CC_CLANG -# pragma clang diagnostic pop -#endif // Q_CC_CLANG QPointF m_startPos; QSizeF m_viewportSize; QRectF m_contentPosRange; diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index 89664447c4..118b481fa3 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -787,11 +787,12 @@ static void init_platform(const QString &pluginArgument, const QString &platform QStringList keys = QPlatformIntegrationFactory::keys(platformPluginPath); QString fatalMessage - = QStringLiteral("Failed to find or load platform plugin \"%1\".\n").arg(name); - if (!keys.isEmpty()) - fatalMessage += QStringLiteral("Available platforms are: %1\n").arg( + = QStringLiteral("This application failed to start because it could not find or load the Qt platform plugin \"%1\".\n\n").arg(name); + if (!keys.isEmpty()) { + fatalMessage += QStringLiteral("Available platform plugins are: %1.\n\n").arg( keys.join(QStringLiteral(", "))); - fatalMessage += QStringLiteral("GUI applications require a platform plugin. Terminating."); + } + fatalMessage += QStringLiteral("Reinstalling the application may fix this problem."); #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) // Windows: Display message box unless it is a console application // or debug build showing an assert box. diff --git a/src/gui/kernel/qplatformsystemtrayicon_qpa.cpp b/src/gui/kernel/qplatformsystemtrayicon_qpa.cpp index 13de2c658a..b47b657361 100644 --- a/src/gui/kernel/qplatformsystemtrayicon_qpa.cpp +++ b/src/gui/kernel/qplatformsystemtrayicon_qpa.cpp @@ -51,7 +51,7 @@ QT_BEGIN_NAMESPACE \inmodule QtGui \brief The QPlatformSystemTrayIcon class abstracts the system tray icon and interaction. - \sa QSystemTray + \sa QSystemTrayIcon */ /*! diff --git a/src/gui/kernel/qsurfaceformat.cpp b/src/gui/kernel/qsurfaceformat.cpp index 25b603bb9c..9b8ed4a289 100644 --- a/src/gui/kernel/qsurfaceformat.cpp +++ b/src/gui/kernel/qsurfaceformat.cpp @@ -119,7 +119,7 @@ public: the size of the alpha buffer; the size of the depth and stencil buffers; and number of samples per pixel for multisampling. In addition, the format contains surface configuration parameters such as OpenGL profile and - version for rendering, whether or not enable stereo buffers, and swap + version for rendering, whether or not to enable stereo buffers, and swap behaviour. */ @@ -361,7 +361,7 @@ int QSurfaceFormat::depthBufferSize() const Set the swap \a behavior of the surface. The swap behavior specifies whether single, double, or triple - buffering is desired. The default, SwapBehavior::DefaultSwapBehavior, + buffering is desired. The default, DefaultSwapBehavior, gives the default swap behavior of the platform. */ void QSurfaceFormat::setSwapBehavior(SwapBehavior behavior) diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp index eff057c4cb..392407d86d 100644 --- a/src/gui/kernel/qwindow.cpp +++ b/src/gui/kernel/qwindow.cpp @@ -933,7 +933,6 @@ bool QWindow::isActive() const /*! \property QWindow::contentOrientation \brief the orientation of the window's contents - \since 5.1 This is a hint to the window manager in case it needs to display additional content like popups, dialogs, status bars, or similar @@ -1190,7 +1189,6 @@ void QWindow::setHeight(int arg) /*! \property QWindow::minimumWidth \brief the minimum width of the window's geometry - \since 5.1 */ void QWindow::setMinimumWidth(int w) { @@ -1200,7 +1198,6 @@ void QWindow::setMinimumWidth(int w) /*! \property QWindow::minimumHeight \brief the minimum height of the window's geometry - \since 5.1 */ void QWindow::setMinimumHeight(int h) { @@ -1233,7 +1230,6 @@ void QWindow::setMaximumSize(const QSize &size) /*! \property QWindow::maximumWidth \brief the maximum width of the window's geometry - \since 5.1 */ void QWindow::setMaximumWidth(int w) { @@ -1243,7 +1239,6 @@ void QWindow::setMaximumWidth(int w) /*! \property QWindow::maximumHeight \brief the maximum height of the window's geometry - \since 5.1 */ void QWindow::setMaximumHeight(int h) { diff --git a/src/gui/kernel/qwindow.h b/src/gui/kernel/qwindow.h index efdfd497a6..ca261ff7ce 100644 --- a/src/gui/kernel/qwindow.h +++ b/src/gui/kernel/qwindow.h @@ -110,14 +110,14 @@ class Q_GUI_EXPORT QWindow : public QObject, public QSurface Q_PROPERTY(int y READ y WRITE setY NOTIFY yChanged) Q_PROPERTY(int width READ width WRITE setWidth NOTIFY widthChanged) Q_PROPERTY(int height READ height WRITE setHeight NOTIFY heightChanged) - Q_PROPERTY(int minimumWidth READ minimumWidth WRITE setMinimumWidth NOTIFY minimumWidthChanged REVISION 1) - Q_PROPERTY(int minimumHeight READ minimumHeight WRITE setMinimumHeight NOTIFY minimumHeightChanged REVISION 1) - Q_PROPERTY(int maximumWidth READ maximumWidth WRITE setMaximumWidth NOTIFY maximumWidthChanged REVISION 1) - Q_PROPERTY(int maximumHeight READ maximumHeight WRITE setMaximumHeight NOTIFY maximumHeightChanged REVISION 1) + Q_PROPERTY(int minimumWidth READ minimumWidth WRITE setMinimumWidth NOTIFY minimumWidthChanged) + Q_PROPERTY(int minimumHeight READ minimumHeight WRITE setMinimumHeight NOTIFY minimumHeightChanged) + Q_PROPERTY(int maximumWidth READ maximumWidth WRITE setMaximumWidth NOTIFY maximumWidthChanged) + Q_PROPERTY(int maximumHeight READ maximumHeight WRITE setMaximumHeight NOTIFY maximumHeightChanged) Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged) Q_PROPERTY(bool active READ isActive NOTIFY activeChanged REVISION 1) Q_PROPERTY(Visibility visibility READ visibility WRITE setVisibility NOTIFY visibilityChanged REVISION 1) - Q_PROPERTY(Qt::ScreenOrientation contentOrientation READ contentOrientation WRITE reportContentOrientationChange NOTIFY contentOrientationChanged REVISION 1) + Q_PROPERTY(Qt::ScreenOrientation contentOrientation READ contentOrientation WRITE reportContentOrientationChange NOTIFY contentOrientationChanged) Q_PROPERTY(qreal opacity READ opacity WRITE setOpacity NOTIFY opacityChanged REVISION 1) public: @@ -286,12 +286,12 @@ public Q_SLOTS: void setWidth(int arg); void setHeight(int arg); - Q_REVISION(1) void setMinimumWidth(int w); - Q_REVISION(1) void setMinimumHeight(int h); - Q_REVISION(1) void setMaximumWidth(int w); - Q_REVISION(1) void setMaximumHeight(int h); + void setMinimumWidth(int w); + void setMinimumHeight(int h); + void setMaximumWidth(int w); + void setMaximumHeight(int h); - void alert(int msec); + Q_REVISION(1) void alert(int msec); Q_SIGNALS: void screenChanged(QScreen *screen); @@ -304,15 +304,15 @@ Q_SIGNALS: void widthChanged(int arg); void heightChanged(int arg); - Q_REVISION(1) void minimumWidthChanged(int arg); - Q_REVISION(1) void minimumHeightChanged(int arg); - Q_REVISION(1) void maximumWidthChanged(int arg); - Q_REVISION(1) void maximumHeightChanged(int arg); + void minimumWidthChanged(int arg); + void minimumHeightChanged(int arg); + void maximumWidthChanged(int arg); + void maximumHeightChanged(int arg); void visibleChanged(bool arg); Q_REVISION(1) void visibilityChanged(QWindow::Visibility visibility); Q_REVISION(1) void activeChanged(); - Q_REVISION(1) void contentOrientationChanged(Qt::ScreenOrientation orientation); + void contentOrientationChanged(Qt::ScreenOrientation orientation); void focusObjectChanged(QObject *object); diff --git a/src/gui/opengl/qopenglpaintengine.cpp b/src/gui/opengl/qopenglpaintengine.cpp index 0782e42531..78f5080caf 100644 --- a/src/gui/opengl/qopenglpaintengine.cpp +++ b/src/gui/opengl/qopenglpaintengine.cpp @@ -549,8 +549,10 @@ void QOpenGL2PaintEngineEx::beginNativePainting() #ifndef QT_OPENGL_ES_2 Q_ASSERT(QOpenGLContext::currentContext()); + const QOpenGLContext *ctx = d->ctx; const QSurfaceFormat &fmt = d->device->context()->format(); if (fmt.majorVersion() < 3 || (fmt.majorVersion() == 3 && fmt.minorVersion() < 1) + || (fmt.majorVersion() == 3 && fmt.minorVersion() == 1 && ctx->hasExtension(QByteArrayLiteral("GL_ARB_compatibility"))) || fmt.profile() == QSurfaceFormat::CompatibilityProfile) { // be nice to people who mix OpenGL 1.x code with QPainter commands @@ -1548,8 +1550,28 @@ namespace { bool QOpenGL2PaintEngineEx::shouldDrawCachedGlyphs(QFontEngine *fontEngine, const QTransform &t) const { - // Don't try to cache vastly transformed fonts - return t.type() < QTransform::TxProject && QPaintEngineEx::shouldDrawCachedGlyphs(fontEngine, t); + // The paint engine does not support projected cached glyph drawing + if (t.type() == QTransform::TxProject) + return false; + + // The font engine might not support filling the glyph cache + // with the given transform applied, in which case we need to + // fall back to the QPainterPath code-path. + if (!fontEngine->supportsTransformation(t)) { + // Except that drawing paths is slow, so for scales between + // 0.5 and 2.0 we leave the glyph cache untransformed and deal + // with the transform ourselves when painting, resulting in + // drawing 1x cached glyphs with a smooth-scale. + float det = t.determinant(); + if (det >= 0.25f && det <= 4.f) { + // Assuming the baseclass still agrees + return QPaintEngineEx::shouldDrawCachedGlyphs(fontEngine, t); + } + + return false; // Fall back to path-drawing + } + + return QPaintEngineEx::shouldDrawCachedGlyphs(fontEngine, t); } void QOpenGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngineGlyphCache::Type glyphType, @@ -1561,20 +1583,24 @@ void QOpenGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngineGlyphCache::Type void *cacheKey = ctx->shareGroup(); bool recreateVertexArrays = false; - QFontEngine *fe = staticTextItem->fontEngine(); - // We allow scaling, so that the glyph-cache will contain glyphs with the - // appropriate resolution in the case of displays with a device-pixel-ratio != 1. - QTransform transform = s->matrix.type() < QTransform::TxRotate ? - QTransform::fromScale(qAbs(s->matrix.m11()), qAbs(s->matrix.m22())) : - QTransform::fromScale( - QVector2D(s->matrix.m11(), s->matrix.m12()).length(), - QVector2D(s->matrix.m21(), s->matrix.m22()).length()); + QTransform glyphCacheTransform; + QFontEngine *fe = staticTextItem->fontEngine(); + if (fe->supportsTransformation(s->matrix)) { + // The font-engine supports rendering glyphs with the current transform, so we + // build a glyph-cache with the scale pre-applied, so that the cache contains + // glyphs with the appropriate resolution in the case of retina displays. + glyphCacheTransform = s->matrix.type() < QTransform::TxRotate ? + QTransform::fromScale(qAbs(s->matrix.m11()), qAbs(s->matrix.m22())) : + QTransform::fromScale( + QVector2D(s->matrix.m11(), s->matrix.m12()).length(), + QVector2D(s->matrix.m21(), s->matrix.m22()).length()); + } QOpenGLTextureGlyphCache *cache = - (QOpenGLTextureGlyphCache *) fe->glyphCache(cacheKey, glyphType, transform); + (QOpenGLTextureGlyphCache *) fe->glyphCache(cacheKey, glyphType, glyphCacheTransform); if (!cache || cache->cacheType() != glyphType || cache->contextGroup() == 0) { - cache = new QOpenGLTextureGlyphCache(glyphType, transform); + cache = new QOpenGLTextureGlyphCache(glyphType, glyphCacheTransform); fe->setGlyphCache(cacheKey, cache); recreateVertexArrays = true; } diff --git a/src/gui/opengl/qopenglvertexarrayobject.cpp b/src/gui/opengl/qopenglvertexarrayobject.cpp index e450fe708f..eb7a42f749 100644 --- a/src/gui/opengl/qopenglvertexarrayobject.cpp +++ b/src/gui/opengl/qopenglvertexarrayobject.cpp @@ -118,6 +118,9 @@ public: void destroy(); void bind(); void release(); + void _q_contextAboutToBeDestroyed(); + + Q_DECLARE_PUBLIC(QOpenGLVertexArrayObject) GLuint vao; @@ -141,12 +144,22 @@ public: bool QOpenGLVertexArrayObjectPrivate::create() { + if (vao) { + qWarning("QOpenGLVertexArrayObject::create() VAO is already created"); + return false; + } + + Q_Q(QOpenGLVertexArrayObject); + if (context) + QObject::disconnect(context, SIGNAL(aboutToBeDestroyed()), q, SLOT(_q_contextAboutToBeDestroyed())); + QOpenGLContext *ctx = QOpenGLContext::currentContext(); if (!ctx) { qWarning("QOpenGLVertexArrayObject::create() requires a valid current OpenGL context"); return false; } context = ctx; + QObject::connect(context, SIGNAL(aboutToBeDestroyed()), q, SLOT(_q_contextAboutToBeDestroyed())); #if defined(QT_OPENGL_ES_2) if (ctx->hasExtension("GL_OES_vertex_array_object")) { @@ -197,8 +210,16 @@ void QOpenGLVertexArrayObjectPrivate::destroy() case NotSupported: break; } - vao = 0; #endif + vao = 0; +} + +/*! + \internal +*/ +void QOpenGLVertexArrayObjectPrivate::_q_contextAboutToBeDestroyed() +{ + destroy(); } void QOpenGLVertexArrayObjectPrivate::bind() @@ -327,7 +348,7 @@ QOpenGLVertexArrayObject::~QOpenGLVertexArrayObject() Q_D(QOpenGLVertexArrayObject); QOpenGLContext *oldContext = 0; - if (d->context && d->context != ctx) { + if (d->context && ctx && d->context != ctx) { oldContext = ctx; if (d->context->makeCurrent(oldContext->surface())) { ctx = d->context; @@ -471,3 +492,5 @@ void QOpenGLVertexArrayObject::release() */ QT_END_NAMESPACE + +#include "moc_qopenglvertexarrayobject.cpp" diff --git a/src/gui/opengl/qopenglvertexarrayobject.h b/src/gui/opengl/qopenglvertexarrayobject.h index 569aeea730..8369497660 100644 --- a/src/gui/opengl/qopenglvertexarrayobject.h +++ b/src/gui/opengl/qopenglvertexarrayobject.h @@ -102,6 +102,7 @@ public: private: Q_DISABLE_COPY(QOpenGLVertexArrayObject) Q_DECLARE_PRIVATE(QOpenGLVertexArrayObject) + Q_PRIVATE_SLOT(d_func(), void _q_contextAboutToBeDestroyed()) QOpenGLVertexArrayObject(QOpenGLVertexArrayObjectPrivate &dd); }; diff --git a/src/gui/painting/qbezier.cpp b/src/gui/painting/qbezier.cpp index 6cef7cc501..2762560da7 100644 --- a/src/gui/painting/qbezier.cpp +++ b/src/gui/painting/qbezier.cpp @@ -150,33 +150,6 @@ static inline int quadraticRoots(qreal a, qreal b, qreal c, } } -static inline bool findInflections(qreal a, qreal b, qreal c, - qreal *t1 , qreal *t2, qreal *tCups) -{ - qreal r1 = 0, r2 = 0; - - short rootsCount = quadraticRoots(a, b, c, &r1, &r2); - - if (rootsCount >= 1) { - if (r1 < r2) { - *t1 = r1; - *t2 = r2; - } else { - *t1 = r2; - *t2 = r1; - } - if (!qFuzzyIsNull(a)) - *tCups = qreal(0.5) * (-b / a); - else - *tCups = 2; - - return true; - } - - return false; -} - - void QBezier::addToPolygon(QPolygonF *polygon, qreal bezier_flattening_threshold) const { QBezier beziers[10]; @@ -531,34 +504,6 @@ static QDebug operator<<(QDebug dbg, const QBezier &bz) } #endif -static inline void splitBezierAt(const QBezier &bez, qreal t, - QBezier *left, QBezier *right) -{ - left->x1 = bez.x1; - left->y1 = bez.y1; - - left->x2 = bez.x1 + t * ( bez.x2 - bez.x1 ); - left->y2 = bez.y1 + t * ( bez.y2 - bez.y1 ); - - left->x3 = bez.x2 + t * ( bez.x3 - bez.x2 ); // temporary holding spot - left->y3 = bez.y2 + t * ( bez.y3 - bez.y2 ); // temporary holding spot - - right->x3 = bez.x3 + t * ( bez.x4 - bez.x3 ); - right->y3 = bez.y3 + t * ( bez.y4 - bez.y3 ); - - right->x2 = left->x3 + t * ( right->x3 - left->x3); - right->y2 = left->y3 + t * ( right->y3 - left->y3); - - left->x3 = left->x2 + t * ( left->x3 - left->x2 ); - left->y3 = left->y2 + t * ( left->y3 - left->y2 ); - - left->x4 = right->x1 = left->x3 + t * (right->x2 - left->x3); - left->y4 = right->y1 = left->y3 + t * (right->y2 - left->y3); - - right->x4 = bez.x4; - right->y4 = bez.y4; -} - qreal QBezier::length(qreal error) const { qreal length = qreal(0.0); diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index 66a4a43cba..d1e9b81faa 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -3327,10 +3327,16 @@ bool QRasterPaintEngine::requiresPretransformedGlyphPositions(QFontEngine *fontE bool QRasterPaintEngine::shouldDrawCachedGlyphs(QFontEngine *fontEngine, const QTransform &m) const { + // The raster engine does not support projected cached glyph drawing + if (m.type() >= QTransform::TxProject) + return false; + // The font engine might not support filling the glyph cache // with the given transform applied, in which case we need to - // fall back to the QPainterPath code-path. - if (!fontEngine->supportsTransformation(m)) + // fall back to the QPainterPath code-path. This does not apply + // for engines with internal caching, as we don't use the engine + // to fill up our cache in that case. + if (!fontEngine->hasInternalCaching() && !fontEngine->supportsTransformation(m)) return false; return QPaintEngineEx::shouldDrawCachedGlyphs(fontEngine, m); diff --git a/src/gui/painting/qpathclipper.cpp b/src/gui/painting/qpathclipper.cpp index 2702b56e73..243c99e671 100644 --- a/src/gui/painting/qpathclipper.cpp +++ b/src/gui/painting/qpathclipper.cpp @@ -1036,16 +1036,6 @@ qreal QWingedEdge::delta(int vertex, int a, int b) const return result; } -static inline QPointF midPoint(const QWingedEdge &list, int ei) -{ - const QPathEdge *ep = list.edge(ei); - Q_ASSERT(ep); - - const QPointF a = *list.vertex(ep->first); - const QPointF b = *list.vertex(ep->second); - return a + 0.5 * (b - a); -} - QWingedEdge::TraversalStatus QWingedEdge::findInsertStatus(int vi, int ei) const { const QPathVertex *vp = vertex(vi); diff --git a/src/gui/painting/qpdf.cpp b/src/gui/painting/qpdf.cpp index 345ebefea7..9105e8b396 100644 --- a/src/gui/painting/qpdf.cpp +++ b/src/gui/painting/qpdf.cpp @@ -1469,7 +1469,12 @@ int QPdfEngine::metric(QPaintDevice::PaintDeviceMetric metricType) const return val; } +static inline QSizeF pageSizeToPostScriptPoints(const QSizeF &pageSizeMM) +{ #define Q_MM(n) int((n * 720 + 127) / 254) + return QSizeF(Q_MM(pageSizeMM.width()), Q_MM(pageSizeMM.height())); +#undef Q_MM +} QPdfEnginePrivate::QPdfEnginePrivate() : clipEnabled(false), allClipped(false), hasPen(true), hasBrush(false), simplePen(false), @@ -1477,7 +1482,7 @@ QPdfEnginePrivate::QPdfEnginePrivate() fullPage(false), embedFonts(true), landscape(false), grayscale(false), - paperSize(Q_MM(210), Q_MM(297)), // A4 + paperSize(pageSizeToPostScriptPoints(QSizeF(210, 297))), // A4 leftMargin(10), topMargin(10), rightMargin(10), bottomMargin(10) // ~3.5 mm { resolution = 1200; @@ -1491,6 +1496,11 @@ QPdfEnginePrivate::QPdfEnginePrivate() stream = new QDataStream; } +void QPdfEnginePrivate::setPaperSize(const QSizeF &pageSizeMM) +{ + paperSize = pageSizeToPostScriptPoints(pageSizeMM); +} + bool QPdfEngine::begin(QPaintDevice *pdev) { Q_D(QPdfEngine); @@ -2518,6 +2528,10 @@ void QPdfEnginePrivate::drawTextItem(const QPointF &p, const QTextItemInt &ti) qreal size = ti.fontEngine->fontDef.pixelSize; +#if defined(Q_OS_WIN) + size = (ti.fontEngine->ascent() + ti.fontEngine->descent()).toReal(); +#endif + QVarLengthArray<glyph_t> glyphs; QVarLengthArray<QFixedPoint> positions; QTransform m = QTransform::fromTranslate(p.x(), p.y()); diff --git a/src/gui/painting/qpdf_p.h b/src/gui/painting/qpdf_p.h index 560621775b..54530d0f78 100644 --- a/src/gui/painting/qpdf_p.h +++ b/src/gui/painting/qpdf_p.h @@ -226,6 +226,7 @@ public: QRect paperRect() const; QRect pageRect() const; + void setPaperSize(const QSizeF &pageSizeMM); int width() const { QRect r = paperRect(); diff --git a/src/gui/painting/qpdfwriter.cpp b/src/gui/painting/qpdfwriter.cpp index 136654cb5d..a783aad66a 100644 --- a/src/gui/painting/qpdfwriter.cpp +++ b/src/gui/painting/qpdfwriter.cpp @@ -166,7 +166,7 @@ void QPdfWriter::setPageSize(PageSize size) Q_D(const QPdfWriter); QPagedPaintDevice::setPageSize(size); - d->engine->d_func()->paperSize = pageSizeMM() * 25.4/72.; + d->engine->d_func()->setPaperSize(pageSizeMM()); } /*! @@ -177,7 +177,7 @@ void QPdfWriter::setPageSizeMM(const QSizeF &size) Q_D(const QPdfWriter); QPagedPaintDevice::setPageSizeMM(size); - d->engine->d_func()->paperSize = pageSizeMM() * 25.4/72.; + d->engine->d_func()->setPaperSize(pageSizeMM()); } /*! diff --git a/src/gui/text/qfontengine_ft.cpp b/src/gui/text/qfontengine_ft.cpp index 4545645dc6..7b4925a9c8 100644 --- a/src/gui/text/qfontengine_ft.cpp +++ b/src/gui/text/qfontengine_ft.cpp @@ -1437,6 +1437,14 @@ void QFontEngineFT::getUnscaledGlyph(glyph_t glyph, QPainterPath *path, glyph_me unlockFace(); } +bool QFontEngineFT::supportsTransformation(const QTransform &transform) const +{ + // The freetype engine falls back to QFontEngine for tranformed glyphs, + // which uses fast-tranform and produces very ugly results, so we claim + // to support just translations. + return transform.type() <= QTransform::TxTranslate; +} + static inline unsigned int getChar(const QChar *str, int &i, const int len) { uint ucs4 = str[i].unicode(); diff --git a/src/gui/text/qfontengine_ft_p.h b/src/gui/text/qfontengine_ft_p.h index e09fa6f94f..bd4c855b91 100644 --- a/src/gui/text/qfontengine_ft_p.h +++ b/src/gui/text/qfontengine_ft_p.h @@ -233,6 +233,8 @@ private: virtual void getUnscaledGlyph(glyph_t glyph, QPainterPath *path, glyph_metrics_t *metrics); + virtual bool supportsTransformation(const QTransform &transform) const; + virtual bool canRender(const QChar *string, int len); virtual void addGlyphsToPath(glyph_t *glyphs, QFixedPoint *positions, int nglyphs, |