From a8af0e05b30cc4ec26f58378cd5a4e11b20cf9bd Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Fri, 26 Mar 2010 08:23:58 -0700 Subject: Fix linking error The #include "moc_qgraphicswidget.cpp" is superfluous and caused these link errors: .obj/debug-shared-emb-x86_64/moc_qgraphicswidget.o:(.data.rel.ro+0x0): multiple definition of `QGraphicsWidget::staticMetaObject' .obj/debug-shared-emb-x86_64/qgraphicswidget.o:(.data.rel.ro+0x0): first defined here .obj/debug-shared-emb-x86_64/moc_qgraphicswidget.o: In function `QGraphicsWidget::metaObject() const': Presumably this only happens when you have a stale moc file sitting around but it's a bug none-the-less. Reviewed-by: TrustMe --- src/gui/graphicsview/qgraphicswidget.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/gui/graphicsview/qgraphicswidget.cpp b/src/gui/graphicsview/qgraphicswidget.cpp index a091347..131ee87 100644 --- a/src/gui/graphicsview/qgraphicswidget.cpp +++ b/src/gui/graphicsview/qgraphicswidget.cpp @@ -342,7 +342,7 @@ void QGraphicsWidget::resize(const QSizeF &size) A side effect of calling this function is that the widget will receive a move event and a resize event. Also, if the widget has a layout assigned, the layout will activate. - + \sa geometry(), resize() */ void QGraphicsWidget::setGeometry(const QRectF &rect) @@ -574,7 +574,7 @@ void QGraphicsWidget::getWindowFrameMargins(qreal *left, qreal *top, qreal *righ void QGraphicsWidget::unsetWindowFrameMargins() { Q_D(QGraphicsWidget); - if ((d->windowFlags & Qt::Window) && (d->windowFlags & Qt::WindowType_Mask) != Qt::Popup && + if ((d->windowFlags & Qt::Window) && (d->windowFlags & Qt::WindowType_Mask) != Qt::Popup && (d->windowFlags & Qt::WindowType_Mask) != Qt::ToolTip && !(d->windowFlags & Qt::FramelessWindowHint)) { QStyleOptionTitleBar bar; d->initStyleOptionTitleBar(&bar); @@ -1151,7 +1151,7 @@ bool QGraphicsWidget::sceneEvent(QEvent *event) Returns true if \a event has been recognized and processed; otherwise, returns false. - + \sa event() */ bool QGraphicsWidget::windowFrameEvent(QEvent *event) @@ -1208,7 +1208,7 @@ Qt::WindowFrameSection QGraphicsWidget::windowFrameSectionAt(const QPointF &pos) const QRectF r = windowFrameRect(); if (!r.contains(pos)) return Qt::NoSection; - + const qreal left = r.left(); const qreal top = r.top(); const qreal right = r.right(); @@ -2335,6 +2335,4 @@ void QGraphicsWidget::dumpFocusChain() QT_END_NAMESPACE -#include "moc_qgraphicswidget.cpp" - #endif //QT_NO_GRAPHICSVIEW -- cgit v0.12 From e9538ced914739129681362dea03ebc323602126 Mon Sep 17 00:00:00 2001 From: Yoann Lopes Date: Fri, 26 Mar 2010 16:27:04 +0100 Subject: Reverts using composition mode when using DeviceCoordinateMode cache. Going back to always blitting the newly painted areas to the cache (and not blending it like before). To avoid painting artifacts when the item is rotated and when it uses DeviceCoordinateMode cache mode, the entire cache is always repainted in that case. Task-number: QTBUG-7863 Reviewed-by: trustme --- src/gui/graphicsview/qgraphicsscene.cpp | 13 ++++++------- tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp | 18 +++++++++++------- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index 6934abc..6581727 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -4285,12 +4285,7 @@ static void _q_paintIntoCache(QPixmap *pix, QGraphicsItem *item, const QRegion & if (!subPix.isNull()) { // Blit the subpixmap into the main pixmap. pixmapPainter.begin(pix); - if (item->cacheMode() == QGraphicsItem::DeviceCoordinateCache - && itemToPixmap.type() > QTransform::TxTranslate) { - pixmapPainter.setCompositionMode(QPainter::CompositionMode_SourceAtop); - } else { - pixmapPainter.setCompositionMode(QPainter::CompositionMode_Source); - } + pixmapPainter.setCompositionMode(QPainter::CompositionMode_Source); pixmapPainter.setClipRegion(pixmapExposed); pixmapPainter.drawPixmap(br.topLeft(), subPix); pixmapPainter.end(); @@ -4456,6 +4451,8 @@ void QGraphicsScenePrivate::drawItemHelper(QGraphicsItem *item, QPainter *painte } // Create or reuse offscreen pixmap, possibly scroll/blit from the old one. + // If the world transform is rotated we always recreate the cache to avoid + // wrong blending. bool pixModified = false; QGraphicsItemCache::DeviceData *deviceData = &itemCache->deviceData[widget]; bool invertable = true; @@ -4463,7 +4460,9 @@ void QGraphicsScenePrivate::drawItemHelper(QGraphicsItem *item, QPainter *painte if (invertable) diff *= painter->worldTransform(); deviceData->lastTransform = painter->worldTransform(); - if (!invertable || diff.type() > QTransform::TxTranslate) { + if (!invertable + || diff.type() > QTransform::TxTranslate + || painter->worldTransform().type() > QTransform::TxScale) { pixModified = true; itemCache->allExposed = true; itemCache->exposed.clear(); diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp index 2b507cb..6725159 100644 --- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp @@ -6825,6 +6825,9 @@ void tst_QGraphicsItem::cacheMode() QTRY_COMPARE(tester->repaints, 4); QCOMPARE(testerChild->repaints, 4); QCOMPARE(testerChild2->repaints, 3); + tester->resetTransform(); + testerChild->resetTransform(); + testerChild2->resetTransform(); // Explicit update causes a repaint. tester->update(0, 0, 5, 5); @@ -6898,23 +6901,24 @@ void tst_QGraphicsItem::cacheMode() // because the parent is rotated with a perspective. testerChild->setPos(1, 1); QTest::qWait(25); - QTRY_COMPARE(tester->repaints, 10); + QTRY_COMPARE(tester->repaints, 11); QCOMPARE(testerChild->repaints, 10); QCOMPARE(testerChild2->repaints, 5); + tester->resetTransform(); // Make a huge item tester->setGeometry(QRectF(-4000, -4000, 8000, 8000)); QTest::qWait(25); - QTRY_COMPARE(tester->repaints, 11); - QCOMPARE(testerChild->repaints, 10); + QTRY_COMPARE(tester->repaints, 12); + QCOMPARE(testerChild->repaints, 11); QCOMPARE(testerChild2->repaints, 5); // Move the large item - will cause a repaint as the // cache is clipped. tester->setPos(5, 0); QTest::qWait(25); - QTRY_COMPARE(tester->repaints, 12); - QCOMPARE(testerChild->repaints, 10); + QTRY_COMPARE(tester->repaints, 13); + QCOMPARE(testerChild->repaints, 11); QCOMPARE(testerChild2->repaints, 5); // Hiding and showing should invalidate the cache @@ -6922,8 +6926,8 @@ void tst_QGraphicsItem::cacheMode() QTest::qWait(25); tester->show(); QTest::qWait(25); - QTRY_COMPARE(tester->repaints, 13); - QCOMPARE(testerChild->repaints, 11); + QTRY_COMPARE(tester->repaints, 14); + QCOMPARE(testerChild->repaints, 12); QCOMPARE(testerChild2->repaints, 6); } -- cgit v0.12