From 18d26192242873625a3132d0ad6b9342226d14bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Fri, 25 Nov 2016 13:57:48 +0100 Subject: QGraphicsView: Improve high-DPI item caching Scale cache size by target paint device devicePixelRatio. Add manual test for the cache modes. Change-Id: I9f3a2b4c4cf12571aefe54ebf534009a2448fb48 Done-with: MihailNaydenov Task-number: QTBUG-26795 Reviewed-by: Friedemann Kleint Reviewed-by: Richard Moe Gustavsen --- tests/manual/highdpi/main.cpp | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'tests/manual/highdpi') diff --git a/tests/manual/highdpi/main.cpp b/tests/manual/highdpi/main.cpp index 6f854a68d4..50ad164597 100644 --- a/tests/manual/highdpi/main.cpp +++ b/tests/manual/highdpi/main.cpp @@ -45,6 +45,8 @@ #include #include #include +#include +#include #include #include #include @@ -1151,6 +1153,30 @@ void PhysicalSizeTest::paintEvent(QPaintEvent *) } +class GraphicsViewCaching : public QGraphicsView +{ +public: + GraphicsViewCaching() { + QGraphicsScene *scene = new QGraphicsScene(0, 0, 400, 400); + + QGraphicsTextItem *item = 0; + + item = scene->addText("NoCache"); + item->setCacheMode(QGraphicsItem::NoCache); + item->setPos(10, 10); + + item = scene->addText("ItemCoordinateCache"); + item->setCacheMode(QGraphicsItem::ItemCoordinateCache); + item->setPos(10, 30); + + item = scene->addText("DeviceCoordinateCache"); + item->setCacheMode(QGraphicsItem::DeviceCoordinateCache); + item->setPos(10, 50); + + setScene(scene); + } +}; + int main(int argc, char **argv) { QApplication app(argc, argv); @@ -1186,7 +1212,7 @@ int main(int argc, char **argv) demoList << new DemoContainer("cursorpos", "Test cursor and window positioning"); demoList << new DemoContainer("screens", "Test screen and window positioning"); demoList << new DemoContainer("physicalsize", "Test manual highdpi support using physicalDotsPerInch"); - + demoList << new DemoContainer("graphicsview", "Test QGraphicsView caching"); foreach (DemoContainerBase *demo, demoList) parser.addOption(demo->option()); -- cgit v1.2.3