diff options
author | Tor Arne Vestbø <tor.arne.vestbo@digia.com> | 2012-10-19 09:53:42 +0200 |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@digia.com> | 2012-10-19 09:54:12 +0200 |
commit | 55a36aed7935984846db2342e37160057cb3bec8 (patch) | |
tree | b84f611333fe9ec6ecda62c9ea47f954f59bc394 /src/gui | |
parent | a9a87deb685600aebd9ed1cec82ad668afca88d9 (diff) | |
parent | 734324c37cb9d8417aa86f76fc81dadc21be2156 (diff) |
Merge remote-tracking branch 'gerrit/master' into newdocs
Change-Id: If7f46d56cf0b0b79f7fc8955a01964121b900d07
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/accessible/qaccessible2.h | 2 | ||||
-rw-r--r-- | src/gui/kernel/qdrag.cpp | 1 | ||||
-rw-r--r-- | src/gui/kernel/qplatformtheme.cpp | 19 | ||||
-rw-r--r-- | src/gui/kernel/qplatformtheme.h | 84 | ||||
-rw-r--r-- | src/gui/kernel/qplatformwindow.cpp | 5 | ||||
-rw-r--r-- | src/gui/kernel/qplatformwindow.h | 2 | ||||
-rw-r--r-- | src/gui/kernel/qwindow.cpp | 39 | ||||
-rw-r--r-- | src/gui/kernel/qwindow_p.h | 3 | ||||
-rw-r--r-- | src/gui/painting/qcosmeticstroker.cpp | 4 | ||||
-rw-r--r-- | src/gui/painting/qcosmeticstroker_p.h | 7 | ||||
-rw-r--r-- | src/gui/painting/qpaintbuffer.cpp | 2 | ||||
-rw-r--r-- | src/gui/painting/qpaintengine_raster.cpp | 39 | ||||
-rw-r--r-- | src/gui/painting/qpaintengine_raster_p.h | 3 | ||||
-rw-r--r-- | src/gui/painting/qpainter.cpp | 5 | ||||
-rw-r--r-- | src/gui/painting/qpainter.h | 3 | ||||
-rw-r--r-- | src/gui/painting/qrasterizer.cpp | 50 | ||||
-rw-r--r-- | src/gui/painting/qrasterizer_p.h | 1 | ||||
-rw-r--r-- | src/gui/text/qtextodfwriter.cpp | 8 |
18 files changed, 220 insertions, 57 deletions
diff --git a/src/gui/accessible/qaccessible2.h b/src/gui/accessible/qaccessible2.h index c1e7b8b5a2..e93324b4f8 100644 --- a/src/gui/accessible/qaccessible2.h +++ b/src/gui/accessible/qaccessible2.h @@ -52,8 +52,6 @@ QT_BEGIN_NAMESPACE #ifndef QT_NO_ACCESSIBILITY -class QModelIndex; - namespace QAccessible2 { enum BoundaryType { diff --git a/src/gui/kernel/qdrag.cpp b/src/gui/kernel/qdrag.cpp index 1c2a6d301b..ff93801524 100644 --- a/src/gui/kernel/qdrag.cpp +++ b/src/gui/kernel/qdrag.cpp @@ -52,6 +52,7 @@ QT_BEGIN_NAMESPACE /*! \class QDrag \inmodule QtGui + \ingroup draganddrop \brief The QDrag class provides support for MIME-based drag and drop data transfer. diff --git a/src/gui/kernel/qplatformtheme.cpp b/src/gui/kernel/qplatformtheme.cpp index b91d3d0281..2e896eecf4 100644 --- a/src/gui/kernel/qplatformtheme.cpp +++ b/src/gui/kernel/qplatformtheme.cpp @@ -43,6 +43,7 @@ #include <QtCore/QVariant> #include <QtCore/QStringList> +#include <QtCore/qfileinfo.h> #include <qpalette.h> #include <qtextformat.h> @@ -164,6 +165,22 @@ const QFont *QPlatformTheme::font(Font type) const return 0; } +QPixmap QPlatformTheme::standardPixmap(StandardPixmap sp, const QSizeF &size) const +{ + Q_UNUSED(sp); + Q_UNUSED(size); + // TODO Should return QCommonStyle pixmaps? + return QPixmap(); +} + +QPixmap QPlatformTheme::fileIconPixmap(const QFileInfo &fileInfo, const QSizeF &size) const +{ + Q_UNUSED(fileInfo); + Q_UNUSED(size); + // TODO Should return QCommonStyle pixmaps? + return QPixmap(); +} + QVariant QPlatformTheme::themeHint(ThemeHint hint) const { return QPlatformTheme::defaultThemeHint(hint); @@ -223,6 +240,8 @@ QVariant QPlatformTheme::defaultThemeHint(ThemeHint hint) return QVariant(int(QTextCharFormat::SpellCheckUnderline)); case TabAllWidgets: return QVariant(true); + case IconPixmapSizes: + return QVariant::fromValue(QList<int>()); } return QVariant(); } diff --git a/src/gui/kernel/qplatformtheme.h b/src/gui/kernel/qplatformtheme.h index 398339255c..25453e792f 100644 --- a/src/gui/kernel/qplatformtheme.h +++ b/src/gui/kernel/qplatformtheme.h @@ -67,6 +67,9 @@ class QPlatformSystemTrayIcon; class QVariant; class QPalette; class QFont; +class QPixmap; +class QSizeF; +class QFileInfo; class Q_GUI_EXPORT QPlatformTheme { @@ -97,7 +100,8 @@ public: KeyboardScheme, UiEffects, SpellCheckUnderlineStyle, - TabAllWidgets + TabAllWidgets, + IconPixmapSizes }; enum DialogType { @@ -150,6 +154,81 @@ public: NFonts }; + enum StandardPixmap { // Keep in sync with QStyle::StandardPixmap + TitleBarMenuButton, + TitleBarMinButton, + TitleBarMaxButton, + TitleBarCloseButton, + TitleBarNormalButton, + TitleBarShadeButton, + TitleBarUnshadeButton, + TitleBarContextHelpButton, + DockWidgetCloseButton, + MessageBoxInformation, + MessageBoxWarning, + MessageBoxCritical, + MessageBoxQuestion, + DesktopIcon, + TrashIcon, + ComputerIcon, + DriveFDIcon, + DriveHDIcon, + DriveCDIcon, + DriveDVDIcon, + DriveNetIcon, + DirOpenIcon, + DirClosedIcon, + DirLinkIcon, + DirLinkOpenIcon, + FileIcon, + FileLinkIcon, + ToolBarHorizontalExtensionButton, + ToolBarVerticalExtensionButton, + FileDialogStart, + FileDialogEnd, + FileDialogToParent, + FileDialogNewFolder, + FileDialogDetailedView, + FileDialogInfoView, + FileDialogContentsView, + FileDialogListView, + FileDialogBack, + DirIcon, + DialogOkButton, + DialogCancelButton, + DialogHelpButton, + DialogOpenButton, + DialogSaveButton, + DialogCloseButton, + DialogApplyButton, + DialogResetButton, + DialogDiscardButton, + DialogYesButton, + DialogNoButton, + ArrowUp, + ArrowDown, + ArrowLeft, + ArrowRight, + ArrowBack, + ArrowForward, + DirHomeIcon, + CommandLink, + VistaShield, + BrowserReload, + BrowserStop, + MediaPlay, + MediaStop, + MediaPause, + MediaSkipForward, + MediaSkipBackward, + MediaSeekForward, + MediaSeekBackward, + MediaVolume, + MediaVolumeMuted, + // do not add any values below/greater than this + CustomBase = 0xf0000000 + }; + enum KeyboardSchemes { WindowsKeyboardScheme, @@ -190,6 +269,9 @@ public: virtual QVariant themeHint(ThemeHint hint) const; + virtual QPixmap standardPixmap(StandardPixmap sp, const QSizeF &size) const; + virtual QPixmap fileIconPixmap(const QFileInfo &fileInfo, const QSizeF &size) const; + static QVariant defaultThemeHint(ThemeHint hint); }; diff --git a/src/gui/kernel/qplatformwindow.cpp b/src/gui/kernel/qplatformwindow.cpp index 27dfd7cf40..2bc6b01b3e 100644 --- a/src/gui/kernel/qplatformwindow.cpp +++ b/src/gui/kernel/qplatformwindow.cpp @@ -213,13 +213,12 @@ QPoint QPlatformWindow::mapFromGlobal(const QPoint &pos) const /*! Requests setting the window state of this surface - to \a type. Returns the actual state set. + to \a type. Qt::WindowActive can be ignored. */ -Qt::WindowState QPlatformWindow::setWindowState(Qt::WindowState) +void QPlatformWindow::setWindowState(Qt::WindowState) { - return Qt::WindowNoState; } /*! diff --git a/src/gui/kernel/qplatformwindow.h b/src/gui/kernel/qplatformwindow.h index 2b2d227fcf..12650d6073 100644 --- a/src/gui/kernel/qplatformwindow.h +++ b/src/gui/kernel/qplatformwindow.h @@ -91,7 +91,7 @@ public: virtual void setVisible(bool visible); virtual void setWindowFlags(Qt::WindowFlags flags); - virtual Qt::WindowState setWindowState(Qt::WindowState state); + virtual void setWindowState(Qt::WindowState state); virtual WId winId() const; virtual void setParent(const QPlatformWindow *window); diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp index 27e1571184..4f1610cb21 100644 --- a/src/gui/kernel/qwindow.cpp +++ b/src/gui/kernel/qwindow.cpp @@ -286,6 +286,10 @@ void QWindow::setVisible(bool visible) QGuiApplicationPrivate::hideModalWindow(this); } +#ifndef QT_NO_CURSOR + if (visible) + d->applyCursor(); +#endif d->platformWindow->setVisible(visible); if (!visible) { @@ -824,9 +828,8 @@ void QWindow::setWindowState(Qt::WindowState state) Q_D(QWindow); if (d->platformWindow) - d->windowState = d->platformWindow->setWindowState(state); - else - d->windowState = state; + d->platformWindow->setWindowState(state); + d->windowState = state; } /*! @@ -1853,11 +1856,10 @@ QCursor QWindow::cursor() const void QWindow::setCursor(const QCursor &cursor) { Q_D(QWindow); - if (QPlatformCursor *platformCursor = d->screen->handle()->cursor()) { - d->cursor = cursor; - QCursor *oc = QGuiApplication::overrideCursor(); - QCursor c = oc ? *oc : d->cursor; - platformCursor->changeCursor(&c, this); + d->cursor = cursor; + // Only attempt to set cursor and emit signal if there is an actual platform cursor + if (d->screen->handle()->cursor()) { + d->applyCursor(); QEvent event(QEvent::CursorChange); QGuiApplication::sendEvent(this, &event); } @@ -1868,19 +1870,20 @@ void QWindow::setCursor(const QCursor &cursor) */ void QWindow::unsetCursor() { - Q_D(QWindow); - if (QPlatformCursor *platformCursor = d->screen->handle()->cursor()) { - d->cursor = Qt::ArrowCursor; - QCursor *oc = QGuiApplication::overrideCursor(); - if (!oc) { - QCursor c = d->cursor; - platformCursor->changeCursor(&c, this); + setCursor(Qt::ArrowCursor); +} + +void QWindowPrivate::applyCursor() +{ + Q_Q(QWindow); + if (platformWindow) { + if (QPlatformCursor *platformCursor = screen->handle()->cursor()) { + QCursor *oc = QGuiApplication::overrideCursor(); + QCursor c = oc ? *oc : cursor; + platformCursor->changeCursor(&c, q); } - QEvent event(QEvent::CursorChange); - QGuiApplication::sendEvent(this, &event); } } - #endif QT_END_NAMESPACE diff --git a/src/gui/kernel/qwindow_p.h b/src/gui/kernel/qwindow_p.h index 57f79f1faa..159f05d1a5 100644 --- a/src/gui/kernel/qwindow_p.h +++ b/src/gui/kernel/qwindow_p.h @@ -97,6 +97,9 @@ public: } void maybeQuitOnLastWindowClosed(); +#ifndef QT_NO_CURSOR + void applyCursor(); +#endif QPoint globalPosition() const { Q_Q(const QWindow); diff --git a/src/gui/painting/qcosmeticstroker.cpp b/src/gui/painting/qcosmeticstroker.cpp index f99edc6194..2eab7b25c5 100644 --- a/src/gui/painting/qcosmeticstroker.cpp +++ b/src/gui/painting/qcosmeticstroker.cpp @@ -414,7 +414,7 @@ void QCosmeticStroker::calculateLastPoint(qreal rx1, qreal ry1, qreal rx2, qreal if (clipLine(rx1, ry1, rx2, ry2)) return; - const int half = 31; + const int half = legacyRounding ? 31 : 0; int x1 = toF26Dot6(rx1) + half; int y1 = toF26Dot6(ry1) + half; int x2 = toF26Dot6(rx2) + half; @@ -707,7 +707,7 @@ static void drawLine(QCosmeticStroker *stroker, qreal rx1, qreal ry1, qreal rx2, if (stroker->clipLine(rx1, ry1, rx2, ry2)) return; - static const int half = 31; + const int half = stroker->legacyRounding ? 31 : 0; int x1 = toF26Dot6(rx1) + half; int y1 = toF26Dot6(ry1) + half; int x2 = toF26Dot6(rx2) + half; diff --git a/src/gui/painting/qcosmeticstroker_p.h b/src/gui/painting/qcosmeticstroker_p.h index f71b87d79d..467eb7a836 100644 --- a/src/gui/painting/qcosmeticstroker_p.h +++ b/src/gui/painting/qcosmeticstroker_p.h @@ -93,11 +93,16 @@ public: patternSize(0), patternLength(0), patternOffset(0), + legacyRounding(false), current_span(0), lastDir(LeftToRight), lastAxisAligned(false) { setup(); } + ~QCosmeticStroker() { free(pattern); free(reversePattern); } + + void setLegacyRoundingEnabled(bool legacyRoundingEnabled) { legacyRounding = legacyRoundingEnabled; } + void drawLine(const QPointF &p1, const QPointF &p2); void drawPath(const QVectorPath &path); void drawPoints(const QPoint *points, int num); @@ -119,6 +124,8 @@ public: int patternLength; int patternOffset; + bool legacyRounding; + enum { NSPANS = 255 }; QT_FT_Span spans[NSPANS]; int current_span; diff --git a/src/gui/painting/qpaintbuffer.cpp b/src/gui/painting/qpaintbuffer.cpp index a2bac58d6c..1e5a00e835 100644 --- a/src/gui/painting/qpaintbuffer.cpp +++ b/src/gui/painting/qpaintbuffer.cpp @@ -1467,6 +1467,8 @@ void QPainterReplayer::process(const QPaintBufferCommand &cmd) painter->setRenderHint(QPainter::SmoothPixmapTransform, nh & QPainter::SmoothPixmapTransform); if (xored & QPainter::NonCosmeticDefaultPen) painter->setRenderHint(QPainter::NonCosmeticDefaultPen, nh & QPainter::NonCosmeticDefaultPen); + if (xored & QPainter::Qt4CompatiblePainting) + painter->setRenderHint(QPainter::Qt4CompatiblePainting, nh & QPainter::Qt4CompatiblePainting); break; } case QPaintBufferPrivate::Cmd_SetOpacity: { diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index 5228fdcf1d..e0eab8dc73 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -644,6 +644,7 @@ QRasterPaintEngineState::QRasterPaintEngineState() flags.fast_pen = true; flags.antialiased = false; flags.bilinear = false; + flags.legacy_rounding = false; flags.fast_text = true; flags.int_xform = true; flags.tx_noshear = true; @@ -927,6 +928,7 @@ void QRasterPaintEngine::renderHintsChanged() s->flags.antialiased = bool(s->renderHints & QPainter::Antialiasing); s->flags.bilinear = bool(s->renderHints & QPainter::SmoothPixmapTransform); + s->flags.legacy_rounding = !bool(s->renderHints & QPainter::Antialiasing) && bool(s->renderHints & QPainter::Qt4CompatiblePainting); if (was_aa != s->flags.antialiased) s->strokeFlags |= DirtyHints; @@ -1524,6 +1526,7 @@ void QRasterPaintEngine::drawRects(const QRect *rects, int rectCount) QRectVectorPath path; if (s->flags.fast_pen) { QCosmeticStroker stroker(s, d->deviceRect); + stroker.setLegacyRoundingEnabled(s->flags.legacy_rounding); for (int i = 0; i < rectCount; ++i) { path.set(rects[i]); stroker.drawPath(path); @@ -1570,6 +1573,7 @@ void QRasterPaintEngine::drawRects(const QRectF *rects, int rectCount) QRectVectorPath path; if (s->flags.fast_pen) { QCosmeticStroker stroker(s, d->deviceRect); + stroker.setLegacyRoundingEnabled(s->flags.legacy_rounding); for (int i = 0; i < rectCount; ++i) { path.set(rects[i]); stroker.drawPath(path); @@ -1603,6 +1607,7 @@ void QRasterPaintEngine::stroke(const QVectorPath &path, const QPen &pen) if (s->flags.fast_pen) { QCosmeticStroker stroker(s, d->deviceRect); + stroker.setLegacyRoundingEnabled(s->flags.legacy_rounding); stroker.drawPath(path); } else if (s->flags.non_complex_pen && path.shape() == QVectorPath::LinesHint) { qreal width = s->lastPen.isCosmetic() @@ -1658,12 +1663,16 @@ void QRasterPaintEngine::stroke(const QVectorPath &path, const QPen &pen) QPaintEngineEx::stroke(path, pen); } -static inline QRect toNormalizedFillRect(const QRectF &rect) +QRect QRasterPaintEngine::toNormalizedFillRect(const QRectF &rect) { - int x1 = qRound(rect.x() + aliasedCoordinateDelta); - int y1 = qRound(rect.y() + aliasedCoordinateDelta); - int x2 = qRound(rect.right() + aliasedCoordinateDelta); - int y2 = qRound(rect.bottom() + aliasedCoordinateDelta); + QRasterPaintEngineState *s = state(); + + qreal delta = s->flags.legacy_rounding ? aliasedCoordinateDelta : qreal(0); + + int x1 = qRound(rect.x() + delta); + int y1 = qRound(rect.y() + delta); + int x2 = qRound(rect.right() + delta); + int y2 = qRound(rect.bottom() + delta); if (x2 < x1) qSwap(x1, x2); @@ -1941,6 +1950,7 @@ void QRasterPaintEngine::drawPolygon(const QPointF *points, int pointCount, Poly QVectorPath vp((qreal *) points, pointCount, 0, QVectorPath::polygonFlags(mode)); if (s->flags.fast_pen) { QCosmeticStroker stroker(s, d->deviceRect); + stroker.setLegacyRoundingEnabled(s->flags.legacy_rounding); stroker.drawPath(vp); } else { QPaintEngineEx::stroke(vp, s->lastPen); @@ -2005,6 +2015,7 @@ void QRasterPaintEngine::drawPolygon(const QPoint *points, int pointCount, Polyg if (s->flags.fast_pen) { QCosmeticStroker stroker(s, d->deviceRect); + stroker.setLegacyRoundingEnabled(s->flags.legacy_rounding); stroker.drawPath(vp); } else { QPaintEngineEx::stroke(vp, s->lastPen); @@ -2233,7 +2244,9 @@ void QRasterPaintEngine::drawImage(const QRectF &r, const QImage &img, const QRe // as fillRect will apply the aliased coordinate delta we need to // subtract it here as we don't use it for image drawing QTransform old = s->matrix; - s->matrix = s->matrix * QTransform::fromTranslate(-aliasedCoordinateDelta, -aliasedCoordinateDelta); + + if (s->flags.legacy_rounding) + s->matrix = s->matrix * QTransform::fromTranslate(-aliasedCoordinateDelta, -aliasedCoordinateDelta); // Do whatever fillRect() does, but without premultiplying the color if it's already premultiplied. QRgb color = img.pixel(sr_l, sr_t); @@ -2376,8 +2389,9 @@ void QRasterPaintEngine::drawImage(const QRectF &r, const QImage &img, const QRe if (s->flags.tx_noshear || s->matrix.type() == QTransform::TxScale) { d->initializeRasterizer(&d->image_filler_xform); d->rasterizer->setAntialiased(s->flags.antialiased); + d->rasterizer->setLegacyRoundingEnabled(s->flags.legacy_rounding); - const QPointF offs = s->flags.antialiased ? QPointF() : QPointF(aliasedCoordinateDelta, aliasedCoordinateDelta); + const QPointF offs = s->flags.legacy_rounding ? QPointF(aliasedCoordinateDelta, aliasedCoordinateDelta) : QPointF(); const QRectF &rect = r.normalized(); const QPointF a = s->matrix.map((rect.topLeft() + rect.bottomLeft()) * 0.5f) - offs; @@ -2390,7 +2404,7 @@ void QRasterPaintEngine::drawImage(const QRectF &r, const QImage &img, const QRe return; } #endif - const qreal offs = s->flags.antialiased ? qreal(0) : aliasedCoordinateDelta; + const qreal offs = s->flags.legacy_rounding ? aliasedCoordinateDelta : qreal(0); QPainterPath path; path.addRect(r); QTransform m = s->matrix; @@ -2471,6 +2485,7 @@ void QRasterPaintEngine::drawTiledPixmap(const QRectF &r, const QPixmap &pixmap, if (s->flags.tx_noshear || s->matrix.type() == QTransform::TxScale) { d->initializeRasterizer(&d->image_filler_xform); d->rasterizer->setAntialiased(s->flags.antialiased); + d->rasterizer->setLegacyRoundingEnabled(s->flags.legacy_rounding); const QRectF &rect = r.normalized(); const QPointF a = s->matrix.map((rect.topLeft() + rect.bottomLeft()) * 0.5f); @@ -2802,7 +2817,7 @@ bool QRasterPaintEngine::drawCachedGlyphs(int numGlyphs, const glyph_t *glyphs, rightShift = 3; // divide by 8 int margin = fontEngine->glyphMargin(glyphType); - const QFixed offs = QFixed::fromReal(aliasedCoordinateDelta); + const QFixed offs = s->flags.legacy_rounding ? QFixed::fromReal(aliasedCoordinateDelta) : QFixed(); const uchar *bits = image.bits(); for (int i=0; i<numGlyphs; ++i) { @@ -3078,6 +3093,7 @@ void QRasterPaintEngine::drawPoints(const QPointF *points, int pointCount) } QCosmeticStroker stroker(s, d->deviceRect); + stroker.setLegacyRoundingEnabled(s->flags.legacy_rounding); stroker.drawPoints(points, pointCount); } @@ -3097,6 +3113,7 @@ void QRasterPaintEngine::drawPoints(const QPoint *points, int pointCount) } QCosmeticStroker stroker(s, d->deviceRect); + stroker.setLegacyRoundingEnabled(s->flags.legacy_rounding); stroker.drawPoints(points, pointCount); } @@ -3117,6 +3134,7 @@ void QRasterPaintEngine::drawLines(const QLine *lines, int lineCount) if (s->flags.fast_pen) { QCosmeticStroker stroker(s, d->deviceRect); + stroker.setLegacyRoundingEnabled(s->flags.legacy_rounding); for (int i=0; i<lineCount; ++i) { const QLine &l = lines[i]; stroker.drawLine(l.p1(), l.p2()); @@ -3188,6 +3206,7 @@ void QRasterPaintEngine::drawLines(const QLineF *lines, int lineCount) return; if (s->flags.fast_pen) { QCosmeticStroker stroker(s, d->deviceRect); + stroker.setLegacyRoundingEnabled(s->flags.legacy_rounding); for (int i=0; i<lineCount; ++i) { QLineF line = lines[i]; stroker.drawLine(line.p1(), line.p2()); @@ -3420,6 +3439,7 @@ void QRasterPaintEnginePrivate::initializeRasterizer(QSpanData *data) QRasterPaintEngineState *s = q->state(); rasterizer->setAntialiased(s->flags.antialiased); + rasterizer->setLegacyRoundingEnabled(s->flags.legacy_rounding); QRect clipRect(deviceRect); ProcessSpans blend; @@ -3484,6 +3504,7 @@ void QRasterPaintEnginePrivate::rasterize(QT_FT_Outline *outline, if (!s->flags.antialiased) { rasterizer->setAntialiased(s->flags.antialiased); + rasterizer->setLegacyRoundingEnabled(s->flags.legacy_rounding); rasterizer->setClipRect(deviceRect); rasterizer->initialize(callback, userData); diff --git a/src/gui/painting/qpaintengine_raster_p.h b/src/gui/painting/qpaintengine_raster_p.h index e1beff047e..8fb72edabd 100644 --- a/src/gui/painting/qpaintengine_raster_p.h +++ b/src/gui/painting/qpaintengine_raster_p.h @@ -110,6 +110,7 @@ public: uint non_complex_pen : 1; // can use rasterizer, rather than stroker uint antialiased : 1; uint bilinear : 1; + uint legacy_rounding : 1; uint fast_text : 1; uint int_xform : 1; uint tx_noshear : 1; @@ -246,6 +247,8 @@ private: bool setClipRectInDeviceCoords(const QRect &r, Qt::ClipOperation op); + QRect toNormalizedFillRect(const QRectF &rect); + inline void ensureBrush(const QBrush &brush) { if (!qbrush_fast_equals(state()->lastBrush, brush) || (brush.style() != Qt::NoBrush && state()->fillFlags)) updateBrush(brush); diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index 02555b6fb6..69267b259b 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -1421,6 +1421,11 @@ void QPainterPrivate::updateState(QPainterState *newState) of 0 (which otherwise enables QPen::isCosmetic()) as being a non-cosmetic pen with a width of 1. + \value Qt4CompatiblePainting Compatibility hint telling the engine to use the + same X11 based fill rules as in Qt 4, where aliased rendering is offset + by slightly less than half a pixel. Potentially useful when porting a + Qt 4 application to Qt 5. + \sa renderHints(), setRenderHint(), {QPainter#Rendering Quality}{Rendering Quality}, {Concentric Circles Example} diff --git a/src/gui/painting/qpainter.h b/src/gui/painting/qpainter.h index c6c0e39ba0..a393b291e3 100644 --- a/src/gui/painting/qpainter.h +++ b/src/gui/painting/qpainter.h @@ -94,7 +94,8 @@ public: TextAntialiasing = 0x02, SmoothPixmapTransform = 0x04, HighQualityAntialiasing = 0x08, - NonCosmeticDefaultPen = 0x10 + NonCosmeticDefaultPen = 0x10, + Qt4CompatiblePainting = 0x20 }; Q_DECLARE_FLAGS(RenderHints, RenderHint) diff --git a/src/gui/painting/qrasterizer.cpp b/src/gui/painting/qrasterizer.cpp index fca037b964..e418f2c326 100644 --- a/src/gui/painting/qrasterizer.cpp +++ b/src/gui/painting/qrasterizer.cpp @@ -129,7 +129,7 @@ public: ~QScanConverter(); void begin(int top, int bottom, int left, int right, - Qt::FillRule fillRule, QSpanBuffer *spanBuffer); + Qt::FillRule fillRule, bool legacyRounding, QSpanBuffer *spanBuffer); void end(); void mergeCurve(const QT_FT_Vector &a, const QT_FT_Vector &b, @@ -177,6 +177,7 @@ private: Q16Dot16 m_rightFP; int m_fillRuleMask; + bool m_legacyRounding; int m_x; int m_y; @@ -196,6 +197,7 @@ class QRasterizerPrivate { public: bool antialiased; + bool legacyRounding; ProcessSpans blend; void *data; QRect clipRect; @@ -219,7 +221,8 @@ QScanConverter::~QScanConverter() } void QScanConverter::begin(int top, int bottom, int left, int right, - Qt::FillRule fillRule, QSpanBuffer *spanBuffer) + Qt::FillRule fillRule, bool legacyRounding, + QSpanBuffer *spanBuffer) { m_top = top; m_bottom = bottom; @@ -229,6 +232,7 @@ void QScanConverter::begin(int top, int bottom, int left, int right, m_lines.reset(); m_fillRuleMask = fillRule == Qt::WindingFill ? ~0x0 : 0x1; + m_legacyRounding = legacyRounding; m_spanBuffer = spanBuffer; } @@ -595,16 +599,20 @@ void QScanConverter::mergeLine(QT_FT_Vector a, QT_FT_Vector b) winding = -1; } - a.x += COORD_OFFSET; - a.y += COORD_OFFSET; - b.x += COORD_OFFSET; - b.y += COORD_OFFSET; + if (m_legacyRounding) { + a.x += COORD_OFFSET; + a.y += COORD_OFFSET; + b.x += COORD_OFFSET; + b.y += COORD_OFFSET; + } + + int rounding = m_legacyRounding ? COORD_ROUNDING : 0; - int iTop = qMax(m_top, int((a.y + 32 - COORD_ROUNDING) >> 6)); - int iBottom = qMin(m_bottom, int((b.y - 32 - COORD_ROUNDING) >> 6)); + int iTop = qMax(m_top, int((a.y + 32 - rounding) >> 6)); + int iBottom = qMin(m_bottom, int((b.y - 32 - rounding) >> 6)); if (iTop <= iBottom) { - Q16Dot16 aFP = Q16Dot16Factor/2 + (a.x << 10) - COORD_ROUNDING; + Q16Dot16 aFP = Q16Dot16Factor/2 + (a.x << 10) - rounding; if (b.x == a.x) { Line line = { qBound(m_leftFP, aFP, m_rightFP), 0, iTop, iBottom, winding }; @@ -635,6 +643,7 @@ void QScanConverter::mergeLine(QT_FT_Vector a, QT_FT_Vector b) QRasterizer::QRasterizer() : d(new QRasterizerPrivate) { + d->legacyRounding = false; } QRasterizer::~QRasterizer() @@ -658,6 +667,11 @@ void QRasterizer::setClipRect(const QRect &clipRect) d->clipRect = clipRect; } +void QRasterizer::setLegacyRoundingEnabled(bool legacyRoundingEnabled) +{ + d->legacyRounding = legacyRoundingEnabled; +} + static Q16Dot16 intersectPixelFP(int x, Q16Dot16 top, Q16Dot16 bottom, Q16Dot16 leftIntersectX, Q16Dot16 rightIntersectX, Q16Dot16 slope, Q16Dot16 invSlope) { Q16Dot16 leftX = IntToQ16Dot16(x); @@ -775,7 +789,7 @@ void QRasterizer::rasterizeLine(const QPointF &a, const QPointF &b, qreal width, pb = npb; } - if (!d->antialiased) { + if (!d->antialiased && d->legacyRounding) { pa.rx() += (COORD_OFFSET - COORD_ROUNDING)/64.; pa.ry() += (COORD_OFFSET - COORD_ROUNDING)/64.; pb.rx() += (COORD_OFFSET - COORD_ROUNDING)/64.; @@ -1174,13 +1188,15 @@ void QRasterizer::rasterize(const QT_FT_Outline *outline, Qt::FillRule fillRule) max_y = qMax(p.y, max_y); } - int iTopBound = qMax(d->clipRect.top(), int((min_y + 32 + COORD_OFFSET - COORD_ROUNDING) >> 6)); - int iBottomBound = qMin(d->clipRect.bottom(), int((max_y - 32 + COORD_OFFSET - COORD_ROUNDING) >> 6)); + int rounding = d->legacyRounding ? COORD_OFFSET - COORD_ROUNDING : 0; + + int iTopBound = qMax(d->clipRect.top(), int((min_y + 32 + rounding) >> 6)); + int iBottomBound = qMin(d->clipRect.bottom(), int((max_y - 32 + rounding) >> 6)); if (iTopBound > iBottomBound) return; - d->scanConverter.begin(iTopBound, iBottomBound, d->clipRect.left(), d->clipRect.right(), fillRule, &buffer); + d->scanConverter.begin(iTopBound, iBottomBound, d->clipRect.left(), d->clipRect.right(), fillRule, d->legacyRounding, &buffer); int first = 0; for (int i = 0; i < outline->n_contours; ++i) { @@ -1210,13 +1226,15 @@ void QRasterizer::rasterize(const QPainterPath &path, Qt::FillRule fillRule) QRectF bounds = path.controlPointRect(); - int iTopBound = qMax(d->clipRect.top(), int(bounds.top() + 0.5 + (COORD_OFFSET - COORD_ROUNDING)/64.)); - int iBottomBound = qMin(d->clipRect.bottom(), int(bounds.bottom() - 0.5 + (COORD_OFFSET - COORD_ROUNDING)/64.)); + double rounding = d->legacyRounding ? (COORD_OFFSET - COORD_ROUNDING) / 64. : 0.0; + + int iTopBound = qMax(d->clipRect.top(), int(bounds.top() + 0.5 + rounding)); + int iBottomBound = qMin(d->clipRect.bottom(), int(bounds.bottom() - 0.5 + rounding)); if (iTopBound > iBottomBound) return; - d->scanConverter.begin(iTopBound, iBottomBound, d->clipRect.left(), d->clipRect.right(), fillRule, &buffer); + d->scanConverter.begin(iTopBound, iBottomBound, d->clipRect.left(), d->clipRect.right(), fillRule, d->legacyRounding, &buffer); int subpathStart = 0; QT_FT_Vector last = { 0, 0 }; diff --git a/src/gui/painting/qrasterizer_p.h b/src/gui/painting/qrasterizer_p.h index 48e9982532..f535db8e6a 100644 --- a/src/gui/painting/qrasterizer_p.h +++ b/src/gui/painting/qrasterizer_p.h @@ -74,6 +74,7 @@ public: void setAntialiased(bool antialiased); void setClipRect(const QRect &clipRect); + void setLegacyRoundingEnabled(bool legacyRoundingEnabled); void initialize(ProcessSpans blend, void *data); diff --git a/src/gui/text/qtextodfwriter.cpp b/src/gui/text/qtextodfwriter.cpp index 33c6ddd1cd..8f6025fdf0 100644 --- a/src/gui/text/qtextodfwriter.cpp +++ b/src/gui/text/qtextodfwriter.cpp @@ -666,13 +666,13 @@ void QTextOdfWriter::writeFrameFormat(QXmlStreamWriter &writer, QTextFrameFormat writer.writeAttribute(styleNS, QString::fromLatin1("name"), QString::fromLatin1("s%1").arg(formatIndex)); writer.writeAttribute(styleNS, QString::fromLatin1("family"), QString::fromLatin1("section")); writer.writeEmptyElement(styleNS, QString::fromLatin1("section-properties")); - if (format.hasProperty(QTextFormat::BlockTopMargin)) + if (format.hasProperty(QTextFormat::FrameTopMargin)) writer.writeAttribute(foNS, QString::fromLatin1("margin-top"), pixelToPoint(qMax(qreal(0.), format.topMargin())) ); - if (format.hasProperty(QTextFormat::BlockBottomMargin)) + if (format.hasProperty(QTextFormat::FrameBottomMargin)) writer.writeAttribute(foNS, QString::fromLatin1("margin-bottom"), pixelToPoint(qMax(qreal(0.), format.bottomMargin())) ); - if (format.hasProperty(QTextFormat::BlockLeftMargin)) + if (format.hasProperty(QTextFormat::FrameLeftMargin)) writer.writeAttribute(foNS, QString::fromLatin1("margin-left"), pixelToPoint(qMax(qreal(0.), format.leftMargin())) ); - if (format.hasProperty(QTextFormat::BlockRightMargin)) + if (format.hasProperty(QTextFormat::FrameRightMargin)) writer.writeAttribute(foNS, QString::fromLatin1("margin-right"), pixelToPoint(qMax(qreal(0.), format.rightMargin())) ); writer.writeEndElement(); // style |