summaryrefslogtreecommitdiffstats
path: root/tests/auto/qgraphicsscene
diff options
context:
space:
mode:
authorYoann Lopes <yoann.lopes@nokia.com>2009-12-04 15:57:18 +0100
committerYoann Lopes <yoann.lopes@nokia.com>2009-12-04 15:57:18 +0100
commit39392326c8c843a6f46b864c6595a5241a47af10 (patch)
treee89b63d383fc130702c47323d9cd55c86348c880 /tests/auto/qgraphicsscene
parent9a76f02a3147c2da969cb1b942ee7228b13c84cc (diff)
Fixes clipping bug in the embedded dialogs demo.
The problem was that when using DeviceCoordinateCache for items in a scene, newly exposed areas were wrongly painted over the Pixmap in the cache, instead of blending into it. Autotest included. Task-number: QTBUG-657 Reviewed-by: Andreas Reviewed-by: bnilsen
Diffstat (limited to 'tests/auto/qgraphicsscene')
-rw-r--r--tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp39
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp
index 32206db8f0..c5e57f766b 100644
--- a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp
+++ b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp
@@ -280,6 +280,7 @@ private slots:
void task160653_selectionChanged();
void task250680_childClip();
void taskQTBUG_5904_crashWithDeviceCoordinateCache();
+ void taskQT657_paintIntoCacheWithTransparentParts();
};
void tst_QGraphicsScene::initTestCase()
@@ -4270,5 +4271,43 @@ void tst_QGraphicsScene::taskQTBUG_5904_crashWithDeviceCoordinateCache()
// No crash, then it passed!
}
+void tst_QGraphicsScene::taskQT657_paintIntoCacheWithTransparentParts()
+{
+ QWidget *w = new QWidget();
+ w->setPalette(Qt::blue);
+ w->setGeometry(0, 0, 50, 50);
+
+ QGraphicsScene *scene = new QGraphicsScene();
+ QGraphicsView *view = new QGraphicsView(scene);
+
+ QGraphicsProxyWidget *proxy = scene->addWidget(w);
+ proxy->setCacheMode(QGraphicsItem::DeviceCoordinateCache);
+ proxy->rotate(15);
+
+ view->show();
+ QTest::qWaitForWindowShown(view);
+ w->update(10,10,10,10);
+ QTest::qWait(50);
+
+ QPixmap pix;
+ QGraphicsItemPrivate* itemp = QGraphicsItemPrivate::get(proxy);
+ QPixmapCache::Key key = itemp->extraItemCache()->deviceData.value(view->viewport()).key;
+ QVERIFY(QPixmapCache::find(key, &pix));
+
+ QTransform t = proxy->sceneTransform();
+ // Map from scene coordinates to pixmap coordinates.
+ // X origin in the pixmap is the most-left point
+ // of the item's boundingRect in the scene.
+ qreal adjust = t.mapRect(proxy->boundingRect().toRect()).left();
+ QRect rect = t.mapRect(QRect(10, 10, 10, 10)).adjusted(-adjust, 0, -adjust + 1, 1);
+ QPixmap subpix = pix.copy(rect);
+
+ QImage im = subpix.toImage();
+ for(int i = 0; i < im.width(); i++) {
+ for(int j = 0; j < im.height(); j++)
+ QCOMPARE(qAlpha(im.pixel(i, j)), 255);
+ }
+}
+
QTEST_MAIN(tst_QGraphicsScene)
#include "tst_qgraphicsscene.moc"