summaryrefslogtreecommitdiffstats
path: root/tests/manual/highdpi
diff options
context:
space:
mode:
authorMorten Johan Sørvig <morten.sorvig@qt.io>2016-11-25 13:57:48 +0100
committerMorten Johan Sørvig <morten.sorvig@qt.io>2018-04-26 23:39:46 +0000
commit18d26192242873625a3132d0ad6b9342226d14bb (patch)
treeec2b123672466094bbcb9e44744f02eb39a55aff /tests/manual/highdpi
parent19950b3267752fbde4a8845bd203172b43fbaffd (diff)
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 <garfieldhq@yahoo.com> Task-number: QTBUG-26795 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Diffstat (limited to 'tests/manual/highdpi')
-rw-r--r--tests/manual/highdpi/main.cpp28
1 files changed, 27 insertions, 1 deletions
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 <QPainter>
#include <QWindow>
#include <QScreen>
+#include <QGraphicsView>
+#include <QGraphicsTextItem>
#include <QFile>
#include <QMouseEvent>
#include <QTemporaryDir>
@@ -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<CursorTester>("cursorpos", "Test cursor and window positioning");
demoList << new DemoContainer<ScreenDisplayer>("screens", "Test screen and window positioning");
demoList << new DemoContainer<PhysicalSizeTest>("physicalsize", "Test manual highdpi support using physicalDotsPerInch");
-
+ demoList << new DemoContainer<GraphicsViewCaching>("graphicsview", "Test QGraphicsView caching");
foreach (DemoContainerBase *demo, demoList)
parser.addOption(demo->option());