--- a/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp Tue Feb 02 00:43:10 2010 +0200
+++ b/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp Fri Feb 19 23:40:16 2010 +0200
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -70,6 +70,7 @@
void grayscale();
void colorize();
void drawPixmapItem();
+ void deviceCoordinateTranslateCaching();
};
void tst_QGraphicsEffect::initTestCase()
@@ -514,6 +515,51 @@
QTRY_VERIFY(effect->repaints >= 2);
}
+class DeviceEffect : public QGraphicsEffect
+{
+public:
+ QRectF boundingRectFor(const QRectF &rect) const
+ { return rect; }
+
+ void draw(QPainter *painter)
+ {
+ QPoint offset;
+ QPixmap pixmap = sourcePixmap(Qt::DeviceCoordinates, &offset, QGraphicsEffect::NoPad);
+
+ if (pixmap.isNull())
+ return;
+
+ painter->save();
+ painter->setWorldTransform(QTransform());
+ painter->drawPixmap(offset, pixmap);
+ painter->restore();
+ }
+};
+
+void tst_QGraphicsEffect::deviceCoordinateTranslateCaching()
+{
+ QGraphicsScene scene;
+ CustomItem *item = new CustomItem(0, 0, 10, 10);
+ scene.addItem(item);
+ scene.setSceneRect(0, 0, 50, 0);
+
+ item->setGraphicsEffect(new DeviceEffect);
+ item->setPen(Qt::NoPen);
+ item->setBrush(Qt::red);
+
+ QGraphicsView view(&scene);
+ view.show();
+ QTest::qWaitForWindowShown(&view);
+
+ QTRY_VERIFY(item->numRepaints >= 1);
+ int numRepaints = item->numRepaints;
+
+ item->translate(10, 0);
+ QTest::qWait(50);
+
+ QVERIFY(item->numRepaints == numRepaints);
+}
+
QTEST_MAIN(tst_QGraphicsEffect)
#include "tst_qgraphicseffect.moc"