Details
-
Bug
-
Resolution: Done
-
P2: Important
-
5.12.0
-
MacPro (Late 2013) macOS 10.13.6 with HiDPI monitor or any Mac with Retina display, HP z840 running Windows 10 with HiDPI monitor set to 200%.
-
-
64fab8f7e2d225e37aa731db7501b5d5b82eab64 (qt/qtbase/dev)
Description
We are seeing major performance issues on HiDPI displays, both Mac and Windows where there are also complex clip regions.
We have one window that can have thousands of areas with custom painting on a single QWidget. On this window we have some mouse selection operations that subsequently redraw portions of the window after setting a complex clipping region. In this case, "complex" means from 300 to 1000 or more rects. Note that this is still only a subset of the entire window area.
When the user does these selection operations on HiDPI displays it can sometimes take a couple of seconds to 30 seconds or more, depending upon the number of items selected.
When we looked for hot spots in Xcode Instruments and Visual Studio 2017 the we are seeing anywhere from 85 to 90% of the time in the
QPainter::setClipRegion(QRegion const&, Qt::ClipOperation)
method.
Here are some timings from a MacPro (Late 2013) (the Windows numbers are about twice as long.)
Total Time | % CPU | Time | Method |
---|---|---|---|
3.96 s | 85.7% | 0 s | QPainter::setClipRegion(QRegion const&, Qt::ClipOperation) |
3.96 s | 85.7% | 0 s | QRasterPaintEngine::clip(QRegion const&, Qt::ClipOperation) |
3.96 s | 85.7% | 1.00 ms | QTransform::map(QRegion const&) const |
3.82 s | 82.6% | 0 s | QRegion::QRegion(QPolygon const&, Qt::FillRule) |
3.81 s | 82.4% | 3.56 s | PolygonRegion(QPoint const*, int, int) |
Total Time | % CPU | Time | Method |
11.61 s | 90.2% | 2.00 ms | QPainter::setClipRegion(QRegion const&, Qt::ClipOperation) |
11.61 s | 90.2% | 2.00 ms | QRasterPaintEngine::clip(QRegion const&, Qt::ClipOperation) |
11.61 s | 90.2% | 1.00 ms | QTransform::map(QRegion const&) const |
11.25 s | 87.3% | 0 s | QRegion::QRegion(QPolygon const&, Qt::FillRule) |
11.22 s | 87.1% | 10.35 s | PolygonRegion(QPoint const*, int, int) |
It seems that on HiDPI displays the 2.0 display aspect ratio causes the array of rectangles in the QRegion to be mapped to QPolygonRegion and this mapping operations is very CPU intensive.
Suggestion: Add an optimization to avoid the mapping to polygon regions if the transform has no rotation or skew. This should create a QRegion with the same number rectangles.
Attachments
For Gerrit Dashboard: QTBUG-72821 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
249023,6 | Add faster path for scaling QRegion with multiple regions | 5.13 | qt/qtbase | Status: MERGED | +2 | 0 |
249726,1 | Add faster path for scaling QRegion with multiple regions | 5.12 | qt/qtbase | Status: DEFERRED | 0 | 0 |